browser/base/content/test/general/browser_popupUI.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 function test() {
     2   waitForExplicitFinish();
     3   gPrefService.setBoolPref("dom.disable_open_during_load", false);
     5   var browser = gBrowser.selectedBrowser;
     6   browser.addEventListener("load", function () {
     7     browser.removeEventListener("load", arguments.callee, true);
     9     if (gPrefService.prefHasUserValue("dom.disable_open_during_load"))
    10       gPrefService.clearUserPref("dom.disable_open_during_load");
    12     findPopup();
    13   }, true);
    15   content.location =
    16     "data:text/html,<html><script>popup=open('about:blank','','width=300,height=200')</script>";
    17 }
    19 function findPopup() {
    20   var enumerator = Services.wm.getEnumerator("navigator:browser");
    22   while (enumerator.hasMoreElements()) {
    23     let win = enumerator.getNext();
    24     if (win.content.wrappedJSObject == content.wrappedJSObject.popup) {
    25       testPopupUI(win);
    26       return;
    27     }
    28   }
    30   throw "couldn't find the popup";
    31 }
    33 function testPopupUI(win) {
    34   var doc = win.document;
    36   ok(win.gURLBar, "location bar exists in the popup");
    37   isnot(win.gURLBar.clientWidth, 0, "location bar is visible in the popup");
    38   ok(win.gURLBar.readOnly, "location bar is read-only in the popup");
    39   isnot(doc.getElementById("Browser:OpenLocation").getAttribute("disabled"), "true",
    40      "'open location' command is not disabled in the popup");
    42   let historyButton = doc.getAnonymousElementByAttribute(win.gURLBar, "anonid",
    43                                                          "historydropmarker");
    44   is(historyButton.clientWidth, 0, "history dropdown button is hidden in the popup");
    46   EventUtils.synthesizeKey("t", { accelKey: true }, win);
    47   is(win.gBrowser.browsers.length, 1, "Accel+T doesn't open a new tab in the popup");
    49   EventUtils.synthesizeKey("w", { accelKey: true }, win);
    50   ok(win.closed, "Accel+W closes the popup");
    52   if (!win.closed)
    53     win.close();
    54   gBrowser.addTab();
    55   gBrowser.removeCurrentTab();
    56   finish();
    57 }

mercurial