browser/base/content/test/general/browser_zbug569342.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 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 var gTab = null;
michael@0 6
michael@0 7 function load(url, cb) {
michael@0 8 gTab = gBrowser.addTab(url);
michael@0 9 gBrowser.addEventListener("load", function (event) {
michael@0 10 if (event.target.location != url)
michael@0 11 return;
michael@0 12
michael@0 13 gBrowser.removeEventListener("load", arguments.callee, true);
michael@0 14 // Trigger onLocationChange by switching tabs.
michael@0 15 gBrowser.selectedTab = gTab;
michael@0 16 cb();
michael@0 17 }, true);
michael@0 18 }
michael@0 19
michael@0 20 function test() {
michael@0 21 waitForExplicitFinish();
michael@0 22
michael@0 23 ok(gFindBar.hidden, "Find bar should not be visible by default");
michael@0 24
michael@0 25 // Open the Find bar before we navigate to pages that shouldn't have it.
michael@0 26 EventUtils.synthesizeKey("f", { accelKey: true });
michael@0 27 ok(!gFindBar.hidden, "Find bar should be visible");
michael@0 28
michael@0 29 nextTest();
michael@0 30 }
michael@0 31
michael@0 32 let urls = [
michael@0 33 "about:config",
michael@0 34 "about:addons",
michael@0 35 "about:permissions"
michael@0 36 ];
michael@0 37
michael@0 38 function nextTest() {
michael@0 39 let url = urls.shift();
michael@0 40 if (url) {
michael@0 41 testFindDisabled(url, nextTest);
michael@0 42 } else {
michael@0 43 // Make sure the find bar is re-enabled after disabled page is closed.
michael@0 44 testFindEnabled("about:blank", function () {
michael@0 45 EventUtils.synthesizeKey("VK_ESCAPE", { });
michael@0 46 ok(gFindBar.hidden, "Find bar should now be hidden");
michael@0 47 finish();
michael@0 48 });
michael@0 49 }
michael@0 50 }
michael@0 51
michael@0 52 function testFindDisabled(url, cb) {
michael@0 53 load(url, function() {
michael@0 54 ok(gFindBar.hidden, "Find bar should not be visible");
michael@0 55 EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
michael@0 56 ok(gFindBar.hidden, "Find bar should not be visible");
michael@0 57 EventUtils.synthesizeKey("f", { accelKey: true });
michael@0 58 ok(gFindBar.hidden, "Find bar should not be visible");
michael@0 59 ok(document.getElementById("cmd_find").getAttribute("disabled"),
michael@0 60 "Find command should be disabled");
michael@0 61
michael@0 62 gBrowser.removeTab(gTab);
michael@0 63 cb();
michael@0 64 });
michael@0 65 }
michael@0 66
michael@0 67 function testFindEnabled(url, cb) {
michael@0 68 load(url, function() {
michael@0 69 ok(!document.getElementById("cmd_find").getAttribute("disabled"),
michael@0 70 "Find command should not be disabled");
michael@0 71
michael@0 72 // Open Find bar and then close it.
michael@0 73 EventUtils.synthesizeKey("f", { accelKey: true });
michael@0 74 ok(!gFindBar.hidden, "Find bar should be visible again");
michael@0 75 EventUtils.synthesizeKey("VK_ESCAPE", { });
michael@0 76 ok(gFindBar.hidden, "Find bar should now be hidden");
michael@0 77
michael@0 78 gBrowser.removeTab(gTab);
michael@0 79 cb();
michael@0 80 });
michael@0 81 }

mercurial