Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / chromium / resources / sandboxed-iframe-fetch-event-iframe.html
blobac99a02fae585b85c20e1837d0111cec981eff23
1 <script>
2 function with_iframe(url) {
3 return new Promise(function(resolve) {
4 var frame = document.createElement('iframe');
5 frame.src = url;
6 frame.onload = function() { resolve(frame); };
7 document.body.appendChild(frame);
8 });
11 function with_sandboxed_iframe(url, sandbox) {
12 return new Promise(function(resolve) {
13 var frame = document.createElement('iframe');
14 frame.sandbox = sandbox;
15 frame.src = url;
16 frame.onload = function() { resolve(frame); };
17 document.body.appendChild(frame);
18 });
21 window.onmessage = function (e) {
22 var id = e.data['id'];
23 fetch(location.href + "_fetch", {mode: 'no-cors'})
24 .then(function() {
25 return with_iframe(location.href + "_iframe");
27 .then(function() {
28 return with_sandboxed_iframe(location.href + "_script",
29 "allow-scripts");
31 .then(function() {
32 return with_sandboxed_iframe(location.href + "_script-origin",
33 "allow-scripts allow-same-origin");
35 .then(function() {
36 window.top.postMessage({id: id, result: 'done'}, '*');
38 .catch(function(e) {
39 window.top.postMessage({id: id, result: 'error: ' + e.toString()}, '*');
40 });
42 </script>