browser/components/customizableui/test/browser_panel_toggle.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/customizableui/test/browser_panel_toggle.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +/**
    1.11 + * Test opening and closing the menu panel UI.
    1.12 + */
    1.13 +
    1.14 +// Show and hide the menu panel programmatically without an event (like UITour.jsm would)
    1.15 +add_task(function() {
    1.16 +  let shownPromise = promisePanelShown(window);
    1.17 +  PanelUI.show();
    1.18 +  yield shownPromise;
    1.19 +
    1.20 +  is(PanelUI.panel.getAttribute("panelopen"), "true", "Check that panel has panelopen attribute");
    1.21 +  is(PanelUI.panel.state, "open", "Check that panel state is 'open'");
    1.22 +
    1.23 +  let hiddenPromise = promisePanelHidden(window);
    1.24 +  PanelUI.hide();
    1.25 +  yield hiddenPromise;
    1.26 +
    1.27 +  ok(!PanelUI.panel.hasAttribute("panelopen"), "Check that panel doesn't have the panelopen attribute");
    1.28 +  is(PanelUI.panel.state, "closed", "Check that panel state is 'closed'");
    1.29 +});
    1.30 +
    1.31 +// Toggle the menu panel open and closed
    1.32 +add_task(function() {
    1.33 +  let shownPromise = promisePanelShown(window);
    1.34 +  PanelUI.toggle({type: "command"});
    1.35 +  yield shownPromise;
    1.36 +
    1.37 +  is(PanelUI.panel.getAttribute("panelopen"), "true", "Check that panel has panelopen attribute");
    1.38 +  is(PanelUI.panel.state, "open", "Check that panel state is 'open'");
    1.39 +
    1.40 +  let hiddenPromise = promisePanelHidden(window);
    1.41 +  PanelUI.toggle({type: "command"});
    1.42 +  yield hiddenPromise;
    1.43 +
    1.44 +  ok(!PanelUI.panel.hasAttribute("panelopen"), "Check that panel doesn't have the panelopen attribute");
    1.45 +  is(PanelUI.panel.state, "closed", "Check that panel state is 'closed'");
    1.46 +});

mercurial