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"?>
5 <window title="Open panel from menuitem"
6 onload="setTimeout(runTests, 0);"
7 xmlns:html="http://www.w3.org/1999/xhtml"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
13 <!--
14 This test does the following:
15 1. Opens the menu, causing the popupshown event to fire, which will call menuOpened.
16 2. Keyboard events are fired to cause the first item on the menu to be executed.
17 3. The command event handler for the first menuitem opens the panel.
18 4. As a menuitem was executed, the menu will roll up, hiding it.
19 5. The popuphidden event for the menu calls menuClosed which tests the popup states.
20 6. The panelOpened function tests the popup states again and hides the popup.
21 7. Once the panel's popuphidden event fires, tests are performed to see if
22 panels inside buttons and toolbarbuttons work. Each is opened and the closed.
23 -->
25 <menu id="menu" onpopupshown="menuOpened()" onpopuphidden="menuClosed();">
26 <menupopup>
27 <menuitem id="i1" label="One" oncommand="$('panel').openPopup($('menu'), 'after_start');"/>
28 <menuitem id="i2" label="Two"/>
29 </menupopup>
30 </menu>
32 <panel id="hiddenpanel" hidden="true"/>
34 <panel id="panel" onpopupshown="panelOpened()"
35 onpopuphidden="$('button').focus(); $('button').open = true">
36 <textbox/>
37 </panel>
39 <button id="button" type="panel" label="Button">
40 <panel onpopupshown="panelOnButtonOpened(this)"
41 onpopuphidden="$('tbutton').open = true;">
42 <button label="OK" oncommand="this.parentNode.parentNode.open = false"/>
43 </panel>
44 </button>
46 <toolbarbutton id="tbutton" type="panel" label="Toolbarbutton">
47 <panel onpopupshown="panelOnToolbarbuttonOpened(this)"
48 onpopuphidden="SimpleTest.finish()">
49 <textbox/>
50 </panel>
51 </toolbarbutton>
53 <script class="testbody" type="application/javascript">
54 <![CDATA[
56 SimpleTest.waitForExplicitFinish();
58 function runTests()
59 {
60 is($("hiddenpanel").state, "closed", "hidden popup is closed");
62 var menu = $("menu");
63 menu.open = true;
64 }
66 function menuOpened()
67 {
68 synthesizeKey("VK_DOWN", { });
69 synthesizeKey("VK_RETURN", { });
70 }
72 function menuClosed()
73 {
74 // the panel will be open at this point, but the popupshown event
75 // still needs to fire
76 is($("panel").state, "showing", "panel is open after menu hide");
77 is($("menu").firstChild.state, "closed", "menu is closed after menu hide");
78 }
80 function panelOpened()
81 {
82 is($("panel").state, "open", "panel is open");
83 is($("menu").firstChild.state, "closed", "menu is closed");
84 $("panel").hidePopup();
85 }
87 function panelOnButtonOpened(panel)
88 {
89 is(panel.state, 'open', 'button panel is open');
90 is(document.activeElement, document.documentElement, "focus blurred on panel from button open");
91 synthesizeKey("VK_DOWN", { });
92 is(document.activeElement, document.documentElement, "focus not modified on cursor down from button");
93 panel.firstChild.doCommand()
94 }
96 function panelOnToolbarbuttonOpened(panel)
97 {
98 is(panel.state, 'open', 'toolbarbutton panel is open');
99 is(document.activeElement, document.documentElement, "focus blurred on panel from toolbarbutton open");
100 panel.firstChild.focus();
101 synthesizeKey("VK_DOWN", { });
102 is(document.activeElement, panel.firstChild.inputField, "focus not modified on cursor down from toolbarbutton");
103 panel.parentNode.open = false;
104 }
106 ]]>
107 </script>
109 <body xmlns="http://www.w3.org/1999/xhtml">
110 <p id="display">
111 </p>
112 <div id="content" style="display: none">
113 </div>
114 <pre id="test">
115 </pre>
116 </body>
118 </window>