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

function deletePing() {
    var deletePingContainer = document.getElementById("delete_ping_container");
    deletePingContainer.innerHTML = '<img src="resources/delete-ping.py?test=contentextensions-block-cookies-in-image-load-in-onunload" onerror="loadNextPage();">';
}

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-cookies-in-image-load-in-onunload&" +
                        "end_test=1");
}

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

<body onunload="loadImage();">
This test sets a cookie, then loads an image in onunload, where the image URL matches a 'block-cookie' rule.
<img src="http://127.0.0.1:8000/cookies/resources/cookie-utility.py?queryfunction=setFooCookie"
    onerror="deletePing();">
<div id="delete_ping_container"></div>
</body>

