зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1168933 - Send referrer when downloading worker script. r=khuey
--HG-- extra : rebase_source : b4fa11d4ba34525979c98de119934beffba284f7
This commit is contained in:
Родитель
0627a09358
Коммит
d56d23dc96
|
@ -191,6 +191,14 @@ ChannelFromScriptURL(nsIPrincipal* principal,
|
|||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel)) {
|
||||
rv = nsContentUtils::SetFetchReferrerURIWithPolicy(principal, parentDoc,
|
||||
httpChannel);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
channel.forget(aChannel);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ support-files =
|
|||
empty.html
|
||||
worker_performance_user_timing.js
|
||||
sharedworker_performance_user_timing.js
|
||||
referrer.sjs
|
||||
|
||||
[test_404.html]
|
||||
[test_atob.html]
|
||||
|
@ -209,3 +210,4 @@ skip-if = buildapp == 'b2g' || e10s
|
|||
[test_xhr_timeout.html]
|
||||
skip-if = (os == "win") || (os == "mac") || toolkit == 'android' || e10s #bug 798220
|
||||
[test_xhrAbort.html]
|
||||
[test_referrer.html]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
function handleRequest(request, response)
|
||||
{
|
||||
if (request.queryString == "result") {
|
||||
response.write(getState("referer"));
|
||||
} else {
|
||||
response.setHeader("Content-Type", "text/javascript", false);
|
||||
response.write("onmessage = function() { postMessage(42); }");
|
||||
setState("referer", request.getHeader("referer"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test the referrer of workers</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<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();
|
||||
}
|
||||
xhr.send();
|
||||
}
|
||||
worker.postMessage(42);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче