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 <html>
2 <head>
3 <title>Test for Bug 620145</title>
4 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
7 <script type="text/javascript" src="prompt_common.js"></script>
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9 </head>
10 <body onload="runtest()">
11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=620145">Mozilla Bug 620145</a>
12 <pre id="test">
13 </pre>
15 <div id="text" style="max-width: 100px" onmouseup="openAlert()">
16 This is a short piece of text used for testing that mouse selecting is
17 stopped when an alert appears.
18 </div>
19 <div id="text2" style="max-width: 100px">
20 This is another short piece of text used for testing that mouse selecting is
21 stopped when an alert appears.
22 </div>
23 <button id="button" onmouseup="openAlert()">Button</button>
25 <script class="testbody" type="text/javascript">
26 SimpleTest.waitForExplicitFinish();
28 var selectionTest = false;
29 var testNum = 0;
31 function hasTabModalPrompts() {
32 var prefName = "prompts.tab_modal.enabled";
33 var Services = SpecialPowers.Cu
34 .import("resource://gre/modules/Services.jsm")
35 .Services;
36 return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL &&
37 Services.prefs.getBoolPref(prefName);
38 }
40 function openAlert() {
41 ok(true, "opening alert...");
42 alert("hello!");
43 ok(true, "...alert done.");
44 }
46 function runtest()
47 {
48 // The <button> in this test's HTML opens a prompt when clicked.
49 // Here we send the events to simulate clicking it.
50 ok(true, "starting test");
51 isTabModal = hasTabModalPrompts();
52 if (!isTabModal)
53 todo(false, "Test is run with tab modal prompts disabled.");
54 else
55 ok(true, "Test is run with tab modal prompts enabled.");
56 startCallbackTimer();
58 var button = $("button");
59 dispatchMouseEvent(button, "mousedown");
60 dispatchMouseEvent(button, "mouseup");
62 selectionTest = isTabModal;
64 startCallbackTimer();
66 var text = $("text");
67 dispatchMouseEvent(text, "mousedown");
68 dispatchMouseEvent(text, "mouseup");
70 SimpleTest.finish();
71 }
73 function dispatchMouseEvent(target, type)
74 {
75 var win = target.ownerDocument.defaultView;
76 e = document.createEvent("MouseEvent");
77 e.initEvent(type, false, false, win, 0, 1, 1, 1, 1,
78 false, false, false, false, 0, null);
79 var utils = SpecialPowers.getDOMWindowUtils(win);
80 utils.dispatchDOMEventViaPresShell(target, e, true);
81 ok(true, type + " sent to " + target.id);
82 }
84 function handleDialog(ui, testNum)
85 {
86 if (!selectionTest) {
87 todo(false, "Selection test is disabled when tab modal prompts are not enabled.");
88 } else {
89 synthesizeMouse($("text"), 25, 55, { type: "mousemove" });
90 is(window.getSelection().toString(), "", "selection not made");
91 }
93 ok(true, "handleDialog sending mouseclick to dialog...");
94 synthesizeMouse(ui.button0, 5, 5, { }, SpecialPowers.unwrap(ui.button0.ownerDocument.defaultView));
95 }
96 </script>
98 </body>
99 </html>