| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Cache Storage: Verify access in sandboxed iframes</title> | 2 <title>Cache Storage: Verify access in sandboxed iframes</title> |
| 3 <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_
worker/#cache-storage"> | 3 <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_
worker/#cache-storage"> |
| 4 <script src="/resources/testharness.js"></script> | 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> | 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="/resources/testharness-helpers.js"></script> | 6 <script src="/resources/testharness-helpers.js"></script> |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 function load_iframe(src, sandbox) { | 9 function load_iframe(src, sandbox) { |
| 10 return new Promise(function(resolve, reject) { | 10 return new Promise(function(resolve, reject) { |
| 11 var iframe = document.createElement('iframe'); | 11 var iframe = document.createElement('iframe'); |
| 12 iframe.onload = function() { resolve(iframe); }; | 12 iframe.onload = function() { resolve(iframe); }; |
| 13 | 13 |
| 14 iframe.sandbox = sandbox; | 14 iframe.sandbox = sandbox; |
| 15 iframe.src = src; | 15 iframe.src = src; |
| 16 | 16 |
| 17 document.documentElement.appendChild(iframe); | 17 document.documentElement.appendChild(iframe); |
| 18 }); | 18 }); |
| 19 } | 19 } |
| 20 | 20 |
| 21 function wait_for_message(id) { | 21 function wait_for_message(id) { |
| 22 return new Promise(function(resolve) { | 22 return new Promise(function(resolve) { |
| 23 self.addEventListener('message', function listener(e) { | 23 self.addEventListener('message', function listener(e) { |
| 24 if (e.data.id === id) { | 24 if (e.data.id === id) { |
| 25 resolve(e.data); | 25 resolve(e.data); |
| 26 self.removeEventListener(listener); | 26 self.removeEventListener('message', listener); |
| 27 } | 27 } |
| 28 }); | 28 }); |
| 29 }); | 29 }); |
| 30 } | 30 } |
| 31 | 31 |
| 32 var counter = 0; | 32 var counter = 0; |
| 33 | 33 |
| 34 promise_test(function(t) { | 34 promise_test(function(t) { |
| 35 return load_iframe('../resources/iframe.html', | 35 return load_iframe('../resources/iframe.html', |
| 36 'allow-scripts allow-same-origin') | 36 'allow-scripts allow-same-origin') |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 .then(function(message) { | 57 .then(function(message) { |
| 58 assert_equals( | 58 assert_equals( |
| 59 message.result, 'denied', | 59 message.result, 'denied', |
| 60 'Access should be denied if sandbox lacks allow-same-origin'); | 60 'Access should be denied if sandbox lacks allow-same-origin'); |
| 61 assert_equals(message.name, 'SecurityError', | 61 assert_equals(message.name, 'SecurityError', |
| 62 'Failure should be a SecurityError'); | 62 'Failure should be a SecurityError'); |
| 63 }); | 63 }); |
| 64 }, 'Sandboxed iframe without allow-same-origin is denied access'); | 64 }, 'Sandboxed iframe without allow-same-origin is denied access'); |
| 65 | 65 |
| 66 </script> | 66 </script> |
| OLD | NEW |