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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 let navbar = document.getElementById("nav-bar");
     8 let navbarCT = navbar.customizationTarget;
     9 let overflowPanelList = document.getElementById("widget-overflow-list");
    11 // Reading currentset
    12 add_task(function() {
    13   let nodeIds = [];
    14   for (let node of navbarCT.childNodes) {
    15     if (node.getAttribute("skipintoolbarset") != "true") {
    16       nodeIds.push(node.id);
    17     }
    18   }
    19   for (let node of overflowPanelList.childNodes) {
    20     if (node.getAttribute("skipintoolbarset") != "true") {
    21       nodeIds.push(node.id);
    22     }
    23   }
    24   let currentSet = navbar.currentSet;
    25   is(currentSet.split(',').length, nodeIds.length, "Should be just as many nodes as there are.");
    26   is(currentSet, nodeIds.join(','), "Current set and node IDs should match.");
    27 });
    29 // Insert, then remove items
    30 add_task(function() {
    31   let currentSet = navbar.currentSet;
    32   let newCurrentSet = currentSet.replace('home-button', 'feed-button,sync-button,home-button');
    33   navbar.currentSet = newCurrentSet;
    34   is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
    35   let feedBtn = document.getElementById("feed-button");
    36   let syncBtn = document.getElementById("sync-button");
    37   ok(feedBtn, "Feed button should have been added.");
    38   ok(syncBtn, "Sync button should have been added.");
    39   if (feedBtn && syncBtn) {
    40     let feedParent = feedBtn.parentNode;
    41     let syncParent = syncBtn.parentNode;
    42     ok(feedParent == navbarCT || feedParent == overflowPanelList,
    43        "Feed button should be in navbar or overflow");
    44     ok(syncParent == navbarCT || syncParent == overflowPanelList,
    45        "Feed button should be in navbar or overflow");
    46     is(feedBtn.nextElementSibling, syncBtn, "Feed button should be next to sync button.");
    47     let homeBtn = document.getElementById("home-button");
    48     is(syncBtn.nextElementSibling, homeBtn, "Sync button should be next to home button.");
    49   }
    50   navbar.currentSet = currentSet;
    51   is(currentSet, navbar.currentSet, "Should be able to remove the added items.");
    52 });
    54 // Simultaneous insert/remove:
    55 add_task(function() {
    56   let currentSet = navbar.currentSet;
    57   let newCurrentSet = currentSet.replace('home-button', 'feed-button');
    58   navbar.currentSet = newCurrentSet;
    59   is(newCurrentSet, navbar.currentSet, "Current set should match expected current set.");
    60   let feedBtn = document.getElementById("feed-button");
    61   ok(feedBtn, "Feed button should have been added.");
    62   let homeBtn = document.getElementById("home-button");
    63   ok(!homeBtn, "Home button should have been removed.");
    64   if (feedBtn) {
    65     let feedParent = feedBtn.parentNode;
    66     ok(feedParent == navbarCT || feedParent == overflowPanelList,
    67        "Feed button should be in navbar or overflow");
    68   }
    69   navbar.currentSet = currentSet;
    70   is(currentSet, navbar.currentSet, "Should be able to return to original state.");
    71 });
    73 add_task(function asyncCleanup() {
    74   yield resetCustomization();
    75 });

mercurial