browser/components/customizableui/test/browser_876944_customize_mode_create_destroy.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 const kTestWidget1 = "test-customize-mode-create-destroy1";
michael@0 8 const kTestWidget2 = "test-customize-mode-create-destroy2";
michael@0 9
michael@0 10 // Creating and destroying a widget should correctly wrap/unwrap stuff
michael@0 11 add_task(function testWrapUnwrap() {
michael@0 12 yield startCustomizing();
michael@0 13 CustomizableUI.createWidget({id: kTestWidget1, label: 'Pretty label', tooltiptext: 'Pretty tooltip'});
michael@0 14 let elem = document.getElementById(kTestWidget1);
michael@0 15 let wrapper = document.getElementById("wrapper-" + kTestWidget1);
michael@0 16 ok(elem, "There should be an item");
michael@0 17 ok(wrapper, "There should be a wrapper");
michael@0 18 is(wrapper.firstChild.id, kTestWidget1, "Wrapper should have test widget");
michael@0 19 is(wrapper.parentNode.id, "customization-palette", "Wrapper should be in palette");
michael@0 20 CustomizableUI.destroyWidget(kTestWidget1);
michael@0 21 wrapper = document.getElementById("wrapper-" + kTestWidget1);
michael@0 22 ok(!wrapper, "There should be a wrapper");
michael@0 23 let item = document.getElementById(kTestWidget1);
michael@0 24 ok(!item, "There should no longer be an item");
michael@0 25 });
michael@0 26
michael@0 27 // Creating and destroying a widget should correctly deal with panel placeholders
michael@0 28 add_task(function testPanelPlaceholders() {
michael@0 29 let panel = document.getElementById(CustomizableUI.AREA_PANEL);
michael@0 30 is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 1 : 2, "The number of placeholders should be correct.");
michael@0 31 CustomizableUI.createWidget({id: kTestWidget2, label: 'Pretty label', tooltiptext: 'Pretty tooltip', defaultArea: CustomizableUI.AREA_PANEL});
michael@0 32 let elem = document.getElementById(kTestWidget2);
michael@0 33 let wrapper = document.getElementById("wrapper-" + kTestWidget2);
michael@0 34 ok(elem, "There should be an item");
michael@0 35 ok(wrapper, "There should be a wrapper");
michael@0 36 is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget");
michael@0 37 is(wrapper.parentNode, panel, "Wrapper should be in panel");
michael@0 38 is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 3 : 1, "The number of placeholders should be correct.");
michael@0 39 CustomizableUI.destroyWidget(kTestWidget2);
michael@0 40 wrapper = document.getElementById("wrapper-" + kTestWidget2);
michael@0 41 ok(!wrapper, "There should be a wrapper");
michael@0 42 let item = document.getElementById(kTestWidget2);
michael@0 43 ok(!item, "There should no longer be an item");
michael@0 44 yield endCustomizing();
michael@0 45 });
michael@0 46
michael@0 47 add_task(function asyncCleanup() {
michael@0 48 yield endCustomizing();
michael@0 49 try {
michael@0 50 CustomizableUI.destroyWidget(kTestWidget1);
michael@0 51 } catch (ex) {}
michael@0 52 try {
michael@0 53 CustomizableUI.destroyWidget(kTestWidget2);
michael@0 54 } catch (ex) {}
michael@0 55 yield resetCustomization();
michael@0 56 });

mercurial