<head>
<script>
if (window.testRunner && window.internals) {
    testRunner.dumpAsText();
    testRunner.dumpChildFramesAsText();
    internals.settings.setHyperlinkAuditingEnabled(true);
    testRunner.waitUntilDone();
}

function loadLinkWithPing() {
    var iframe = document.getElementById("link_frame");
    var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
    iframeDoc.write('' +
        '<img src="resources/delete-ping.py?test=contentextensions-block-cookies-in-ping" ' + 
            'onerror="parent.clickOnLinkWithPing();">' +
        '<a id="a" ' +
            'href="resources/check-ping.html" ' + // check-ping.html calls showPingResult()
            'ping="resources/save-ping.py?test=contentextensions-block-cookies-in-ping"> ' +
            'Link with ping' +
        '</a>'
        
    );
}

function clickOnLinkWithPing() {
    var iframe = document.getElementById("link_frame");
    var iframeDoc = iframe.contentDocument;
    if (window.eventSender) {
        var a = iframeDoc.getElementById("a");
        var x = iframe.offsetLeft + a.offsetLeft + 2;
        var y = iframe.offsetTop + a.offsetTop + 2;
        eventSender.mouseMoveTo(x, y);
        eventSender.mouseDown();
        eventSender.mouseUp();
    }
}

function showPingResult() {
    var iframe = document.getElementById("result_frame");
    iframe.onload = function() {
        if (window.testRunner) { testRunner.notifyDone() }
    }
    iframe.src = "resources/get-ping-data.py?test=contentextensions-block-cookies-in-ping";
}
</script>
</head>

<body>
This test sets a cookie, then follows a link with a ping attribute where the ping URL matches a 'block-cookie' rule.
<img src="http://localhost:8000/cookies/resources/cookie-utility.py?queryfunction=setFooCookie"
    onerror="loadLinkWithPing();">
<iframe id="link_frame" name="link_frame"><!-- Will contain link with ping --></iframe>
<iframe id="result_frame" name="result_frame"><!-- Will contain ping data received by server --></iframe>
</body>

