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 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=864040
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 864040</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
11 <script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
13 </head>
14 <body>
15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=864040">Mozilla Bug 864040</a>
16 <div id="display">
17 <textarea id="ta" rows="5" cols="20"></textarea>
18 <div id="ce" contentEditable="true" style="height: 5em;"></div>
19 </div>
20 <div id="content" style="display: none">
21 </div>
22 <pre id="test">
23 <script type="application/javascript">
24 /**
25 * Test for Bug 864040
26 *
27 * We use a selection event to set the selection to the end of an editor
28 * containing an ending newline. Then we test to see that the caret is
29 * actually drawn on the newline.
30 */
32 function testSelectEndOfText(elem) {
33 var tn = elem.tagName;
34 elem.focus();
36 // Enter test string into editor
37 var test_string = 'test\n';
38 sendString(test_string);
40 // Get the caret position after what we entered
41 var result = synthesizeQuerySelectedText();
42 ok(result, tn + ': failed to query selection (1)');
43 var refoffset = result.offset;
45 // Take a snapshot of where the caret is (on the new line)
46 referenceSnapshot = snapshotWindow(window, true /* withCaret */);
47 ok(referenceSnapshot, tn + ': failed to take snapshot (1)');
49 // Set selection to the same spot through a selection event
50 ok(synthesizeSelectionSet(refoffset, 0, false), tn + ': failed to set selection');
52 // Make sure new selection is the same
53 result = synthesizeQuerySelectedText();
54 ok(result, tn + ': failed to query selection (2)');
55 is(result.offset, refoffset, tn + ': caret is not at the right position');
57 // Take a snapshot of where the new caret is (shoud still be on the new line)
58 testSnapshot = snapshotWindow(window, true /* withCaret */);
59 ok(testSnapshot, tn + ': failed to take snapshot (2)');
61 // Compare snapshot (should be the same)
62 result = compareSnapshots(referenceSnapshot, testSnapshot, true /* expected */)
63 ok(result, tn + ': failed to compare snapshots');
64 // result = [correct, s1data, s2data]
65 ok(result[0], tn + ': caret is not on new line');
66 if (!result[0]) {
67 dump('Ref: ' + result[1] + '\n');
68 dump('Res: ' + result[2] + '\n');
69 }
70 }
72 function runTests() {
73 // we don't test regular <input> because this test is about multiline support
74 // test textarea
75 testSelectEndOfText(document.getElementById('ta'));
76 // test contentEditable
77 testSelectEndOfText(document.getElementById('ce'));
78 SimpleTest.finish();
79 }
81 SimpleTest.waitForExplicitFinish();
83 SimpleTest.waitForFocus(runTests);
84 </script>
85 </pre>
86 </body>
87 </html>