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=484181
5 -->
6 <head>
7 <title>Test for Bug 484181</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=484181">Mozilla Bug 484181</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 <script type="application/javascript">
21 /** Test for Bug 484181 **/
23 SimpleTest.waitForExplicitFinish();
24 addLoadEvent(runTest);
26 var gMisspeltWords;
28 function getEditor() {
29 var Ci = SpecialPowers.Ci;
30 var win = window;
31 var editingSession = SpecialPowers.wrap(win).QueryInterface(Ci.nsIInterfaceRequestor)
32 .getInterface(Ci.nsIWebNavigation)
33 .QueryInterface(Ci.nsIInterfaceRequestor)
34 .getInterface(Ci.nsIEditingSession);
35 return editingSession.getEditorForWindow(win);
36 }
38 function getSpellCheckSelection() {
39 var editor = getEditor();
40 var selcon = editor.selectionController;
41 return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
42 }
44 function append(str) {
46 var edit = document.getElementById("edit");
47 var editor = getEditor();
48 var sel = editor.selection;
49 sel.selectAllChildren(edit);
50 sel.collapseToEnd();
52 for (var i = 0; i < str.length; ++i) {
53 synthesizeKey(str[i], {});
54 }
55 }
57 function runTest() {
58 gMisspeltWords = ["haz", "cheezburger"];
59 var edit = document.getElementById("edit");
60 edit.focus();
62 SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", window);
63 onSpellCheck(edit, function () {
64 is(isSpellingCheckOk(), true, "All misspellings before editing are accounted for.");
66 append(" becaz I'm a lolcat!");
67 onSpellCheck(edit, function () {
68 gMisspeltWords.push("becaz");
69 gMisspeltWords.push("lolcat");
70 is(isSpellingCheckOk(), true, "All misspellings after typing are accounted for.");
72 SimpleTest.finish();
73 });
74 });
75 }
77 function isSpellingCheckOk() {
79 var sel = getSpellCheckSelection();
80 var numWords = sel.rangeCount;
82 is(numWords, gMisspeltWords.length, "Correct number of misspellings and words.");
84 if (numWords != gMisspeltWords.length)
85 return false;
87 for (var i=0; i<numWords; i++) {
88 var word = sel.getRangeAt(i);
89 is (word, gMisspeltWords[i], "Misspelling is what we think it is.");
90 if (word != gMisspeltWords[i])
91 return false;
92 }
93 return true;
94 }
96 </script>
97 </pre>
99 <div><div></div><div id="edit" contenteditable="true">I can haz cheezburger</div></div>
101 </body>
102 </html>