chromium/third_party/blink/web_tests/http/tests/navigation/ping-cookie.html

<html><head>
<title>Ping</title>
<script>

var testCalled = false;

function test() {
    if (!testCalled) {
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
            testRunner.waitUntilDone();
            testRunner.dumpPingLoaderCallbacks();
        }
        testCalled = true;
        return;
    }
    try {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", "../cookies/resources/setCookies.cgi", false);
        xhr.setRequestHeader("X-SET-COOKIE", "hello=world;path=/");
        xhr.send(null);
        if (xhr.status != 200) {
            document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
            if (window.testRunner)
                testRunner.notifyDone();
        }
    } catch (e) {
        document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
        if (window.testRunner)
            testRunner.notifyDone();
    }

    if (window.eventSender) {
        var a = document.getElementById("a");
        eventSender.mouseMoveTo(a.offsetLeft + 2, a.offsetTop + 2);
        eventSender.mouseDown();
        eventSender.mouseUp();
    }
}

</script>
</head>
<body onload="test();">
<img src="resources/delete-ping.php?test=cookie" onload="test();" onerror="test();"></img>
<a id="a" href="resources/check-ping.php?test=cookie" ping="resources/save-Ping.php?test=cookie">Navigate and send ping</a>
</body></html>