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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_popupUI.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +function test() {
     1.5 +  waitForExplicitFinish();
     1.6 +  gPrefService.setBoolPref("dom.disable_open_during_load", false);
     1.7 +
     1.8 +  var browser = gBrowser.selectedBrowser;
     1.9 +  browser.addEventListener("load", function () {
    1.10 +    browser.removeEventListener("load", arguments.callee, true);
    1.11 +
    1.12 +    if (gPrefService.prefHasUserValue("dom.disable_open_during_load"))
    1.13 +      gPrefService.clearUserPref("dom.disable_open_during_load");
    1.14 +
    1.15 +    findPopup();
    1.16 +  }, true);
    1.17 +
    1.18 +  content.location =
    1.19 +    "data:text/html,<html><script>popup=open('about:blank','','width=300,height=200')</script>";
    1.20 +}
    1.21 +
    1.22 +function findPopup() {
    1.23 +  var enumerator = Services.wm.getEnumerator("navigator:browser");
    1.24 +
    1.25 +  while (enumerator.hasMoreElements()) {
    1.26 +    let win = enumerator.getNext();
    1.27 +    if (win.content.wrappedJSObject == content.wrappedJSObject.popup) {
    1.28 +      testPopupUI(win);
    1.29 +      return;
    1.30 +    }
    1.31 +  }
    1.32 +
    1.33 +  throw "couldn't find the popup";
    1.34 +}
    1.35 +
    1.36 +function testPopupUI(win) {
    1.37 +  var doc = win.document;
    1.38 +
    1.39 +  ok(win.gURLBar, "location bar exists in the popup");
    1.40 +  isnot(win.gURLBar.clientWidth, 0, "location bar is visible in the popup");
    1.41 +  ok(win.gURLBar.readOnly, "location bar is read-only in the popup");
    1.42 +  isnot(doc.getElementById("Browser:OpenLocation").getAttribute("disabled"), "true",
    1.43 +     "'open location' command is not disabled in the popup");
    1.44 +
    1.45 +  let historyButton = doc.getAnonymousElementByAttribute(win.gURLBar, "anonid",
    1.46 +                                                         "historydropmarker");
    1.47 +  is(historyButton.clientWidth, 0, "history dropdown button is hidden in the popup");
    1.48 +
    1.49 +  EventUtils.synthesizeKey("t", { accelKey: true }, win);
    1.50 +  is(win.gBrowser.browsers.length, 1, "Accel+T doesn't open a new tab in the popup");
    1.51 +
    1.52 +  EventUtils.synthesizeKey("w", { accelKey: true }, win);
    1.53 +  ok(win.closed, "Accel+W closes the popup");
    1.54 +
    1.55 +  if (!win.closed)
    1.56 +    win.close();
    1.57 +  gBrowser.addTab();
    1.58 +  gBrowser.removeCurrentTab();
    1.59 +  finish();
    1.60 +}

mercurial