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 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 4 | |
michael@0 | 5 | <window title="Blinking Context Menu Item Tests" |
michael@0 | 6 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 10 | |
michael@0 | 11 | <menulist id="menulist"> |
michael@0 | 12 | <menupopup id="menupopup"> |
michael@0 | 13 | <menuitem label="Menu Item" id="menuitem"/> |
michael@0 | 14 | </menupopup> |
michael@0 | 15 | </menulist> |
michael@0 | 16 | <script class="testbody" type="application/javascript"> |
michael@0 | 17 | <![CDATA[ |
michael@0 | 18 | |
michael@0 | 19 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 20 | SimpleTest.waitForFocus(startTest); |
michael@0 | 21 | |
michael@0 | 22 | function startTest() { |
michael@0 | 23 | if (!/Mac/.test(navigator.platform)) { |
michael@0 | 24 | ok(true, "Nothing to test on non-Mac."); |
michael@0 | 25 | SimpleTest.finish(); |
michael@0 | 26 | return; |
michael@0 | 27 | } |
michael@0 | 28 | // Destroy frame while removing the _moz-menuactive attribute. |
michael@0 | 29 | test_crash("REMOVAL", test2); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function test2() { |
michael@0 | 33 | // Destroy frame while adding the _moz-menuactive attribute. |
michael@0 | 34 | test_crash("ADDITION", test3); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function test3() { |
michael@0 | 38 | // Don't mess with the frame, just test whether we've blinked. |
michael@0 | 39 | test_crash("", SimpleTest.finish); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | function test_crash(when, andThen) { |
michael@0 | 43 | var menupopup = document.getElementById("menupopup"); |
michael@0 | 44 | var menuitem = document.getElementById("menuitem"); |
michael@0 | 45 | var attrChanges = { "REMOVAL": 0, "ADDITION": 0 }; |
michael@0 | 46 | var storedEvent = null; |
michael@0 | 47 | menupopup.addEventListener("popupshown", function () { |
michael@0 | 48 | menupopup.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 49 | menuitem.addEventListener("mouseup", function (e) { |
michael@0 | 50 | menuitem.removeEventListener("mouseup", arguments.callee, true); |
michael@0 | 51 | menuitem.addEventListener("DOMAttrModified", function (e) { |
michael@0 | 52 | if (e.attrName == "_moz-menuactive") { |
michael@0 | 53 | if (!attrChanges[e.attrChange]) |
michael@0 | 54 | attrChanges[e.attrChange] = 1; |
michael@0 | 55 | else |
michael@0 | 56 | attrChanges[e.attrChange]++; |
michael@0 | 57 | storedEvent = e; |
michael@0 | 58 | if (e.attrChange == e[when]) { |
michael@0 | 59 | menuitem.hidden = true; |
michael@0 | 60 | menuitem.getBoundingClientRect(); |
michael@0 | 61 | ok(true, "Didn't crash on _moz-menuactive " + when.toLowerCase() + " during blinking") |
michael@0 | 62 | menuitem.hidden = false; |
michael@0 | 63 | menuitem.removeEventListener("DOMAttrModified", arguments.callee, false); |
michael@0 | 64 | SimpleTest.executeSoon(function () { |
michael@0 | 65 | menupopup.hidePopup(); |
michael@0 | 66 | }); |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | }, false); |
michael@0 | 70 | }, true); |
michael@0 | 71 | menupopup.addEventListener("popuphidden", function() { |
michael@0 | 72 | menupopup.removeEventListener("popuphidden", arguments.callee, false); |
michael@0 | 73 | if (!when) { |
michael@0 | 74 | // Test whether we've blinked at all. |
michael@0 | 75 | var shouldBlink = navigator.platform.match(/Mac/); |
michael@0 | 76 | var expectedNumRemoval = shouldBlink ? 2 : 1; |
michael@0 | 77 | var expectedNumAddition = shouldBlink ? 1 : 0; |
michael@0 | 78 | ok(storedEvent, "got DOMAttrModified events after clicking menuitem") |
michael@0 | 79 | is(attrChanges[storedEvent.REMOVAL], expectedNumRemoval, "blinking unset attributes correctly"); |
michael@0 | 80 | is(attrChanges[storedEvent.ADDITION], expectedNumAddition, "blinking set attributes correctly"); |
michael@0 | 81 | } |
michael@0 | 82 | SimpleTest.executeSoon(andThen); |
michael@0 | 83 | }, false); |
michael@0 | 84 | synthesizeMouse(menuitem, 10, 5, { type : "mousemove" }); |
michael@0 | 85 | synthesizeMouse(menuitem, 10, 5, { type : "mousemove" }); |
michael@0 | 86 | synthesizeMouse(menuitem, 10, 5, { type : "mousedown" }); |
michael@0 | 87 | SimpleTest.executeSoon(function () { |
michael@0 | 88 | synthesizeMouse(menuitem, 10, 5, { type : "mouseup" }); |
michael@0 | 89 | }); |
michael@0 | 90 | }, false); |
michael@0 | 91 | document.getElementById("menulist").open = true; |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | ]]> |
michael@0 | 95 | </script> |
michael@0 | 96 | |
michael@0 | 97 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 98 | <p id="display"> |
michael@0 | 99 | </p> |
michael@0 | 100 | <div id="content" style="display: none"> |
michael@0 | 101 | </div> |
michael@0 | 102 | <pre id="test"> |
michael@0 | 103 | </pre> |
michael@0 | 104 | </body> |
michael@0 | 105 | |
michael@0 | 106 | </window> |