mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1142727 - Do not intercept sandboxed iframes with service workers; r=nsm
This is temporary until we clarify what we want to do with these iframes in the spec.
This commit is contained in:
parent
ff8405ed01
commit
b5a110ac65
@ -13950,6 +13950,11 @@ NS_IMETHODIMP
|
||||
nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, bool* aShouldIntercept)
|
||||
{
|
||||
*aShouldIntercept = false;
|
||||
if (mSandboxFlags) {
|
||||
// If we're sandboxed, don't intercept.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager();
|
||||
if (!swm) {
|
||||
return NS_OK;
|
||||
|
5
dom/workers/test/serviceworkers/fetch/sandbox/index.html
Normal file
5
dom/workers/test/serviceworkers/fetch/sandbox/index.html
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
window.parent.postMessage({status: "ok", result: true, message: "The iframe is not being intercepted"}, "*");
|
||||
window.parent.postMessage({status: "done"}, "*");
|
||||
</script>
|
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
window.parent.postMessage({status: "ok", result: false, message: "The iframe is being intercepted"}, "*");
|
||||
window.parent.postMessage({status: "done"}, "*");
|
||||
</script>
|
26
dom/workers/test/serviceworkers/fetch/sandbox/register.html
Normal file
26
dom/workers/test/serviceworkers/fetch/sandbox/register.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
function ok(v, msg) {
|
||||
window.parent.postMessage({status: "ok", result: !!v, message: msg}, "*");
|
||||
}
|
||||
|
||||
var isDone = false;
|
||||
function done(reg) {
|
||||
if (!isDone) {
|
||||
ok(reg.waiting || reg.active, "Either active or waiting worker should be available.");
|
||||
window.parent.postMessage({status: "registrationdone"}, "*");
|
||||
isDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
navigator.serviceWorker.register("sandbox_test.js", {scope: "."})
|
||||
.then(function(registration) {
|
||||
if (registration.installing) {
|
||||
registration.installing.onstatechange = function(e) {
|
||||
done(registration);
|
||||
};
|
||||
} else {
|
||||
done(registration);
|
||||
}
|
||||
});
|
||||
</script>
|
@ -0,0 +1,5 @@
|
||||
self.addEventListener("fetch", function(event) {
|
||||
if (event.request.url.indexOf("index.html") >= 0) {
|
||||
event.respondWith(fetch("intercepted_index.html"));
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
navigator.serviceWorker.getRegistration(".").then(function(registration) {
|
||||
registration.unregister().then(function(success) {
|
||||
if (success) {
|
||||
window.parent.postMessage({status: "unregistrationdone"}, "*");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
@ -34,6 +34,11 @@ support-files =
|
||||
fetch/https/clonedresponse/register.html
|
||||
fetch/https/clonedresponse/unregister.html
|
||||
fetch/https/clonedresponse/https_test.js
|
||||
fetch/sandbox/index.html
|
||||
fetch/sandbox/intercepted_index.html
|
||||
fetch/sandbox/register.html
|
||||
fetch/sandbox/unregister.html
|
||||
fetch/sandbox/sandbox_test.js
|
||||
match_all_properties_worker.js
|
||||
match_all_clients/match_all_controlled.html
|
||||
test_serviceworker_interfaces.js
|
||||
@ -68,3 +73,4 @@ support-files =
|
||||
[test_serviceworker_interfaces.html]
|
||||
[test_serviceworker_not_sharedworker.html]
|
||||
[test_match_all_client_id.html]
|
||||
[test_sandbox_intercept.html]
|
||||
|
51
dom/workers/test/serviceworkers/test_sandbox_intercept.html
Normal file
51
dom/workers/test/serviceworkers/test_sandbox_intercept.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1142727 - Test that sandboxed iframes are not intercepted</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">
|
||||
<iframe sandbox="allow-scripts allow-same-origin"></iframe>
|
||||
</div>
|
||||
<pre id="test"></pre>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var iframe;
|
||||
function runTest() {
|
||||
iframe = document.querySelector("iframe");
|
||||
iframe.src = "/tests/dom/workers/test/serviceworkers/fetch/sandbox/register.html";
|
||||
var ios;
|
||||
window.onmessage = function(e) {
|
||||
if (e.data.status == "ok") {
|
||||
ok(e.data.result, e.data.message);
|
||||
} else if (e.data.status == "registrationdone") {
|
||||
iframe.src = "/tests/dom/workers/test/serviceworkers/fetch/sandbox/index.html";
|
||||
} else if (e.data.status == "done") {
|
||||
iframe.src = "/tests/dom/workers/test/serviceworkers/fetch/sandbox/unregister.html";
|
||||
} else if (e.data.status == "unregistrationdone") {
|
||||
window.onmessage = null;
|
||||
ok(true, "Test finished successfully");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
onload = function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
]}, runTest);
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user