frameStoragePrevented.html (1248B)
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 <title>frame for storage prevented test</title> 4 5 <script type="text/javascript" src="https://example.com/tests/dom/tests/mochitest/general/storagePermissionsUtils.js"></script> 6 <script type="text/javascript"> 7 8 task(async function() { 9 // We shouldn't be able to access storage 10 await storagePrevented(); 11 12 // This hash of the URI is set to #nullprincipal by the test if the current page has a null principal, 13 // and thus attempting to create a dedicated worker will throw 14 if (location.hash == "#nullprincipal") { 15 function createWorker() { 16 return new Promise((resolve, reject) => { 17 var w; 18 try { 19 w = new Worker("workerStoragePrevented.js#outer"); 20 } catch (e) { 21 ok(true, "Running workers was prevented"); 22 resolve(); 23 } 24 25 w.onerror = function() { 26 ok(true, "Running workers was prevented"); 27 resolve(); 28 } 29 }); 30 } 31 32 await createWorker(); 33 return; 34 } 35 36 // Try to run a worker, which shouldn't be able to access storage 37 await runWorker("workerStoragePrevented.js#outer"); 38 }); 39 40 </script> 41 42 </head> 43 44 <body> 45 </body> 46 </html>