Bug 942915: Part 2: Update tests for Metro button Australis.
☠☠ backed out by 0ce73a4540df ☠ ☠
authorMarina Samuel <msamuel@mozilla.com>
Mon, 02 Dec 2013 11:17:14 -0500
changeset 173015 f2a84fb7a14e154f71f799aa0d85b3bb9a49744e
parent 173014 8601e55efa523d9b7e2b394121e186ea6555d5d7
child 173016 0aeb846dc2e7b458651a11df052415cb57eb301a
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs942915
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 942915: Part 2: Update tests for Metro button Australis.
browser/components/customizableui/test/browser_876944_customize_mode_create_destroy.js
browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js
browser/components/customizableui/test/browser_890140_orphaned_placeholders.js
browser/components/customizableui/test/head.js
--- a/browser/components/customizableui/test/browser_876944_customize_mode_create_destroy.js
+++ b/browser/components/customizableui/test/browser_876944_customize_mode_create_destroy.js
@@ -23,25 +23,25 @@ let gTests = [
       let item = document.getElementById(kTestWidget1);
       ok(!item, "There should no longer be an item");
     },
   },
   {
     desc: "Creating and destroying a widget should correctly deal with panel placeholders",
     run: function() {
       let panel = document.getElementById(CustomizableUI.AREA_PANEL);
-      is(panel.querySelectorAll(".panel-customization-placeholder").length, 3, "The number of placeholders should be correct.");
+      is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 2 : 3, "The number of placeholders should be correct.");
       CustomizableUI.createWidget({id: kTestWidget2, label: 'Pretty label', tooltiptext: 'Pretty tooltip', defaultArea: CustomizableUI.AREA_PANEL});
       let elem = document.getElementById(kTestWidget2);
       let wrapper = document.getElementById("wrapper-" + kTestWidget2);
       ok(elem, "There should be an item");
       ok(wrapper, "There should be a wrapper");
       is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget");
       is(wrapper.parentNode, panel, "Wrapper should be in panel");
-      is(panel.querySelectorAll(".panel-customization-placeholder").length, 2, "The number of placeholders should be correct.");
+      is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 1 : 2, "The number of placeholders should be correct.");
       CustomizableUI.destroyWidget(kTestWidget2);
       wrapper = document.getElementById("wrapper-" + kTestWidget2);
       ok(!wrapper, "There should be a wrapper");
       let item = document.getElementById(kTestWidget2);
       ok(!item, "There should no longer be an item");
     },
     teardown: endCustomizing
   },
--- a/browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js
+++ b/browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js
@@ -16,16 +16,17 @@ let gTests = [
                                  "save-page-button",
                                  "zoom-controls",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(zoomControls, printButton);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       let newWindowButton = document.getElementById("new-window-button");
       simulateItemDrag(zoomControls, newWindowButton);
       ok(CustomizableUI.inDefaultState, "Should be in default state again.");
     },
   },
@@ -42,16 +43,17 @@ let gTests = [
                                  "privatebrowsing-button",
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(zoomControls, savePageButton);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       ok(CustomizableUI.inDefaultState, "Should be in default state.");
     },
   },
   {
     desc: "Dragging the zoom controls to be before the new-window " +
           "button should not move any widgets.",
@@ -65,16 +67,17 @@ let gTests = [
                                  "privatebrowsing-button",
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(zoomControls, newWindowButton);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       ok(CustomizableUI.inDefaultState, "Should still be in default state.");
     },
   },
   {
     desc: "Dragging the zoom controls to be before the history-panelmenu " +
           "should move the zoom-controls in to the row higher than the " +
@@ -89,16 +92,17 @@ let gTests = [
                                  "save-page-button",
                                  "zoom-controls",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(zoomControls, historyPanelMenu);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       let newWindowButton = document.getElementById("new-window-button");
       simulateItemDrag(zoomControls, newWindowButton);
       ok(CustomizableUI.inDefaultState, "Should be in default state again.");
     },
   },
@@ -116,16 +120,17 @@ let gTests = [
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "zoom-controls",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(zoomControls, preferencesButton);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       let newWindowButton = document.getElementById("new-window-button");
       simulateItemDrag(zoomControls, newWindowButton);
       ok(CustomizableUI.inDefaultState, "Should be in default state again.");
     },
   },
