Skip to content
Permalink
Browse files
2011-03-03 David Levin <levin@chromium.org>
        Reviewed by Darin Adler.

        Need web worker referer layout test for xhr requests.
        https://bugs.webkit.org/show_bug.cgi?id=55590

        Verify that the referrer is set for sync and async XHR requests
        from both workers and shared workers.

        * http/tests/xmlhttprequest/workers/referer-expected.txt: Added.
        * http/tests/xmlhttprequest/workers/referer.html: Added.
        * http/tests/xmlhttprequest/workers/resources/referer-test.js: Added.
        * http/tests/xmlhttprequest/workers/resources/referer.js: Added.
        * http/tests/xmlhttprequest/workers/shared-worker-referer-expected.txt: Added.
        * http/tests/xmlhttprequest/workers/shared-worker-referer.html: Added.

Canonical link: https://commits.webkit.org/70205@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80311 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
David Levin committed Mar 4, 2011
1 parent ec75e27 commit 7c109d728e38dde698cf211addb4cf953cbd625e
Showing 7 changed files with 111 additions and 0 deletions.
@@ -1,3 +1,20 @@
2011-03-03 David Levin <levin@chromium.org>

Reviewed by Darin Adler.

Need web worker referer layout test for xhr requests.
https://bugs.webkit.org/show_bug.cgi?id=55590

Verify that the referrer is set for sync and async XHR requests
from both workers and shared workers.

* http/tests/xmlhttprequest/workers/referer-expected.txt: Added.
* http/tests/xmlhttprequest/workers/referer.html: Added.
* http/tests/xmlhttprequest/workers/resources/referer-test.js: Added.
* http/tests/xmlhttprequest/workers/resources/referer.js: Added.
* http/tests/xmlhttprequest/workers/shared-worker-referer-expected.txt: Added.
* http/tests/xmlhttprequest/workers/shared-worker-referer.html: Added.

2011-03-02 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Steve Block.
@@ -0,0 +1,4 @@
Referer should be set for XMLHttpRequest from Workers.

FAIL: Sync. Expected referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/resources/referer.js' Actual referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/referer.html'
FAIL: Async. Expected referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/resources/referer.js' Actual referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/referer.html'
@@ -0,0 +1,7 @@
<html>
<body>
<p>Referer should be set for XMLHttpRequest from Workers.</p>
<script src="resources/worker-create.js"></script>
<script src="resources/referer-test.js"></script>
</body>
</html>
@@ -0,0 +1,31 @@
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}

var console_messages = document.createElement("ul");
document.body.appendChild(console_messages);

function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
console_messages.appendChild(item);
}

var workerUrl = location.protocol + "//MyUserName:MySecurePassword@" + location.host + location.pathname.replace(/\/[^\/]*$/, "") + '/resources/referer.js#ref';
var worker = createWorker(workerUrl);

worker.onmessage = function(evt)
{
if (/log .+/.test(evt.data))
log(evt.data.substr(4));
else if (/DONE/.test(evt.data)) {
if (window.layoutTestController)
layoutTestController.notifyDone();
} else {
log("ERROR");
if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
@@ -0,0 +1,41 @@
var refererLocation = location.href.replace(/:\/\/.*\@/, "://").replace(/#.*$/, "");
var xhr = new XMLHttpRequest;

importScripts("worker-pre.js");

function log(message)
{
postMessage("log " + message);
}

function done()
{
postMessage("DONE");
}

function verifyReferer(method, xhr)
{
if (xhr.responseText == refererLocation)
log("PASS: " + method + " referer.");
else
log("FAIL: " + method + ". Expected referer: '" + refererLocation + "' Actual referer: '" + xhr.responseText + "'");
}

function processStateChange()
{
if (xhr.readyState == 4) {
verifyReferer("Async", xhr);
done();
}
}

function init()
{
xhr.open("GET", "../../resources/print-referer.cgi", false);
xhr.send(null);
verifyReferer("Sync", xhr);
xhr.open("GET", "../../resources/print-referer.cgi", true);
xhr.onreadystatechange = processStateChange;
xhr.send(null);
}

@@ -0,0 +1,4 @@
Referer should be set for XMLHttpRequest from SharedWorkers.

FAIL: Sync. Expected referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/resources/referer.js' Actual referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/shared-worker-referer.html'
FAIL: Async. Expected referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/resources/referer.js' Actual referer: 'http://127.0.0.1:8000/xmlhttprequest/workers/shared-worker-referer.html'
@@ -0,0 +1,7 @@
<html>
<body>
<p>Referer should be set for XMLHttpRequest from SharedWorkers.</p>
<script src="resources/shared-worker-create.js"></script>
<script src="resources/referer-test.js"></script>
</body>
</html>

0 comments on commit 7c109d7

Please sign in to comment.