<head>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function loadNextPage() {
    // Navigating to another location invokes the unload handler
    location.href = "resources/redirect.py?to=" + 
                        encodeURIComponent(
                        "/contentextensions/resources/get-ping-data.py?" + 
                        "test=contentextensions-block-image-load-in-onunload&" +
                        "timeout_ms=1000&" +
                        "end_test=1");
    // Why timeout_ms=1000:
    // To pass the test, the ping shouldn't arrive, so we need to
    // timeout at some point. We don't have to wait too long because
    // the console message can tell us whether the ping was blocked.
}

function loadImage() {
    var img = new Image(1, 1);
    img.src = "resources/save-ping.py?test=contentextensions-block-image-load-in-onunload";
}
</script>
</head>

<body onunload="loadImage();">
This test loads an image in onunload, where the image URL matches a 'block' rule.
<img src="resources/delete-ping.py?test=contentextensions-block-image-load-in-onunload" onerror="loadNextPage();">
</body>

