blob: a384a5e6dadb38d51b61923558279b2d0bd1d6aa [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()");
WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
let resource = event.data.resource;
InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
InspectorTest.expectThat(resource.url === "", "Request url should be rewritten to the null string.");
resource.singleFireEventListener(WebInspector.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>