dom/tests/mochitest/chrome/window_focus_docnav.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 href="chrome://global/skin" type="text/css"?>
     4 <window onload="start()"
     5         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     7 <script type="application/javascript"
     8         src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    10 <textbox id="textbox"/>
    12 <panel id="panel2" onpopupshown="runTests(this, 2);" onpopuphidden="document.getElementById('panel').hidePopup()">
    13   <textbox id="p2textbox" value="Popup2"/>
    14 </panel>
    15 <panel id="panel" onpopupshown="runTests(this, 1);"
    16                   onpopuphidden="done()">
    17   <textbox id="p1textbox" value="Popup1"/>
    18 </panel>
    20 <browser id="browser" type="content" src="focus_frameset.html" width="500" height="400"/>
    22 <script type="application/javascript">
    23 <![CDATA[
    25 var fm = Components.classes["@mozilla.org/focus-manager;1"].
    26            getService(Components.interfaces.nsIFocusManager);
    28 function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
    29 function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
    31 function done()
    32 {
    33   var opener = window.opener;
    34   window.close();
    35   opener.wrappedJSObject.SimpleTest.finish();
    36 }
    38 function previous(expectedWindow, expectedElement, desc)
    39 {
    40   synthesizeKey("VK_F6", { shiftKey: true });
    41   is(fm.focusedWindow, expectedWindow, desc);
    42   is(fm.focusedElement, expectedElement, desc + " element");
    43 }
    45 function next(expectedWindow, expectedElement, desc)
    46 {
    47   synthesizeKey("VK_F6", { });
    48   is(fm.focusedWindow, expectedWindow, desc);
    49   is(fm.focusedElement, expectedElement, desc + " element" + "::" + (fm.focusedElement ? fm.focusedElement.parentNode.id : "<none>"));
    50 }
    52 // This test runs through three cases. Document navigation forward and
    53 // backward using the F6 key when no popups are open, with one popup open and
    54 // with two popups open.
    55 function runTests(panel, popupCount)
    56 {
    57   if (!popupCount || popupCount > 2)
    58     popupCount = 0;
    60   fm.clearFocus(window);
    62   var childwin = document.getElementById("browser").contentWindow;
    64   if (popupCount) {
    65     if (popupCount == 2) {
    66       next(window, document.getElementById("p2textbox").inputField, "First into popup 2 with " + popupCount);
    67     }
    69     next(window, document.getElementById("p1textbox").inputField, "First into popup 1 with " + popupCount);
    70   }
    72   next(childwin.frames[0], childwin.frames[0].document.documentElement, "First with " + popupCount);
    73   next(childwin.frames[1], childwin.frames[1].document.documentElement, "Second with " + popupCount);
    74   previous(childwin.frames[0], childwin.frames[0].document.documentElement, "Second back with " + popupCount);
    76   if (popupCount) {
    77     previous(window, document.getElementById("p1textbox").inputField, "First back from popup 1 with " + popupCount);
    79     if (popupCount == 2) {
    80       previous(window, document.getElementById("p2textbox").inputField, "First back from popup 2 with " + popupCount);
    81     }
    82   }
    84   previous(window, document.getElementById("textbox").inputField, "First back with " + popupCount);
    86   if (panel == document.getElementById("panel"))
    87     document.getElementById("panel2").openPopup(null, "after_start", 100, 20);
    88   else if (panel == document.getElementById("panel2"))
    89     panel.hidePopup();
    90   else
    91     document.getElementById("panel").openPopup(null, "after_start");
    92 }
    94 function start()
    95 {
    96   window.opener.wrappedJSObject.SimpleTest.waitForExplicitFinish();
    97   window.opener.wrappedJSObject.SimpleTest.waitForFocus(
    98     function() { runTests(null, 0); },
    99     document.getElementById("browser").contentWindow);
   100 }
   102 ]]></script>
   104 </window>

mercurial