mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1218474 - Improve the referrer checks in worker mochitests, r=bkelly
This commit is contained in:
parent
1bcd4d95d4
commit
61abf8e5dc
@ -112,6 +112,7 @@ support-files =
|
|||||||
performance_observer.html
|
performance_observer.html
|
||||||
sharedWorker_ports.js
|
sharedWorker_ports.js
|
||||||
sharedWorker_lifetime.js
|
sharedWorker_lifetime.js
|
||||||
|
worker_referrer.js
|
||||||
|
|
||||||
[test_404.html]
|
[test_404.html]
|
||||||
[test_atob.html]
|
[test_atob.html]
|
||||||
|
@ -2,10 +2,14 @@ function handleRequest(request, response)
|
|||||||
{
|
{
|
||||||
if (request.queryString == "result") {
|
if (request.queryString == "result") {
|
||||||
response.write(getState("referer"));
|
response.write(getState("referer"));
|
||||||
} else {
|
setState("referer", "INVALID");
|
||||||
|
} else if (request.queryString == "worker") {
|
||||||
response.setHeader("Content-Type", "text/javascript", false);
|
response.setHeader("Content-Type", "text/javascript", false);
|
||||||
response.write("onmessage = function() { postMessage(42); }");
|
response.write("onmessage = function() { postMessage(42); }");
|
||||||
setState("referer", request.getHeader("referer"));
|
setState("referer", request.getHeader("referer"));
|
||||||
|
} else if (request.queryString == 'import') {
|
||||||
|
setState("referer", request.getHeader("referer"));
|
||||||
|
response.write("'hello world'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,19 +15,42 @@
|
|||||||
<pre id="test"></pre>
|
<pre id="test"></pre>
|
||||||
<script class="testbody" type="text/javascript">
|
<script class="testbody" type="text/javascript">
|
||||||
|
|
||||||
var worker = new Worker("referrer.sjs");
|
function test_mainScript() {
|
||||||
worker.onmessage = function() {
|
var worker = new Worker("referrer.sjs?worker");
|
||||||
var xhr = new XMLHttpRequest();
|
worker.onmessage = function() {
|
||||||
xhr.open('GET', 'referrer.sjs?result', true);
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onload = function() {
|
xhr.open('GET', 'referrer.sjs?result', true);
|
||||||
is(xhr.responseText, location.href, "The referrer has been sent.");
|
xhr.onload = function() {
|
||||||
SimpleTest.finish();
|
is(xhr.responseText, location.href, "The referrer has been sent.");
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
xhr.send();
|
||||||
}
|
}
|
||||||
xhr.send();
|
worker.postMessage(42);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_importScript() {
|
||||||
|
var worker = new Worker("worker_referrer.js");
|
||||||
|
worker.onmessage = function(e) {
|
||||||
|
is(e.data, location.href.replace("test_referrer.html", "worker_referrer.js"), "The referrer has been sent.");
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
worker.postMessage(42);
|
||||||
|
}
|
||||||
|
|
||||||
|
var tests = [ test_mainScript, test_importScript ];
|
||||||
|
function next() {
|
||||||
|
if (!tests.length) {
|
||||||
|
SimpleTest.finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var test = tests.shift();
|
||||||
|
test();
|
||||||
}
|
}
|
||||||
worker.postMessage(42);
|
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
next();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
|
9
dom/workers/test/worker_referrer.js
Normal file
9
dom/workers/test/worker_referrer.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
onmessage = function() {
|
||||||
|
importScripts(['referrer.sjs?import']);
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', 'referrer.sjs?result', true);
|
||||||
|
xhr.onload = function() {
|
||||||
|
postMessage(xhr.responseText);
|
||||||
|
}
|
||||||
|
xhr.send();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user