test_navigationPreload_disable_crash.html (1847B)
1 <!-- 2 Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ 4 --> 5 <!DOCTYPE HTML> 6 <html> 7 <head> 8 <title>Failure to create a Promise shouldn't crash</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 </div> 16 <pre id="test"></pre> 17 <script class="testbody" type="text/javascript"> 18 async function runTest() { 19 const iframe = document.createElement('iframe'); 20 document.getElementById("content").appendChild(iframe); 21 22 const serviceWorker = iframe.contentWindow.navigator.serviceWorker; 23 const worker = await iframe.contentWindow.navigator.serviceWorker.register("empty.js", {}); 24 25 iframe.remove(); 26 27 // We can't wait for this promise to settle, because the global's 28 // browsing context has been discarded when the iframe was removed. 29 // We're just checking if this call crashes, which would happen 30 // immediately, so ignoring the promise should be fine. 31 worker.navigationPreload.disable(); 32 ok(true, "navigationPreload.disable() failed but didn't crash."); 33 34 SimpleTest.finish(); 35 } 36 37 SimpleTest.waitForExplicitFinish(); 38 // We can't call unregister on the worker after its browsing context has been 39 // discarded, so use SpecialPowers.removeAllServiceWorkerData. 40 SimpleTest.registerCleanupFunction(() => SpecialPowers.removeAllServiceWorkerData()); 41 onload = function() { 42 SpecialPowers.pushPrefEnv({"set": [ 43 ["dom.serviceWorkers.exemptFromPerDomainMax", true], 44 ["dom.serviceWorkers.enabled", true], 45 ["dom.serviceWorkers.navigationPreload.enabled", true], 46 ["dom.serviceWorkers.testing.enabled", true], 47 ]}, runTest); 48 }; 49 </script> 50 </pre> 51 </body> 52 </html>