toolkit/content/tests/chrome/test_popup_preventdefault.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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="Popup Prevent Default Tests"
michael@0 6 onload="setTimeout(runTest, 0);"
michael@0 7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 8
michael@0 9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10
michael@0 11 <!--
michael@0 12 This tests checks that preventDefault can be called on a popupshowing
michael@0 13 event and that preventDefault has no effect for the popuphiding event.
michael@0 14 -->
michael@0 15
michael@0 16 <script>
michael@0 17 SimpleTest.waitForExplicitFinish();
michael@0 18
michael@0 19 var gBlockShowing = true;
michael@0 20 var gShownNotAllowed = true;
michael@0 21
michael@0 22 function runTest()
michael@0 23 {
michael@0 24 document.getElementById("menu").open = true;
michael@0 25 }
michael@0 26
michael@0 27 function popupShowing(event)
michael@0 28 {
michael@0 29 if (gBlockShowing) {
michael@0 30 event.preventDefault();
michael@0 31 gBlockShowing = false;
michael@0 32 setTimeout(function() {
michael@0 33 gShownNotAllowed = false;
michael@0 34 document.getElementById("menu").open = true;
michael@0 35 }, 3000, true);
michael@0 36 }
michael@0 37 }
michael@0 38
michael@0 39 function popupShown()
michael@0 40 {
michael@0 41 ok(!gShownNotAllowed, "popupshowing preventDefault");
michael@0 42 document.getElementById("menu").open = false;
michael@0 43 }
michael@0 44
michael@0 45 function popupHiding(event)
michael@0 46 {
michael@0 47 // since this is a content test, preventDefault should have no effect
michael@0 48 event.preventDefault();
michael@0 49 }
michael@0 50
michael@0 51 function popupHidden()
michael@0 52 {
michael@0 53 ok(true, "popuphiding preventDefault not allowed");
michael@0 54 SimpleTest.finish();
michael@0 55 }
michael@0 56 </script>
michael@0 57
michael@0 58 <button id="menu" type="menu" label="Menu">
michael@0 59 <menupopup onpopupshowing="popupShowing(event);"
michael@0 60 onpopupshown="popupShown();"
michael@0 61 onpopuphiding="popupHiding(event);"
michael@0 62 onpopuphidden="popupHidden();">
michael@0 63 <menuitem label="Item"/>
michael@0 64 </menupopup>
michael@0 65 </button>
michael@0 66
michael@0 67 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 68 <p id="display">
michael@0 69 </p>
michael@0 70 <div id="content" style="display: none">
michael@0 71 </div>
michael@0 72 <pre id="test">
michael@0 73 </pre>
michael@0 74 </body>
michael@0 75
michael@0 76 </window>

mercurial