Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / workers / resources / referer.js
blob980ce163256ccef41391322d802195ad516f0918
1 var refererLocation = location.href.replace(/:\/\/.*\@/, "://").replace(/#.*$/, "");
2 var xhr = new XMLHttpRequest;
4 importScripts("worker-pre.js");
6 function log(message)
8 postMessage("log " + message);
11 function done()
13 postMessage("DONE");
16 function verifyReferer(method, xhr)
18 if (xhr.responseText == refererLocation)
19 log("PASS: " + method + " referer.");
20 else
21 log("FAIL: " + method + ". Expected referer: '" + refererLocation + "' Actual referer: '" + xhr.responseText + "'");
24 function processStateChange()
26 if (xhr.readyState == 4) {
27 verifyReferer("Async", xhr);
28 done();
32 function init()
34 xhr.open("GET", "../../resources/print-referer.cgi", false);
35 xhr.send(null);
36 verifyReferer("Sync", xhr);
37 xhr.open("GET", "../../resources/print-referer.cgi", true);
38 xhr.onreadystatechange = processStateChange;
39 xhr.send(null);