browser/components/customizableui/test/browser_887438_currentset_shim.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 let navbar = document.getElementById("nav-bar");
michael@0 8 let navbarCT = navbar.customizationTarget;
michael@0 9 let overflowPanelList = document.getElementById("widget-overflow-list");
michael@0 10
michael@0 11 // Reading currentset
michael@0 12 add_task(function() {
michael@0 13 let nodeIds = [];
michael@0 14 for (let node of navbarCT.childNodes) {
michael@0 15 if (node.getAttribute("skipintoolbarset") != "true") {
michael@0 16 nodeIds.push(node.id);
michael@0 17 }
michael@0 18 }
michael@0 19 for (let node of overflowPanelList.childNodes) {
michael@0 20 if (node.getAttribute("skipintoolbarset") != "true") {
michael@0 21 nodeIds.push(node.id);
michael@0 22 }
michael@0 23 }
michael@0 24 let currentSet = navbar.currentSet;
michael@0 25 is(currentSet.split(',').length, nodeIds.length, "Should be just as many nodes as there are.");
michael@0 26 is(currentSet, nodeIds.join(','), "Current set and node IDs should match.");
michael@0 27 });
michael@0 28
michael@0 29 // Insert, then remove items
michael@0 30 add_task(function() {
michael@0 31 let currentSet = navbar.currentSet;
michael@0 32 let newCurrentSet = currentSet.replace('home-button', 'feed-button,sync-button,home-button');
michael@0 33 navbar.currentSet = newCurrentSet;
michael@0 34 is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
michael@0 35 let feedBtn = document.getElementById("feed-button");
michael@0 36 let syncBtn = document.getElementById("sync-button");
michael@0 37 ok(feedBtn, "Feed button should have been added.");
michael@0 38 ok(syncBtn, "Sync button should have been added.");
michael@0 39 if (feedBtn && syncBtn) {
michael@0 40 let feedParent = feedBtn.parentNode;
michael@0 41 let syncParent = syncBtn.parentNode;
michael@0 42 ok(feedParent == navbarCT || feedParent == overflowPanelList,
michael@0 43 "Feed button should be in navbar or overflow");
michael@0 44 ok(syncParent == navbarCT || syncParent == overflowPanelList,
michael@0 45 "Feed button should be in navbar or overflow");
michael@0 46 is(feedBtn.nextElementSibling, syncBtn, "Feed button should be next to sync button.");
michael@0 47 let homeBtn = document.getElementById("home-button");
michael@0 48 is(syncBtn.nextElementSibling, homeBtn, "Sync button should be next to home button.");
michael@0 49 }
michael@0 50 navbar.currentSet = currentSet;
michael@0 51 is(currentSet, navbar.currentSet, "Should be able to remove the added items.");
michael@0 52 });
michael@0 53
michael@0 54 // Simultaneous insert/remove:
michael@0 55 add_task(function() {
michael@0 56 let currentSet = navbar.currentSet;
michael@0 57 let newCurrentSet = currentSet.replace('home-button', 'feed-button');
michael@0 58 navbar.currentSet = newCurrentSet;
michael@0 59 is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
michael@0 60 let feedBtn = document.getElementById("feed-button");
michael@0 61 ok(feedBtn, "Feed button should have been added.");
michael@0 62 let homeBtn = document.getElementById("home-button");
michael@0 63 ok(!homeBtn, "Home button should have been removed.");
michael@0 64 if (feedBtn) {
michael@0 65 let feedParent = feedBtn.parentNode;
michael@0 66 ok(feedParent == navbarCT || feedParent == overflowPanelList,
michael@0 67 "Feed button should be in navbar or overflow");
michael@0 68 }
michael@0 69 navbar.currentSet = currentSet;
michael@0 70 is(currentSet, navbar.currentSet, "Should be able to return to original state.");
michael@0 71 });
michael@0 72
michael@0 73 add_task(function asyncCleanup() {
michael@0 74 yield resetCustomization();
michael@0 75 });

mercurial