blob: 03605717273439c935a3848ccf91d3e2df6a366a [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function test()
{
let suite = InspectorTest.createAsyncSuite("AuditTestCase");
function addPayloadTest({name, payload}) {
suite.addTestCase({
name,
async test() {
let object = await WI.AuditTestCase.fromPayload(payload);
function replacer(key, value) {
if (key === "supports")
return `<version + ${value - WI.AuditTestBase.Version}>`;
return value;
}
InspectorTest.log(object ? JSON.stringify(object, replacer, 2) : object);
},
});
}
let payloadTests = [
{
name: "AuditTestCase.fromPayload.nullObject",
payload: null,
},
{
name: "AuditTestCase.fromPayload.nonObject",
payload: "INVALID",
},
{
name: "AuditTestCase.fromPayload.emptyObject",
payload: {},
},
{
name: "AuditTestCase.fromPayload.invalidTopLevelMembers",
payload: {
type: null,
name: null,
test: null,
},
},
{
name: "AuditTestCase.fromPayload.valid",
payload: {
type: WI.AuditTestCase.TypeIdentifier,
name: "valid test name",
test: "function() { }",
},
},
{
name: "AuditTestCase.fromPayload.validWithInvalidOptionals",
payload: {
type: WI.AuditTestCase.TypeIdentifier,
name: "validWithInvalidOptionals test name",
description: null,
supports: WI.AuditTestBase.Version + 1,
setup: null,
test: "validWithInvalidOptionals test function",
},
},
{
name: "AuditTestCase.fromPayload.validWithValidOptionals",
payload: {
type: WI.AuditTestCase.TypeIdentifier,
name: "validWithValidOptionals test name",
description: "validWithValidOptionals test description",
supports: WI.AuditTestBase.Version - 1,
setup: "validWithValidOptionals test setup",
test: "validWithValidOptionals test function",
},
},
];
payloadTests.forEach(addPayloadTest);
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Testing the functions of WI.AuditTestCase.</p>
</body>
</html>