browser/modules/test/browser_UITour_panel_close_annotation.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 * Tests that annotations disappear when their target is hidden.
michael@0 6 */
michael@0 7
michael@0 8 "use strict";
michael@0 9
michael@0 10 let gTestTab;
michael@0 11 let gContentAPI;
michael@0 12 let gContentWindow;
michael@0 13 let highlight = document.getElementById("UITourHighlight");
michael@0 14 let tooltip = document.getElementById("UITourTooltip");
michael@0 15
michael@0 16 Components.utils.import("resource:///modules/UITour.jsm");
michael@0 17
michael@0 18 function test() {
michael@0 19 registerCleanupFunction(() => {
michael@0 20 // Close the find bar in case it's open in the remaining tab
michael@0 21 gBrowser.getFindBar(gBrowser.selectedTab).close();
michael@0 22 });
michael@0 23 UITourTest();
michael@0 24 }
michael@0 25
michael@0 26 let tests = [
michael@0 27 function test_highlight_move_outside_panel(done) {
michael@0 28 gContentAPI.showInfo("urlbar", "test title", "test text");
michael@0 29 gContentAPI.showHighlight("customize");
michael@0 30 waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
michael@0 31 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
michael@0 32
michael@0 33 // Move the highlight outside which should close the app menu.
michael@0 34 gContentAPI.showHighlight("appMenu");
michael@0 35 waitForPopupAtAnchor(highlight.parentElement, document.getElementById("PanelUI-button"), () => {
michael@0 36 isnot(PanelUI.panel.state, "open",
michael@0 37 "Panel should have closed after the highlight moved elsewhere.");
michael@0 38 is(tooltip.state, "open", "The info panel should have remained open");
michael@0 39 done();
michael@0 40 }, "Highlight should move to the appMenu button and still be visible");
michael@0 41 }, "Highlight should be shown after showHighlight() for fixed panel items");
michael@0 42 },
michael@0 43
michael@0 44 function test_highlight_panel_hideMenu(done) {
michael@0 45 gContentAPI.showHighlight("customize");
michael@0 46 gContentAPI.showInfo("search", "test title", "test text");
michael@0 47 waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
michael@0 48 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
michael@0 49
michael@0 50 // Close the app menu and make sure the highlight also disappeared.
michael@0 51 gContentAPI.hideMenu("appMenu");
michael@0 52 waitForElementToBeHidden(highlight, function checkPanelIsClosed() {
michael@0 53 isnot(PanelUI.panel.state, "open",
michael@0 54 "Panel still should have closed");
michael@0 55 is(tooltip.state, "open", "The info panel should have remained open");
michael@0 56 done();
michael@0 57 }, "Highlight should have disappeared when panel closed");
michael@0 58 }, "Highlight should be shown after showHighlight() for fixed panel items");
michael@0 59 },
michael@0 60
michael@0 61 function test_highlight_panel_click_find(done) {
michael@0 62 gContentAPI.showHighlight("help");
michael@0 63 gContentAPI.showInfo("searchProvider", "test title", "test text");
michael@0 64 waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
michael@0 65 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
michael@0 66
michael@0 67 // Click the find button which should close the panel.
michael@0 68 let findButton = document.getElementById("find-button");
michael@0 69 EventUtils.synthesizeMouseAtCenter(findButton, {});
michael@0 70 waitForElementToBeHidden(highlight, function checkPanelIsClosed() {
michael@0 71 isnot(PanelUI.panel.state, "open",
michael@0 72 "Panel should have closed when the find bar opened");
michael@0 73 is(tooltip.state, "open", "The info panel should have remained open");
michael@0 74 done();
michael@0 75 }, "Highlight should have disappeared when panel closed");
michael@0 76 }, "Highlight should be shown after showHighlight() for fixed panel items");
michael@0 77 },
michael@0 78
michael@0 79 function test_highlight_info_panel_click_find(done) {
michael@0 80 gContentAPI.showHighlight("help");
michael@0 81 gContentAPI.showInfo("customize", "customize me!", "awesome!");
michael@0 82 waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
michael@0 83 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
michael@0 84
michael@0 85 // Click the find button which should close the panel.
michael@0 86 let findButton = document.getElementById("find-button");
michael@0 87 EventUtils.synthesizeMouseAtCenter(findButton, {});
michael@0 88 waitForElementToBeHidden(highlight, function checkPanelIsClosed() {
michael@0 89 isnot(PanelUI.panel.state, "open",
michael@0 90 "Panel should have closed when the find bar opened");
michael@0 91 waitForElementToBeHidden(tooltip, function checkTooltipIsClosed() {
michael@0 92 isnot(tooltip.state, "open", "The info panel should have closed too");
michael@0 93 done();
michael@0 94 }, "Tooltip should hide with the menu");
michael@0 95 }, "Highlight should have disappeared when panel closed");
michael@0 96 }, "Highlight should be shown after showHighlight() for fixed panel items");
michael@0 97 },
michael@0 98
michael@0 99 function test_highlight_panel_open_subview(done) {
michael@0 100 gContentAPI.showHighlight("customize");
michael@0 101 gContentAPI.showInfo("backForward", "test title", "test text");
michael@0 102 waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
michael@0 103 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
michael@0 104
michael@0 105 // Click the help button which should open the subview in the panel menu.
michael@0 106 let helpButton = document.getElementById("PanelUI-help");
michael@0 107 EventUtils.synthesizeMouseAtCenter(helpButton, {});
michael@0 108 waitForElementToBeHidden(highlight, function highlightHidden() {
michael@0 109 is(PanelUI.panel.state, "open",
michael@0 110 "Panel should have stayed open when the subview opened");
michael@0 111 is(tooltip.state, "open", "The info panel should have remained open");
michael@0 112 PanelUI.hide();
michael@0 113 done();
michael@0 114 }, "Highlight should have disappeared when the subview opened");
michael@0 115 }, "Highlight should be shown after showHighlight() for fixed panel items");
michael@0 116 },
michael@0 117
michael@0 118 function test_info_panel_open_subview(done) {
michael@0 119 gContentAPI.showHighlight("urlbar");
michael@0 120 gContentAPI.showInfo("customize", "customize me!", "Open a subview");
michael@0 121 waitForElementToBeVisible(tooltip, function checkPanelIsOpen() {
michael@0 122 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
michael@0 123
michael@0 124 // Click the help button which should open the subview in the panel menu.
michael@0 125 let helpButton = document.getElementById("PanelUI-help");
michael@0 126 EventUtils.synthesizeMouseAtCenter(helpButton, {});
michael@0 127 waitForElementToBeHidden(tooltip, function tooltipHidden() {
michael@0 128 is(PanelUI.panel.state, "open",
michael@0 129 "Panel should have stayed open when the subview opened");
michael@0 130 is(highlight.parentElement.state, "open", "The highlight should have remained open");
michael@0 131 PanelUI.hide();
michael@0 132 done();
michael@0 133 }, "Tooltip should have disappeared when the subview opened");
michael@0 134 }, "Highlight should be shown after showHighlight() for fixed panel items");
michael@0 135 },
michael@0 136
michael@0 137 function test_info_move_outside_panel(done) {
michael@0 138 gContentAPI.showInfo("addons", "test title", "test text");
michael@0 139 gContentAPI.showHighlight("urlbar");
michael@0 140 let addonsButton = document.getElementById("add-ons-button");
michael@0 141 waitForPopupAtAnchor(tooltip, addonsButton, function checkPanelIsOpen() {
michael@0 142 isnot(PanelUI.panel.state, "closed", "Panel should have opened");
michael@0 143
michael@0 144 // Move the info panel outside which should close the app menu.
michael@0 145 gContentAPI.showInfo("appMenu", "Cool menu button", "It's three lines");
michael@0 146 waitForPopupAtAnchor(tooltip, document.getElementById("PanelUI-button"), () => {
michael@0 147 isnot(PanelUI.panel.state, "open",
michael@0 148 "Menu should have closed after the highlight moved elsewhere.");
michael@0 149 is(highlight.parentElement.state, "open", "The highlight should have remained visible");
michael@0 150 done();
michael@0 151 }, "Tooltip should move to the appMenu button and still be visible");
michael@0 152 }, "Tooltip should be shown after showInfo() for a panel item");
michael@0 153 },
michael@0 154
michael@0 155 ];

mercurial