blob: 1ad94a47e5eebffbf660948c29ebf1187848b8fd [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function createBlockedResourceLoad() {
testRunner.setWillSendRequestReturnsNull(true);
let img = document.createElement("img");
img.src = "does-not-exist.png";
document.body.appendChild(img);
}
function test()
{
let suite = InspectorTest.createAsyncSuite("ClientBlockedResourceLoad");
suite.addTestCase({
name: "TriggerBlockedResourceLoad",
description: "Trigger a blocked resource load and ensure we get notified of the request.",
test(resolve, reject) {
InspectorTest.evaluateInPage("createBlockedResourceLoad()");
WI.Frame.singleFireEventListener(WI.Frame.Event.ResourceWasAdded, (event) => {
let resource = event.data.resource;
InspectorTest.expectThat(resource instanceof WI.Resource, "Resource should be created.");
InspectorTest.expectThat(resource.url === "", "Request url should be rewritten to the null string.");
resource.singleFireEventListener(WI.Resource.Event.LoadingDidFail, (event) => {
InspectorTest.pass("Resource load should fail.");
resolve();
});
});
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests that there is no crash when the client blocks a resource load.</p>
</body>
</html>