diff --git a/browser/metro/base/content/browser-ui.js b/browser/metro/base/content/browser-ui.js
index 42c7079bb1b1..bbb1b3a1ae92 100644
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -83,6 +83,7 @@ var BrowserUI = {
get _forward() { return document.getElementById("cmd_forward"); },
lastKnownGoodURL: "", // used when the user wants to escape unfinished url entry
+ ready: false, // used for tests to determine when delayed initialization is done
init: function() {
// start the debugger now so we can use it on the startup code as well
@@ -134,6 +135,7 @@ var BrowserUI = {
let event = document.createEvent("Events");
event.initEvent("UIReadyDelayed", true, false);
window.dispatchEvent(event);
+ BrowserUI.ready = true;
}, 0);
});
diff --git a/browser/metro/base/content/browser.xul b/browser/metro/base/content/browser.xul
index 41bcf554504b..41c491d378fb 100644
--- a/browser/metro/base/content/browser.xul
+++ b/browser/metro/base/content/browser.xul
@@ -356,7 +356,7 @@
Find bar tests + + diff --git a/browser/metro/base/tests/mochitest/browser_findbar.js b/browser/metro/base/tests/mochitest/browser_findbar.js new file mode 100644 index 000000000000..ccc586153b72 --- /dev/null +++ b/browser/metro/base/tests/mochitest/browser_findbar.js @@ -0,0 +1,56 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +function test() { + runTests(); +} + +gTests.push({ + desc: "Access the find bar with the keyboard", + run: function() { + let tab = yield addTab(chromeRoot + "browser_findbar.html"); + yield waitForCondition(() => BrowserUI.ready); + is(Elements.findbar.isShowing, false, "Find bar is hidden by default"); + + EventUtils.synthesizeKey("f", { accelKey: true }); + yield waitForEvent(Elements.findbar, "transitionend"); + is(Elements.findbar.isShowing, true, "Show find bar with Ctrl-F"); + + let textbox = document.getElementById("findbar-textbox"); + is(textbox.value, "", "Find bar is empty"); + + EventUtils.sendString("bar"); + is(textbox.value, "bar", "Type 'bar' into find bar"); + + EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }); + yield waitForEvent(Elements.findbar, "transitionend"); + is(Elements.findbar.isShowing, false, "Hide find bar with Esc"); + + Browser.closeTab(tab); + } +}); + +gTests.push({ + desc: "Show and hide the find bar with mouse", + run: function() { + let tab = yield addTab(chromeRoot + "browser_findbar.html"); + yield waitForCondition(() => BrowserUI.ready); + is(Elements.findbar.isShowing, false, "Find bar is hidden by default"); + + ContextUI.displayNavbar(); + EventUtils.sendMouseEvent({ type: "click" }, "menu-button"); + EventUtils.sendMouseEvent({ type: "click" }, "context-findinpage"); + yield waitForEvent(Elements.findbar, "transitionend"); + is(Elements.findbar.isShowing, true, "Show find bar with menu item"); + + EventUtils.synthesizeMouse(document.getElementById("findbar-close"), 1, 1, {}); + yield waitForEvent(Elements.findbar, "transitionend"); + is(Elements.findbar.isShowing, false, "Hide find bar with close button"); + + Browser.closeTab(tab); + } +});