mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 03:49:42 +00:00
Bug 892759 - Add basic tests for the Metro find in page bar [r=rsilveira]
This commit is contained in:
parent
91485d75fb
commit
423705b64a
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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 -->
|
||||
|
@ -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 \
|
||||
|
10
browser/metro/base/tests/mochitest/browser_findbar.html
Normal file
10
browser/metro/base/tests/mochitest/browser_findbar.html
Normal 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>
|
56
browser/metro/base/tests/mochitest/browser_findbar.js
Normal file
56
browser/metro/base/tests/mochitest/browser_findbar.js
Normal 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);
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user