Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
7 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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> |