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.

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

mercurial