Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for Login Manager</title>
5 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
6 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
7 <script type="text/javascript" src="pwmgr_common.js"></script>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9 </head>
10 <body onload="endTest();">
11 Login Manager test: 221634
12 <p id="display"></p>
13 <div id="content" style="display: none">
15 <form id="form1" action="formtest.js">
16 <input type="text" name="uname">
17 <input type="password" name="pword">
19 <button type="submit">Submit</button>
20 <button type="reset"> Reset</button>
21 </form>
23 <img onload="performTest();" src="mlogosm.gif">
24 </div>
25 <pre id="test">
26 <script class="testbody" type="text/javascript">
28 /** Test for Login Manager: 221634 (password manager needs to fill in forms before the page finishes loading) **/
29 commonInit();
31 var dclHappened = false;
32 var testHappened = false;
33 var pageloadHappened = false;
35 // We're still loading the page, so make sure nothing has filled in yet.
36 is($_(1, "uname").value, "", "Checking unfilled username 1");
37 is($_(1, "pword").value, "", "Checking unfilled password 1");
39 document.addEventListener("DOMContentLoaded", contentLoaded, false);
41 SimpleTest.waitForExplicitFinish();
44 // Step 1 - Fires at DOMContentLoaded
45 function contentLoaded() {
46 ok(!testHappened, "Sanity check to ensure test hasn't happened yet.")
47 ok(!pageloadHappened, "Sanity check to ensure pageload hasn't happened yet.")
49 // We're in DOMContentLoaded, so the pwmgr may or may not have filled in yet.
51 // Set a 0-second timeout, which should execute before the pageload event.
52 // setTimeout(reallyDoTest, 0);
53 // ha-ha... That doesn't work. The pageload event comes first, although
54 // it can be hacked into working by adding <img src="404_non_existent_file.gif">
56 dclHappened = true;
57 }
59 // Step 2 - Fires when the image loads, which should be immediately after DOMContentLoaded (but before pageload)
60 function performTest() {
61 ok(dclHappened, "Sanity check to make sure DOMContentLoaded already happened");
62 ok(!pageloadHappened, "Sanity check to ensure pageload hasn't happened yet.")
64 // Check form1
65 is($_(1, "uname").value, "testuser", "Checking filled username");
66 is($_(1, "pword").value, "testpass", "Checking filled password");
68 testHappened = true;
69 }
71 // Step 3 - Fired by |body| onload.
72 function endTest() {
73 ok(dclHappened, "Sanity check to make sure DOMContentLoaded already happened");
74 ok(testHappened, "Sanity check to make sure our test ran before pageload");
76 // Check form1
77 is($_(1, "uname").value, "testuser", "Rechecking filled username");
78 is($_(1, "pword").value, "testpass", "Rechecking filled password");
80 pageloadHappened = true;
82 // Make sure the expected number of tests (for this page) have run.
83 // If the event execution gets out of order, only a subset get counted.
84 // (Although there should still be other failures... Belt-n-suspenders!)
85 is(SimpleTest._tests.length, 12, "expected number of executed tests");
87 SimpleTest.finish();
88 }
90 </script>
92 </pre>
93 </body>
94 </html>