OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Accessing navigator.serviceWorker in sandboxed iframe.</title> | 2 <title>Accessing navigator.serviceWorker in sandboxed iframe.</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script src="../resources/test-helpers.js"></script> | 5 <script src="../resources/test-helpers.js"></script> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 | |
9 function with_sandboxed_iframe(url, sandbox) { | |
10 return new Promise(function(resolve) { | |
11 var frame = document.createElement('iframe'); | |
12 frame.sandbox = sandbox; | |
13 frame.src = url; | |
14 frame.onload = function() { resolve(frame); }; | |
15 document.body.appendChild(frame); | |
16 }); | |
17 } | |
18 | |
19 var lastCallbackId = 0; | 8 var lastCallbackId = 0; |
20 var callbacks = {}; | 9 var callbacks = {}; |
21 function postMassageAndWaitResult(frame) { | 10 function postMassageAndWaitResult(frame) { |
22 return new Promise(function(resolve) { | 11 return new Promise(function(resolve) { |
23 var id = ++lastCallbackId; | 12 var id = ++lastCallbackId; |
24 callbacks[id] = resolve; | 13 callbacks[id] = resolve; |
25 frame.contentWindow.postMessage({id:id}, '*'); | 14 frame.contentWindow.postMessage({id:id}, '*'); |
26 }); | 15 }); |
27 } | 16 } |
28 | 17 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 frame.remove(); | 67 frame.remove(); |
79 assert_equals(result, 'ok'); | 68 assert_equals(result, 'ok'); |
80 t.done(); | 69 t.done(); |
81 }); | 70 }); |
82 }, | 71 }, |
83 'Accessing navigator.serviceWorker in sandboxed iframe with ' + | 72 'Accessing navigator.serviceWorker in sandboxed iframe with ' + |
84 'allow-same-origin flag should not throw.'); | 73 'allow-same-origin flag should not throw.'); |
85 | 74 |
86 </script> | 75 </script> |
87 </body> | 76 </body> |
OLD | NEW |