cross-origin-serviceworker.tentative.https.sub.html (1253B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Notifications in cross origin iframes</title> 4 <link rel="help" href="https://github.com/whatwg/notifications/issues/177"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="resources/helpers.js"></script> 10 <script> 11 // The syntax below will give us a third party URL. 12 // See: https://web-platform-tests.org/writing-tests/server-features.html 13 const thirdPartyOrigin = 'https://{{hosts[alt][]}}:{{ports[https][0]}}'; 14 const thirdPartyIframe = 15 `${thirdPartyOrigin}/notifications/resources/cross-origin-serviceworker-iframe.sub.html`; 16 let promise; 17 18 promise_setup(async () => { 19 await trySettingPermission("granted"); 20 21 promise = new Promise(r => window.addEventListener("message", ev => { 22 if ("shown" in ev.data) { 23 r(ev.data) 24 } 25 })); 26 27 const iframe = document.createElement("iframe"); 28 iframe.src = thirdPartyIframe; 29 document.body.append(iframe); 30 }) 31 32 promise_test(async t => { 33 const result = await promise; 34 assert_false(result.shown, `notification should not be shown`); 35 }, "third party serviceworker"); 36 </script>