test_bug1171215.html (2000B)
1 <!DOCTYPE html> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1022869 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1022869</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="text/javascript"> 12 13 SimpleTest.waitForExplicitFinish(); 14 15 /** Test for Bug 1022869 */ 16 async function startTest() { 17 // Bug 1746646: Make mochitests work with TCP enabled (cookieBehavior = 5) 18 // Acquire storage access permission here so that the storage used to 19 // hold cookies with the opened windows works in xorigin tests. Otherwise, 20 // the iframe containing this page is isolated from first-party storage 21 // access, which denies access to the same cookie store 22 if (isXOrigin) { 23 SpecialPowers.wrap(document).notifyUserGestureActivation(); 24 await SpecialPowers.addPermission( 25 "storageAccessAPI", 26 true, 27 window.location.href 28 ); 29 await SpecialPowers.wrap(document).requestStorageAccess(); 30 } 31 // Initialize our cookie. 32 document.cookie = "a=b"; 33 34 let w = window.open("window_bug1171215.html"); 35 onmessage = e => { 36 if (e.data.type == "finish") { 37 w.close(); 38 SpecialPowers.clearUserPref("network.cookie.sameSite.laxByDefault"); 39 SimpleTest.finish(); 40 return; 41 } 42 43 if (e.data.type == "info") { 44 info(e.data.msg); 45 return; 46 } 47 48 if (e.data.type == "test") { 49 ok(e.data.test, e.data.msg); 50 return; 51 } 52 53 ok(false, "Unknown message"); 54 }; 55 } 56 57 // Bug 1617611: Fix all the tests broken by "cookies SameSite=lax by default" 58 SpecialPowers.pushPrefEnv({ set: [["network.cookie.cookieBehavior", 1], ["network.cookie.sameSite.laxByDefault", false]] }) 59 .then(startTest); 60 61 </script> 62 </head> 63 <body> 64 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1022869">Mozilla Bug 1022869</a> 65 </body> 66 </html>