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