toolkit/components/passwordmgr/test/test_bug_221634.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial