browser/components/customizableui/test/browser_993322_widget_notoolbar.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/customizableui/test/browser_993322_widget_notoolbar.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     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 +const BUTTONID = "test-API-created-widget-toolbar-gone";
    1.11 +const TOOLBARID = "test-API-created-extra-toolbar";
    1.12 +
    1.13 +add_task(function*() {
    1.14 +  let toolbar = createToolbarWithPlacements(TOOLBARID, []);
    1.15 +  CustomizableUI.addWidgetToArea(BUTTONID, TOOLBARID);
    1.16 +  is(CustomizableUI.getPlacementOfWidget(BUTTONID).area, TOOLBARID, "Should be on toolbar");
    1.17 +  is(toolbar.children.length, 0, "Toolbar has no kid");
    1.18 +
    1.19 +  CustomizableUI.unregisterArea(TOOLBARID);
    1.20 +  CustomizableUI.createWidget({id: BUTTONID, label: "Test widget toolbar gone"});
    1.21 +
    1.22 +  let currentWidget = CustomizableUI.getWidget(BUTTONID);
    1.23 +
    1.24 +  yield startCustomizing();
    1.25 +  let buttonNode = document.getElementById(BUTTONID);
    1.26 +  ok(buttonNode, "Should find button in window");
    1.27 +  if (buttonNode) {
    1.28 +    is(buttonNode.parentNode.localName, "toolbarpaletteitem", "Node should be wrapped");
    1.29 +    is(buttonNode.parentNode.getAttribute("place"), "palette", "Node should be in palette");
    1.30 +    is(buttonNode, gNavToolbox.palette.querySelector("#" + BUTTONID), "Node should really be in palette.");
    1.31 +  }
    1.32 +  is(currentWidget.forWindow(window).node, buttonNode, "Should have the same node for customize mode");
    1.33 +  yield endCustomizing();
    1.34 +
    1.35 +  CustomizableUI.destroyWidget(BUTTONID);
    1.36 +  CustomizableUI.unregisterArea(TOOLBARID, true);
    1.37 +  toolbar.remove();
    1.38 +  gAddedToolbars.clear();
    1.39 +});

mercurial