Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/resources/sandboxed-iframe-fetch-event-iframe.html

Issue 1208693003: Add LayoutTest for ServiceWorker's sandbox iframe handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use in Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/sandboxed-iframe-fetch-event-worker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/chromium/resources/sandboxed-iframe-fetch-event-iframe.html
diff --git a/LayoutTests/http/tests/serviceworker/chromium/resources/sandboxed-iframe-fetch-event-iframe.html b/LayoutTests/http/tests/serviceworker/chromium/resources/sandboxed-iframe-fetch-event-iframe.html
new file mode 100644
index 0000000000000000000000000000000000000000..ac99a02fae585b85c20e1837d0111cec981eff23
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/resources/sandboxed-iframe-fetch-event-iframe.html
@@ -0,0 +1,42 @@
+<script>
+function with_iframe(url) {
+ return new Promise(function(resolve) {
+ var frame = document.createElement('iframe');
+ frame.src = url;
+ frame.onload = function() { resolve(frame); };
+ document.body.appendChild(frame);
+ });
+}
+
+function with_sandboxed_iframe(url, sandbox) {
+ return new Promise(function(resolve) {
+ var frame = document.createElement('iframe');
+ frame.sandbox = sandbox;
+ frame.src = url;
+ frame.onload = function() { resolve(frame); };
+ document.body.appendChild(frame);
+ });
+}
+
+window.onmessage = function (e) {
+ var id = e.data['id'];
+ fetch(location.href + "_fetch", {mode: 'no-cors'})
+ .then(function() {
+ return with_iframe(location.href + "_iframe");
+ })
+ .then(function() {
+ return with_sandboxed_iframe(location.href + "_script",
+ "allow-scripts");
+ })
+ .then(function() {
+ return with_sandboxed_iframe(location.href + "_script-origin",
+ "allow-scripts allow-same-origin");
+ })
+ .then(function() {
+ window.top.postMessage({id: id, result: 'done'}, '*');
+ })
+ .catch(function(e) {
+ window.top.postMessage({id: id, result: 'error: ' + e.toString()}, '*');
+ });
+};
+</script>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/sandboxed-iframe-fetch-event-worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698