Backed out 2 changesets (bug 1156659) for causing multiple dt failures on browser_jst...
[gecko.git] / netwerk / test / mochitests / test_1425031.html
blob54865501c864ddb53755027204c100737b75397b
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1425031
5 -->
6 <head>
7 <title>Cookies set in content processes update immediately.</title>
8 <script src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1425031">Mozilla Bug 1425031</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
15 <script type="application/javascript">
17 // Verify that cookie operations initiated by content processes do not cause
18 // asynchronous updates for those operations to be processed later.
20 SimpleTest.waitForExplicitFinish();
22 var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('file_1331680.js'));
23 var testsNum = 0;
24 var cookieString = "cookie0=test";
25 let {COOKIE_ADDED, COOKIE_DELETED} = SpecialPowers.Ci.nsICookieNotification;
27 // Confirm the notify which represents the cookie is updating.
28 function confirmCookieOperation(op) {
29 testsNum++;
30 switch(testsNum) {
31 case 1:
32 is(op, COOKIE_ADDED, "Confirm the cookie operation is added.");
33 is(document.cookie, cookieString, "Confirm the cookie string is unaffected by the addition");
34 break;
35 case 2:
36 is(op, COOKIE_DELETED, "Confirm the cookie operation is deleted.");
37 is(document.cookie, cookieString, "Confirm the cookie string is unaffected by the deletion");
38 break;
39 case 3:
40 is(op, COOKIE_ADDED, "Confirm the cookie operation is added.");
41 is(document.cookie, cookieString, "Confirm the cookie string is unaffected by the second addition.");
42 document.cookie = "cookie0=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
43 gScript.sendAsyncMessage('removeObserver');
44 SpecialPowers.clearUserPref("network.cookie.sameSite.laxByDefault");
45 SimpleTest.finish();
46 break;
50 function testSetCookie() {
51 document.cookie = cookieString;
52 is(document.cookie, cookieString, "Confirm cookie string.");
53 document.cookie = "cookie0=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
54 is(document.cookie, "", "Removed all cookies.");
55 document.cookie = cookieString;
56 is(document.cookie, cookieString, "Confirm cookie string.");
59 // Bug 1617611: Fix all the tests broken by "cookies SameSite=lax by default"
60 SpecialPowers.pushPrefEnv({
61 set: [["network.cookie.sameSite.laxByDefault", false]],
62 }, () => {
63 gScript.addMessageListener("cookieOperation", confirmCookieOperation);
64 gScript.addMessageListener("createObserver:return", testSetCookie);
65 gScript.sendAsyncMessage('createObserver');
66 });
68 </script>
70 </div>
71 <pre id="test">
72 </pre>
73 </body>
74 </html>