dom/tests/mochitest/chrome/file_bug800817.xul

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     4 <!--
     5 https://bugzilla.mozilla.org/show_bug.cgi?id=800817
     6 -->
     7 <window title="Mozilla Bug 800817"
     8         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     9   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    10   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    12   <!-- test results are displayed in the html:body -->
    13   <body xmlns="http://www.w3.org/1999/xhtml">
    14   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=800817"
    15      target="_blank">Mozilla Bug 800817</a>
    16   </body>
    18   <!-- test code goes here -->
    19   <script type="application/javascript">
    20   <![CDATA[
    21   /** Test for Bug 800817 **/
    23   function sendClick(win) {
    24     var wu = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    25                 .getInterface(Components.interfaces.nsIDOMWindowUtils);
    26     wu.sendMouseEventToWindow("mousedown", 10, 10, 0, 0, 0);
    27     wu.sendMouseEventToWindow("mouseup", 10, 10, 0, 0, 0);
    28   }
    30   function runTests() {
    31     var b1 = document.getElementById("b1");
    32     var b2 = document.getElementById("b2");
    34     var testMozBrowser = opener.wrappedJSObject.testMozBrowser;
    35     if (testMozBrowser) {
    36       b1.setAttribute("mozbrowser", "true");
    37       b2.setAttribute("mozbrowser", "true");
    38     }
    40     if (testMozBrowser)
    41       opener.wrappedJSObject.info("Testing with mozbrowser=true");
    42     else
    43       opener.wrappedJSObject.info("Testing without mozbrowser");
    45     b1.contentWindow.focus();
    46     opener.wrappedJSObject.is(document.activeElement, b1,
    47                               "Focused first iframe");
    49     var didCallDummy = false;
    50     b2.contentWindow.addEventListener("mousedown", function(e) { didCallDummy = true; });
    51     sendClick(b2.contentWindow);
    52     opener.wrappedJSObject.ok(didCallDummy, "dummy mousedown handler should fire");
    53     opener.wrappedJSObject.is(document.activeElement, b2,
    54                               "Focus shifted to second iframe");
    56     b1.contentWindow.focus();
    57     opener.wrappedJSObject.is(document.activeElement, b1,
    58                               "Re-focused first iframe for the first time");
    60     var didCallListener = false;
    61     b2.contentWindow.addEventListener("mousedown", function(e) { didCallListener = true; e.preventDefault(); });
    62     sendClick(b2.contentWindow);
    63     opener.wrappedJSObject.ok(didCallListener, "mousedown handler should fire");
    64     opener.wrappedJSObject.is(document.activeElement, b1,
    65                               "Did not move focus to the second iframe");
    67     window.close();
    68     opener.wrappedJSObject.finishedTests();
    69   }
    71   SimpleTest.waitForFocus(runTests);
    72   ]]>
    73   </script>
    74   <iframe xmlns="http://www.w3.org/1999/xhtml"
    75           id="b1" type="content" src="about:blank"
    76           style="width: 300px; height: 550px; border: 1px solid black;"/>
    77   <iframe xmlns="http://www.w3.org/1999/xhtml"
    78           id="b2" type="content" src="about:blank"
    79           style="width: 300px; height: 550px; border: 1px solid black;"/>
    80 </window>

mercurial