@@ -143,16 +148,17 @@ let gTests = [
                                    "zoom-controls",
                                    "save-page-button",
                                    "print-button",
                                    "history-panelmenu",
                                    "fullscreen-button",
                                    "find-button",
                                    "preferences-button",
                                    "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterInsert);
       simulateItemDrag(developerButton, zoomControls);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       let palette = document.getElementById("customization-palette");
       // Check that the palette items are re-wrapped correctly.
       let feedWrapper = document.getElementById("wrapper-feed-button");
       let feedButton = document.getElementById("feed-button");
       is(feedButton.parentNode, feedWrapper,
@@ -181,16 +187,17 @@ let gTests = [
                                    "zoom-controls",
                                    "save-page-button",
                                    "print-button",
                                    "history-panelmenu",
                                    "fullscreen-button",
                                    "find-button",
                                    "preferences-button",
                                    "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterInsert);
       simulateItemDrag(developerButton, editControls);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       let palette = document.getElementById("customization-palette");
       // Check that the palette items are re-wrapped correctly.
       let feedWrapper = document.getElementById("wrapper-feed-button");
       let feedButton = document.getElementById("feed-button");
       is(feedButton.parentNode, feedWrapper,
@@ -216,16 +223,17 @@ let gTests = [
                                  "privatebrowsing-button",
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(editControls, zoomControls);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       ok(CustomizableUI.inDefaultState, "Should still be in default state.");
     },
   },
   {
     desc: "Dragging the edit-controls to be before the new-window-button should " +
           "move the zoom-controls before the edit-controls.",
@@ -239,16 +247,17 @@ let gTests = [
                                  "privatebrowsing-button",
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(editControls, newWindowButton);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       let zoomControls = document.getElementById("zoom-controls");
       simulateItemDrag(editControls, zoomControls);
       ok(CustomizableUI.inDefaultState, "Should still be in default state.");
     },
   },
   {
@@ -265,16 +274,17 @@ let gTests = [
                                  "privatebrowsing-button",
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(editControls, privateBrowsingButton);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       let zoomControls = document.getElementById("zoom-controls");
       simulateItemDrag(editControls, zoomControls);
       ok(CustomizableUI.inDefaultState, "Should still be in default state.");
     },
   },
   {
@@ -291,16 +301,17 @@ let gTests = [
                                  "privatebrowsing-button",
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(editControls, savePageButton);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       let zoomControls = document.getElementById("zoom-controls");
       simulateItemDrag(editControls, zoomControls);
       ok(CustomizableUI.inDefaultState, "Should still be in default state.");
     },
   },
   {
@@ -316,16 +327,17 @@ let gTests = [
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button",
                                  "edit-controls"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(editControls, panel);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       let zoomControls = document.getElementById("zoom-controls");
       simulateItemDrag(editControls, zoomControls);
       ok(CustomizableUI.inDefaultState, "Should still be in default state.");
     },
   },
   {
@@ -340,16 +352,17 @@ let gTests = [
                                  "privatebrowsing-button",
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       let paletteChildElementCount = palette.childElementCount;
       simulateItemDrag(editControls, palette);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       is(paletteChildElementCount + 1, palette.childElementCount,
          "The palette should have a new child, congratulations!");
       is(editControls.parentNode.id, "wrapper-edit-controls",
          "The edit-controls should be properly wrapped.");
       is(editControls.parentNode.getAttribute("place"), "palette",
@@ -363,31 +376,33 @@ let gTests = [
   },
   {
     desc: "Dragging the edit-controls to each of the panel placeholders " +
           "should append the edit-controls to the bottom of the panel.",
     setup: startCustomizing,
     run: function() {
       let editControls = document.getElementById("edit-controls");
       let panel = document.getElementById(CustomizableUI.AREA_PANEL);
-      for (let i = 0; i < 3; i++) {
+      let numPlaceholders = isInWin8() ? 2 : 3;
+      for (let i = 0; i < numPlaceholders; i++) {
         // NB: We can't just iterate over all of the placeholders
         // because each drag-drop action recreates them.
         let placeholder = panel.getElementsByClassName("panel-customization-placeholder")[i];
         let placementsAfterMove = ["zoom-controls",
                                    "new-window-button",
                                    "privatebrowsing-button",
                                    "save-page-button",
                                    "print-button",
                                    "history-panelmenu",
                                    "fullscreen-button",
                                    "find-button",
                                    "preferences-button",
                                    "add-ons-button",
                                    "edit-controls"];
+        addSwitchToMetroButtonInWindows8(placementsAfterMove);
         simulateItemDrag(editControls, placeholder);
         assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
         let zoomControls = document.getElementById("zoom-controls");
         simulateItemDrag(editControls, zoomControls);
         ok(CustomizableUI.inDefaultState, "Should still be in default state.");
       }
     },
   },
@@ -420,21 +435,26 @@ let gTests = [
                                  "save-page-button",
                                  "print-button",
                                  "history-panelmenu",
                                  "fullscreen-button",
                                  "find-button",
                                  "preferences-button",
                                  "add-ons-button",
                                  "edit-controls"];
+      addSwitchToMetroButtonInWindows8(placementsAfterMove);
       simulateItemDrag(editControls, target);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
       let itemToDrag = "sync-button";
       let button = document.getElementById(itemToDrag);
-      placementsAfterMove.push(itemToDrag);
+      if (!isInWin8()) {
+        placementsAfterMove.push(itemToDrag);
+      } else {
+        placementsAfterMove.splice(11, 0, itemToDrag);
+      }
       simulateItemDrag(button, editControls);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
 
       // Put stuff back:
       let palette = document.getElementById("customization-palette");
       let zoomControls = document.getElementById("zoom-controls");
       simulateItemDrag(button, palette);
       simulateItemDrag(editControls, zoomControls);
--- a/browser/components/customizableui/test/browser_890140_orphaned_placeholders.js
+++ b/browser/components/customizableui/test/browser_890140_orphaned_placeholders.js
@@ -6,116 +6,155 @@ let gTests = [
   {
     desc: "One orphaned item should have two placeholders next to it.",
     setup: startCustomizing,
     run: function() {
       let btn = document.getElementById("developer-button");
       let panel = document.getElementById(CustomizableUI.AREA_PANEL);
       let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
 
-      let placementsAfterAppend = placements.concat(["developer-button"]);
-      simulateItemDrag(btn, panel);
-      assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
-      ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
+      if (!isInWin8()) {
+        placements = placements.concat(["developer-button"]);
+        simulateItemDrag(btn, panel);
+        ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
+      } else {
+        ok(CustomizableUI.inDefaultState, "Should be in default state.");
+      }
+
+      assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
       is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting");
 
       yield endCustomizing();
       yield startCustomizing();
       is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders after re-entering");
 
-      let palette = document.getElementById("customization-palette");
-      simulateItemDrag(btn, palette);
+      if (!isInWin8()) {
+        let palette = document.getElementById("customization-palette");
+        simulateItemDrag(btn, palette);
+      }
       ok(CustomizableUI.inDefaultState, "Should be in default state again.");
     },
   },
   {
     desc: "Two orphaned items should have one placeholder next to them (case 1).",
     setup: startCustomizing,
     run: function() {
       let btn = document.getElementById("developer-button");
       let panel = document.getElementById(CustomizableUI.AREA_PANEL);
       let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
 
-      let placementsAfterAppend = placements.concat(["developer-button", "sync-button"]);
+      let placementsAfterAppend = placements.concat(["developer-button"]);
       simulateItemDrag(btn, panel);
-      btn = document.getElementById("sync-button");
-      simulateItemDrag(btn, panel);
+
+      if (!isInWin8()) {
+        placementsAfterAppend = placementsAfterAppend.concat(["sync-button"]);
+        btn = document.getElementById("sync-button");
+        simulateItemDrag(btn, panel);
+      }
+
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
 
       yield endCustomizing();
       yield startCustomizing();
       is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders after re-entering");
 
       let palette = document.getElementById("customization-palette");
       simulateItemDrag(btn, palette);
-      btn = document.getElementById("developer-button");
-      simulateItemDrag(btn, palette);
+
+      if (!isInWin8()) {
+        btn = document.getElementById("developer-button");
+        simulateItemDrag(btn, palette);
+      }
       ok(CustomizableUI.inDefaultState, "Should be in default state again.");
     },
   },
   {
     desc: "Two orphaned items should have one placeholder next to them (case 2).",
     setup: startCustomizing,
     run: function() {
       let btn = document.getElementById("add-ons-button");
+      let btn2 = document.getElementById("switch-to-metro-button");
       let panel = document.getElementById(CustomizableUI.AREA_PANEL);
       let palette = document.getElementById("customization-palette");
       let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
 
       let placementsAfterAppend = placements.filter(p => p != btn.id);
       simulateItemDrag(btn, palette);
+
+      if (isInWin8()) {
+        placementsAfterAppend = placementsAfterAppend.filter(p => p != btn2.id);
+        simulateItemDrag(btn2, palette);
+      }
+
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders before exiting");
 
       yield endCustomizing();
       yield startCustomizing();
       is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholders after re-entering");
 
       simulateItemDrag(btn, panel);
+
+      if (isInWin8()) {
+        simulateItemDrag(btn2, panel);
+      }
+
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
       ok(CustomizableUI.inDefaultState, "Should be in default state again.");
     },
   },
   {
     desc: "A wide widget at the bottom of the panel should have three placeholders after it.",
     setup: startCustomizing,
     run: function() {
       let btn = document.getElementById("edit-controls");
+      let metroBtn = document.getElementById("switch-to-metro-button");
       let panel = document.getElementById(CustomizableUI.AREA_PANEL);
+      let palette = document.getElementById("customization-palette");
       let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
 
+      if (isInWin8()) {
+        // Remove switch-to-metro-button
+        placements.pop();
+        simulateItemDrag(metroBtn, palette);
+      }
+
       let placementsAfterAppend = placements.concat([placements.shift()]);
       simulateItemDrag(btn, panel);
       assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
       ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
       is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders before exiting");
 
       yield endCustomizing();
       yield startCustomizing();
       is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
 
+      if (isInWin8()) {
+        simulateItemDrag(metroBtn, panel);
+      }
       let zoomControls = document.getElementById("zoom-controls");
       simulateItemDrag(btn, zoomControls);
       ok(CustomizableUI.inDefaultState, "Should be in default state again.");
     },
   },
   {
-    desc: "The default placements should have three placeholders at the bottom.",
+    desc: "The default placements should have three placeholders at the bottom (or 2 in win8).",
     setup: startCustomizing,
     run: function() {
+      let numPlaceholders = isInWin8() ? 2 : 3;
       let panel = document.getElementById(CustomizableUI.AREA_PANEL);
       ok(CustomizableUI.inDefaultState, "Should be in default state.");
-      is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders before exiting");
+      is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting");
 
       yield endCustomizing();
       yield startCustomizing();
-      is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
+      is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders after re-entering");
 
       ok(CustomizableUI.inDefaultState, "Should still be in default state.");
     },
   },
 ];
 
 function asyncCleanup() {
   yield endCustomizing();
--- a/browser/components/customizableui/test/head.js
+++ b/browser/components/customizableui/test/head.js
@@ -49,16 +49,31 @@ function removeCustomToolbars() {
   }
   gAddedToolbars.clear();
 }
 
 function resetCustomization() {
   return CustomizableUI.reset();
 }
 
+function isInWin8() {
+  let sysInfo = Services.sysinfo;
+  let osName = sysInfo.getProperty("name");
+  let version = sysInfo.getProperty("version");
+
+  // Windows 8 is version >= 6.2
+  return osName == "Windows_NT" && version >= 6.2;
+}
+
+function addSwitchToMetroButtonInWindows8(areaPanelPlacements) {
+  if (isInWin8()) {
+    areaPanelPlacements.push("switch-to-metro-button");
+  }
+}
+
 function assertAreaPlacements(areaId, expectedPlacements) {
   let actualPlacements = getAreaWidgetIds(areaId);
   is(actualPlacements.length, expectedPlacements.length,
      "Area " + areaId + " should have " + expectedPlacements.length + " items.");
   let minItems = Math.min(expectedPlacements.length, actualPlacements.length);
   for (let i = 0; i < minItems; i++) {
     if (typeof expectedPlacements[i] == "string") {
       is(actualPlacements[i], expectedPlacements[i],