OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: check referer of fetch() with Referrer Policy</title> |
| 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <script src="/common/get-host-info.sub.js"></script> |
| 6 <script src="resources/test-helpers.sub.js"></script> |
| 7 <script> |
| 8 promise_test(function(t) { |
| 9 var SCOPE = 'resources/referrer-policy-iframe.html'; |
| 10 var SCRIPT = 'resources/fetch-rewrite-worker-referrer-policy.js'; |
| 11 var host_info = get_host_info(); |
| 12 var body, unregister; |
| 13 |
| 14 body = service_worker_unregister_and_register(t, SCRIPT, SCOPE) |
| 15 .then(function(registration) { |
| 16 unregister = registration.unregister.bind(registration); |
| 17 return wait_for_state(t, registration.installing, 'activated'); |
| 18 }) |
| 19 .then(function() { return with_iframe(SCOPE); }) |
| 20 .then(function(frame) { |
| 21 var channel = new MessageChannel(); |
| 22 t.add_cleanup(function() { |
| 23 frame.remove(); |
| 24 }); |
| 25 |
| 26 return new Promise(function(resolve) { |
| 27 channel.port1.onmessage = resolve; |
| 28 frame.contentWindow.postMessage({}, |
| 29 host_info['HTTPS_ORIGIN'], |
| 30 [channel.port2]); |
| 31 }); |
| 32 }) |
| 33 .then(function(e) { |
| 34 assert_equals(e.data.results, 'finish'); |
| 35 }); |
| 36 |
| 37 // Schedule un-registration to occur after test execution has completed, |
| 38 // without hiding test failure. |
| 39 return body |
| 40 .then(unregister, unregister) |
| 41 .then(function() { return body; }); |
| 42 }, 'Verify the referer with a Referrer Policy'); |
| 43 </script> |
OLD | NEW |