Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
8 changed files
with
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
5 changes: 5 additions & 0 deletions
5
dom/workers/test/serviceworkers/fetch/sandbox/intercepted_index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 26 additions & 0 deletions
26
dom/workers/test/serviceworkers/fetch/sandbox/register.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
5 changes: 5 additions & 0 deletions
5
dom/workers/test/serviceworkers/fetch/sandbox/sandbox_test.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
self.addEventListener("fetch", function(event) { | ||
if (event.request.url.indexOf("index.html") >= 0) { | ||
event.respondWith(fetch("intercepted_index.html")); | ||
} | ||
}); |
10 changes: 10 additions & 0 deletions
10
dom/workers/test/serviceworkers/fetch/sandbox/unregister.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
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
51 changes: 51 additions & 0 deletions
51
dom/workers/test/serviceworkers/test_sandbox_intercept.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |