browser/modules/test/browser_UITour_panel_close_annotation.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/modules/test/browser_UITour_panel_close_annotation.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,155 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests that annotations disappear when their target is hidden.
     1.9 + */
    1.10 +
    1.11 +"use strict";
    1.12 +
    1.13 +let gTestTab;
    1.14 +let gContentAPI;
    1.15 +let gContentWindow;
    1.16 +let highlight = document.getElementById("UITourHighlight");
    1.17 +let tooltip = document.getElementById("UITourTooltip");
    1.18 +
    1.19 +Components.utils.import("resource:///modules/UITour.jsm");
    1.20 +
    1.21 +function test() {
    1.22 +  registerCleanupFunction(() => {
    1.23 +    // Close the find bar in case it's open in the remaining tab
    1.24 +    gBrowser.getFindBar(gBrowser.selectedTab).close();
    1.25 +  });
    1.26 +  UITourTest();
    1.27 +}
    1.28 +
    1.29 +let tests = [
    1.30 +  function test_highlight_move_outside_panel(done) {
    1.31 +    gContentAPI.showInfo("urlbar", "test title", "test text");
    1.32 +    gContentAPI.showHighlight("customize");
    1.33 +    waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
    1.34 +      isnot(PanelUI.panel.state, "closed", "Panel should have opened");
    1.35 +
    1.36 +      // Move the highlight outside which should close the app menu.
    1.37 +      gContentAPI.showHighlight("appMenu");
    1.38 +      waitForPopupAtAnchor(highlight.parentElement, document.getElementById("PanelUI-button"), () => {
    1.39 +        isnot(PanelUI.panel.state, "open",
    1.40 +              "Panel should have closed after the highlight moved elsewhere.");
    1.41 +        is(tooltip.state, "open", "The info panel should have remained open");
    1.42 +        done();
    1.43 +      }, "Highlight should move to the appMenu button and still be visible");
    1.44 +    }, "Highlight should be shown after showHighlight() for fixed panel items");
    1.45 +  },
    1.46 +
    1.47 +  function test_highlight_panel_hideMenu(done) {
    1.48 +    gContentAPI.showHighlight("customize");
    1.49 +    gContentAPI.showInfo("search", "test title", "test text");
    1.50 +    waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
    1.51 +      isnot(PanelUI.panel.state, "closed", "Panel should have opened");
    1.52 +
    1.53 +      // Close the app menu and make sure the highlight also disappeared.
    1.54 +      gContentAPI.hideMenu("appMenu");
    1.55 +      waitForElementToBeHidden(highlight, function checkPanelIsClosed() {
    1.56 +        isnot(PanelUI.panel.state, "open",
    1.57 +              "Panel still should have closed");
    1.58 +        is(tooltip.state, "open", "The info panel should have remained open");
    1.59 +        done();
    1.60 +      }, "Highlight should have disappeared when panel closed");
    1.61 +    }, "Highlight should be shown after showHighlight() for fixed panel items");
    1.62 +  },
    1.63 +
    1.64 +  function test_highlight_panel_click_find(done) {
    1.65 +    gContentAPI.showHighlight("help");
    1.66 +    gContentAPI.showInfo("searchProvider", "test title", "test text");
    1.67 +    waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
    1.68 +      isnot(PanelUI.panel.state, "closed", "Panel should have opened");
    1.69 +
    1.70 +      // Click the find button which should close the panel.
    1.71 +      let findButton = document.getElementById("find-button");
    1.72 +      EventUtils.synthesizeMouseAtCenter(findButton, {});
    1.73 +      waitForElementToBeHidden(highlight, function checkPanelIsClosed() {
    1.74 +        isnot(PanelUI.panel.state, "open",
    1.75 +              "Panel should have closed when the find bar opened");
    1.76 +        is(tooltip.state, "open", "The info panel should have remained open");
    1.77 +        done();
    1.78 +      }, "Highlight should have disappeared when panel closed");
    1.79 +    }, "Highlight should be shown after showHighlight() for fixed panel items");
    1.80 +  },
    1.81 +
    1.82 +  function test_highlight_info_panel_click_find(done) {
    1.83 +    gContentAPI.showHighlight("help");
    1.84 +    gContentAPI.showInfo("customize", "customize me!", "awesome!");
    1.85 +    waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
    1.86 +      isnot(PanelUI.panel.state, "closed", "Panel should have opened");
    1.87 +
    1.88 +      // Click the find button which should close the panel.
    1.89 +      let findButton = document.getElementById("find-button");
    1.90 +      EventUtils.synthesizeMouseAtCenter(findButton, {});
    1.91 +      waitForElementToBeHidden(highlight, function checkPanelIsClosed() {
    1.92 +        isnot(PanelUI.panel.state, "open",
    1.93 +              "Panel should have closed when the find bar opened");
    1.94 +        waitForElementToBeHidden(tooltip, function checkTooltipIsClosed() {
    1.95 +          isnot(tooltip.state, "open", "The info panel should have closed too");
    1.96 +          done();
    1.97 +        }, "Tooltip should hide with the menu");
    1.98 +      }, "Highlight should have disappeared when panel closed");
    1.99 +    }, "Highlight should be shown after showHighlight() for fixed panel items");
   1.100 +  },
   1.101 +
   1.102 +  function test_highlight_panel_open_subview(done) {
   1.103 +    gContentAPI.showHighlight("customize");
   1.104 +    gContentAPI.showInfo("backForward", "test title", "test text");
   1.105 +    waitForElementToBeVisible(highlight, function checkPanelIsOpen() {
   1.106 +      isnot(PanelUI.panel.state, "closed", "Panel should have opened");
   1.107 +
   1.108 +      // Click the help button which should open the subview in the panel menu.
   1.109 +      let helpButton = document.getElementById("PanelUI-help");
   1.110 +      EventUtils.synthesizeMouseAtCenter(helpButton, {});
   1.111 +      waitForElementToBeHidden(highlight, function highlightHidden() {
   1.112 +        is(PanelUI.panel.state, "open",
   1.113 +           "Panel should have stayed open when the subview opened");
   1.114 +        is(tooltip.state, "open", "The info panel should have remained open");
   1.115 +        PanelUI.hide();
   1.116 +        done();
   1.117 +      }, "Highlight should have disappeared when the subview opened");
   1.118 +    }, "Highlight should be shown after showHighlight() for fixed panel items");
   1.119 +  },
   1.120 +
   1.121 +  function test_info_panel_open_subview(done) {
   1.122 +    gContentAPI.showHighlight("urlbar");
   1.123 +    gContentAPI.showInfo("customize", "customize me!", "Open a subview");
   1.124 +    waitForElementToBeVisible(tooltip, function checkPanelIsOpen() {
   1.125 +      isnot(PanelUI.panel.state, "closed", "Panel should have opened");
   1.126 +
   1.127 +      // Click the help button which should open the subview in the panel menu.
   1.128 +      let helpButton = document.getElementById("PanelUI-help");
   1.129 +      EventUtils.synthesizeMouseAtCenter(helpButton, {});
   1.130 +      waitForElementToBeHidden(tooltip, function tooltipHidden() {
   1.131 +        is(PanelUI.panel.state, "open",
   1.132 +           "Panel should have stayed open when the subview opened");
   1.133 +        is(highlight.parentElement.state, "open", "The highlight should have remained open");
   1.134 +        PanelUI.hide();
   1.135 +        done();
   1.136 +      }, "Tooltip should have disappeared when the subview opened");
   1.137 +    }, "Highlight should be shown after showHighlight() for fixed panel items");
   1.138 +  },
   1.139 +
   1.140 +  function test_info_move_outside_panel(done) {
   1.141 +    gContentAPI.showInfo("addons", "test title", "test text");
   1.142 +    gContentAPI.showHighlight("urlbar");
   1.143 +    let addonsButton = document.getElementById("add-ons-button");
   1.144 +    waitForPopupAtAnchor(tooltip, addonsButton, function checkPanelIsOpen() {
   1.145 +      isnot(PanelUI.panel.state, "closed", "Panel should have opened");
   1.146 +
   1.147 +      // Move the info panel outside which should close the app menu.
   1.148 +      gContentAPI.showInfo("appMenu", "Cool menu button", "It's three lines");
   1.149 +      waitForPopupAtAnchor(tooltip, document.getElementById("PanelUI-button"), () => {
   1.150 +        isnot(PanelUI.panel.state, "open",
   1.151 +              "Menu should have closed after the highlight moved elsewhere.");
   1.152 +        is(highlight.parentElement.state, "open", "The highlight should have remained visible");
   1.153 +        done();
   1.154 +      }, "Tooltip should move to the appMenu button and still be visible");
   1.155 +    }, "Tooltip should be shown after showInfo() for a panel item");
   1.156 +  },
   1.157 +
   1.158 +];

mercurial