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 <?xml version="1.0"?>
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
4 <!--
5 XUL Widget Test for textbox with Add and Undo Add to Dictionary
6 -->
7 <window title="Textbox Add and Undo Add to Dictionary Test" width="500" height="600"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
12 <hbox>
13 <textbox id="t1" value="Hellop" oncontextmenu="runContextMenuTest()" spellcheck="true"/>
14 </hbox>
16 <!-- test results are displayed in the html:body -->
17 <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
19 <!-- test code goes here -->
20 <script type="application/javascript"><![CDATA[
22 SimpleTest.waitForExplicitFinish();
24 var textbox;
25 var testNum;
27 function bringUpContextMenu(element)
28 {
29 synthesizeMouseAtCenter(element, { type: "contextmenu", button: 2});
30 }
32 function leftClickElement(element)
33 {
34 synthesizeMouseAtCenter(element, { button: 0 });
35 }
37 function startTests()
38 {
39 textbox = document.getElementById("t1");
40 textbox.focus();
41 testNum = 0;
43 Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
44 onSpellCheck(textbox, function () {
45 bringUpContextMenu(textbox);
46 });
47 }
49 function runContextMenuTest()
50 {
51 SimpleTest.executeSoon( function() {
52 // The textbox has its children in an hbox XUL element, so get that first
53 var hbox = document.getAnonymousNodes(textbox).item(0);
55 var contextMenu = document.getAnonymousElementByAttribute(hbox, "anonid", "input-box-contextmenu");
57 switch(testNum)
58 {
59 case 0: // "Add to Dictionary" button
60 var addToDict = contextMenu.querySelector("[anonid=spell-add-to-dictionary]");
61 ok(!addToDict.hidden, "Is Add to Dictionary visible?");
63 var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
64 ok(!separator.hidden, "Is separator visible?");
66 addToDict.doCommand();
68 contextMenu.hidePopup();
69 testNum++;
71 onSpellCheck(textbox, function () {
72 bringUpContextMenu(textbox);
73 });
74 break;
76 case 1: // "Undo Add to Dictionary" button
77 var undoAddDict = contextMenu.querySelector("[anonid=spell-undo-add-to-dictionary]");
78 ok(!undoAddDict.hidden, "Is Undo Add to Dictioanry visible?");
80 var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
81 ok(!separator.hidden, "Is separator hidden?");
83 undoAddDict.doCommand();
85 contextMenu.hidePopup();
86 onSpellCheck(textbox, function () {
87 SimpleTest.finish();
88 });
89 break;
90 }
91 });
92 }
94 SimpleTest.waitForFocus(startTests);
96 ]]></script>
98 </window>