зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1218474 - Improve the referrer checks in worker mochitests, r=bkelly
This commit is contained in:
Родитель
1bcd4d95d4
Коммит
61abf8e5dc
|
@ -112,6 +112,7 @@ support-files =
|
|||
performance_observer.html
|
||||
sharedWorker_ports.js
|
||||
sharedWorker_lifetime.js
|
||||
worker_referrer.js
|
||||
|
||||
[test_404.html]
|
||||
[test_atob.html]
|
||||
|
|
|
@ -2,10 +2,14 @@ function handleRequest(request, response)
|
|||
{
|
||||
if (request.queryString == "result") {
|
||||
response.write(getState("referer"));
|
||||
} else {
|
||||
setState("referer", "INVALID");
|
||||
} else if (request.queryString == "worker") {
|
||||
response.setHeader("Content-Type", "text/javascript", false);
|
||||
response.write("onmessage = function() { postMessage(42); }");
|
||||
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>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var worker = new Worker("referrer.sjs");
|
||||
worker.onmessage = function() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'referrer.sjs?result', true);
|
||||
xhr.onload = function() {
|
||||
is(xhr.responseText, location.href, "The referrer has been sent.");
|
||||
SimpleTest.finish();
|
||||
function test_mainScript() {
|
||||
var worker = new Worker("referrer.sjs?worker");
|
||||
worker.onmessage = function() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'referrer.sjs?result', true);
|
||||
xhr.onload = function() {
|
||||
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();
|
||||
next();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -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();
|
||||
}
|
Загрузка…
Ссылка в новой задаче