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

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: add service_worker_unregister_and_done 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
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..e7afc70ebdebf4c0b17ec7e4957f7be3578b2490
--- /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'}, '*');
+ },
+ function() {
nhiroki 2015/06/26 01:01:36 Why don't you use 'catch'?
horo 2015/06/26 03:59:10 Done.
+ window.top.postMessage({id: id, result: 'error'}, '*');
+ });
+};
+</script>

Powered by Google App Engine
This is Rietveld 408576698