test_cookieBlock.html (1286B)
1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 <head> 3 <title>cookie blocking test</title> 4 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 8 <script type="text/javascript"> 9 10 function startTest() 11 { 12 // Let's use a new window to have the cookie permission applied. 13 let w = window.open("windowProxy.html"); 14 w.onload = _ => { 15 try { 16 w.localStorage.setItem("blocked", "blockedvalue"); 17 ok(false, "Exception for localStorage.setItem, ACCESS_DENY"); 18 } 19 catch (ex) { 20 ok(true, "Exception for localStorage.setItem, ACCESS_DENY"); 21 } 22 23 try { 24 w.localStorage.getItem("blocked"); 25 ok(false, "Exception for localStorage.getItem, ACCESS_DENY"); 26 } 27 catch (ex) { 28 ok(true, "Exception for localStorage.getItem, ACCESS_DENY"); 29 } 30 31 w.close(); 32 SpecialPowers.popPermissions(() => { 33 SimpleTest.finish(); 34 }); 35 } 36 } 37 38 SimpleTest.waitForExplicitFinish(); 39 40 // Initialize storage before setting the cookie, otherwise we won't be testing 41 // the checks in setItem/getItem methods. 42 var storage = localStorage; 43 44 SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': false, 'context': document}], startTest); 45 46 </script> 47 48 </head> 49 50 <body> 51 52 </body> 53 </html>