Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | "use strict"; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | runTests(); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | gTests.push({ |
michael@0 | 13 | desc: "Access the find bar with the keyboard", |
michael@0 | 14 | run: function() { |
michael@0 | 15 | let tab = yield addTab(chromeRoot + "browser_findbar.html"); |
michael@0 | 16 | yield waitForCondition(() => BrowserUI.ready); |
michael@0 | 17 | is(Elements.findbar.isShowing, false, "Find bar is hidden by default"); |
michael@0 | 18 | |
michael@0 | 19 | EventUtils.synthesizeKey("f", { accelKey: true }); |
michael@0 | 20 | yield waitForEvent(Elements.findbar, "transitionend"); |
michael@0 | 21 | is(Elements.findbar.isShowing, true, "Show find bar with Ctrl-F"); |
michael@0 | 22 | |
michael@0 | 23 | let textbox = document.getElementById("findbar-textbox"); |
michael@0 | 24 | is(textbox.value, "", "Find bar is empty"); |
michael@0 | 25 | |
michael@0 | 26 | EventUtils.sendString("bar"); |
michael@0 | 27 | is(textbox.value, "bar", "Type 'bar' into find bar"); |
michael@0 | 28 | |
michael@0 | 29 | EventUtils.synthesizeKey("f", { accelKey: true}); |
michael@0 | 30 | yield waitForEvent(Elements.findbar, "transitionend"); |
michael@0 | 31 | ok(document.commandDispatcher.focusedElement, textbox.inputField, "textbox field is focused with Ctrl-F"); |
michael@0 | 32 | is(textbox.selectionStart, 0, "textbox field is selected with Ctrl-F."); |
michael@0 | 33 | is(textbox.selectionEnd, textbox.value.length, "textbox field is selected with Ctrl-F."); |
michael@0 | 34 | |
michael@0 | 35 | EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }); |
michael@0 | 36 | yield waitForEvent(Elements.findbar, "transitionend"); |
michael@0 | 37 | is(Elements.findbar.isShowing, false, "Hide find bar with Esc"); |
michael@0 | 38 | |
michael@0 | 39 | Browser.closeTab(tab); |
michael@0 | 40 | } |
michael@0 | 41 | }); |
michael@0 | 42 | |
michael@0 | 43 | gTests.push({ |
michael@0 | 44 | desc: "Findbar/navbar interaction", |
michael@0 | 45 | run: function() { |
michael@0 | 46 | let tab = yield addTab(chromeRoot + "browser_findbar.html"); |
michael@0 | 47 | yield waitForCondition(() => BrowserUI.ready); |
michael@0 | 48 | is(ContextUI.navbarVisible, false, "Navbar is hidden by default"); |
michael@0 | 49 | is(Elements.findbar.isShowing, false, "Find bar is hidden by default"); |
michael@0 | 50 | |
michael@0 | 51 | yield showNavBar(); |
michael@0 | 52 | is(ContextUI.navbarVisible, true, "Navbar is visible"); |
michael@0 | 53 | is(Elements.findbar.isShowing, false, "Find bar is still hidden"); |
michael@0 | 54 | |
michael@0 | 55 | EventUtils.synthesizeKey("f", { accelKey: true }); |
michael@0 | 56 | yield Promise.all([waitForEvent(Elements.navbar, "transitionend"), |
michael@0 | 57 | waitForEvent(Elements.findbar, "transitionend")]); |
michael@0 | 58 | is(ContextUI.navbarVisible, false, "Navbar is hidden"); |
michael@0 | 59 | is(Elements.findbar.isShowing, true, "Findbar is visible"); |
michael@0 | 60 | |
michael@0 | 61 | yield Promise.all([showNavBar(), |
michael@0 | 62 | waitForEvent(Elements.findbar, "transitionend")]); |
michael@0 | 63 | is(ContextUI.navbarVisible, true, "Navbar is visible again"); |
michael@0 | 64 | is(Elements.findbar.isShowing, false, "Find bar is hidden again"); |
michael@0 | 65 | |
michael@0 | 66 | Browser.closeTab(tab); |
michael@0 | 67 | } |
michael@0 | 68 | }); |
michael@0 | 69 | |
michael@0 | 70 | |
michael@0 | 71 | gTests.push({ |
michael@0 | 72 | desc: "Show and hide the find bar with mouse", |
michael@0 | 73 | run: function() { |
michael@0 | 74 | let tab = yield addTab(chromeRoot + "browser_findbar.html"); |
michael@0 | 75 | yield waitForCondition(() => BrowserUI.ready); |
michael@0 | 76 | is(Elements.findbar.isShowing, false, "Find bar is hidden by default"); |
michael@0 | 77 | |
michael@0 | 78 | yield showNavBar(); |
michael@0 | 79 | EventUtils.sendMouseEvent({ type: "click" }, "menu-button"); |
michael@0 | 80 | EventUtils.sendMouseEvent({ type: "click" }, "context-findinpage"); |
michael@0 | 81 | yield waitForEvent(Elements.findbar, "transitionend"); |
michael@0 | 82 | is(Elements.findbar.isShowing, true, "Show find bar with menu item"); |
michael@0 | 83 | |
michael@0 | 84 | EventUtils.synthesizeMouse(document.getElementById("findbar-close-button"), 1, 1, {}); |
michael@0 | 85 | yield waitForEvent(Elements.findbar, "transitionend"); |
michael@0 | 86 | is(Elements.findbar.isShowing, false, "Hide find bar with close button"); |
michael@0 | 87 | |
michael@0 | 88 | Browser.closeTab(tab); |
michael@0 | 89 | } |
michael@0 | 90 | }); |
michael@0 | 91 | |
michael@0 | 92 | gTests.push({ |
michael@0 | 93 | desc: "Text at bottom of screen is not obscured by findbar", |
michael@0 | 94 | run: function() { |
michael@0 | 95 | let textbox = document.getElementById("findbar-textbox"); |
michael@0 | 96 | |
michael@0 | 97 | let tab = yield addTab(chromeRoot + "browser_findbar.html"); |
michael@0 | 98 | yield waitForCondition(() => BrowserUI.ready); |
michael@0 | 99 | is(Elements.findbar.isShowing, false, "Find bar is hidden by default"); |
michael@0 | 100 | |
michael@0 | 101 | FindHelperUI.show(); |
michael@0 | 102 | yield waitForCondition(() => FindHelperUI.isActive); |
michael@0 | 103 | |
michael@0 | 104 | EventUtils.sendString("bottom"); |
michael@0 | 105 | let event = yield waitForEvent(window, "MozDeckOffsetChanged"); |
michael@0 | 106 | ok(!(event instanceof Error), "MozDeckOffsetChanged received (1)"); |
michael@0 | 107 | ok(event.detail > 0, "Browser deck shifted upward"); |
michael@0 | 108 | |
michael@0 | 109 | textbox.select(); |
michael@0 | 110 | EventUtils.sendString("bar"); |
michael@0 | 111 | event = yield waitForEvent(window, "MozDeckOffsetChanged"); |
michael@0 | 112 | ok(!(event instanceof Error), "MozDeckOffsetChanged received (2)"); |
michael@0 | 113 | is(event.detail, 0, "Browser deck shifted back to normal"); |
michael@0 | 114 | |
michael@0 | 115 | textbox.select(); |
michael@0 | 116 | EventUtils.sendString("bottom"); |
michael@0 | 117 | event = yield waitForEvent(window, "MozDeckOffsetChanged"); |
michael@0 | 118 | ok(!(event instanceof Error), "MozDeckOffsetChanged received (3)"); |
michael@0 | 119 | ok(event.detail > 0, "Browser deck shifted upward again"); |
michael@0 | 120 | |
michael@0 | 121 | let waitForDeckOffset = waitForEvent(window, "MozDeckOffsetChanged"); |
michael@0 | 122 | let waitForTransitionEnd = waitForEvent(Elements.findbar, "transitionend"); |
michael@0 | 123 | FindHelperUI.hide(); |
michael@0 | 124 | event = yield waitForDeckOffset; |
michael@0 | 125 | ok(!(event instanceof Error), "MozDeckOffsetChanged received (4)"); |
michael@0 | 126 | is(event.detail, 0, "Browser deck shifted back to normal when findbar hides"); |
michael@0 | 127 | |
michael@0 | 128 | // Cleanup. |
michael@0 | 129 | yield waitForTransitionEnd; |
michael@0 | 130 | Browser.closeTab(tab); |
michael@0 | 131 | } |
michael@0 | 132 | }); |