Bug 892759 - Add basic tests for the Metro find in page bar [r=rsilveira]

This commit is contained in:
Matt Brubeck 2013-07-15 15:20:32 -07:00
parent 91485d75fb
commit 423705b64a
5 changed files with 71 additions and 1 deletions

View File

@ -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);
});

View File

@ -356,7 +356,7 @@
<button class="findbar-item previous-button" command="cmd_findPrevious"/>
<button class="findbar-item next-button" command="cmd_findNext"/>
<spacer flex="1"/>
<button class="findbar-item close-button" command="cmd_findClose"/>
<button id="findbar-close" class="findbar-item close-button" command="cmd_findClose"/>
</appbar>
<!-- Context button bar -->

View File

@ -21,6 +21,8 @@ BROWSER_TESTS = \
browser_context_menu_tests_03.html \
browser_context_ui.js \
browser_downloads.js \
browser_findbar.js \
browser_findbar.html \
browser_history.js \
browser_onscreen_keyboard.js \
browser_onscreen_keyboard.html \

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Find bar tests</title>
</head>
<body>
<p>Find bar tests</title>
</body>
</html>

View File

@ -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);
}
});