OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="/resources/testharness.js"></script> |
| 3 <script src="/resources/testharnessreport.js"></script> |
| 4 <script src="resources/test-helpers.sub.js"></script> |
| 5 <title>Service worker registration from within sandboxed iframe</title> |
| 6 <body> |
| 7 <script> |
| 8 'use strict'; |
| 9 function waitForMsg(id) { |
| 10 return new Promise(function(resolve) { |
| 11 window.addEventListener('message', function onMessage(event) { |
| 12 if (!event.data || event.data.id !== id) { |
| 13 return; |
| 14 } |
| 15 window.removeEventListener('message', onMessage); |
| 16 resolve(event.data.result); |
| 17 }); |
| 18 }); |
| 19 } |
| 20 |
| 21 promise_test(function(t) { |
| 22 var iframe = document.createElement('iframe'); |
| 23 iframe.setAttribute('src', 'resources/iframe-register-link-element.html?subt
est1'); |
| 24 iframe.setAttribute('sandbox', 'allow-scripts'); |
| 25 |
| 26 document.body.appendChild(iframe); |
| 27 t.add_cleanup(function() { |
| 28 iframe.remove(); |
| 29 }); |
| 30 |
| 31 return waitForMsg('?subtest1') |
| 32 .then(function(data) { |
| 33 assert_equals(data, 'error'); |
| 34 }); |
| 35 }, 'registration via <link> element `rel` rejected'); |
| 36 |
| 37 promise_test(function(t) { |
| 38 var iframe = document.createElement('iframe'); |
| 39 iframe.setAttribute('src', 'resources/iframe-register-link-element.html?subt
est2'); |
| 40 iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin'); |
| 41 |
| 42 document.body.appendChild(iframe); |
| 43 t.add_cleanup(function() { |
| 44 iframe.remove(); |
| 45 }); |
| 46 |
| 47 return waitForMsg('?subtest2') |
| 48 .then(function(data) { |
| 49 assert_equals(data, 'loaded'); |
| 50 }); |
| 51 }, 'registration via <link> element `rel` accepted in presence of `allow-same-
origin` directive'); |
| 52 </script> |
| 53 </body> |
OLD | NEW |