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

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

mercurial