Backed out changeset 6aee7a646f7e (bug 1014332)

This commit is contained in:
Ed Morley 2014-08-21 12:27:19 +01:00
Родитель 59f76a94a9
Коммит bae6f10a73
4 изменённых файлов: 47 добавлений и 65 удалений

Просмотреть файл

@ -166,7 +166,6 @@ let CustomizableUIInternal = {
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button",
"social-share-button",
]; ];
if (gPalette.has("switch-to-metro-button")) { if (gPalette.has("switch-to-metro-button")) {
@ -208,6 +207,7 @@ let CustomizableUIInternal = {
"downloads-button", "downloads-button",
"home-button", "home-button",
"loop-call-button", "loop-call-button",
"social-share-button",
], ],
defaultCollapsed: false, defaultCollapsed: false,
}, true); }, true);

Просмотреть файл

@ -27,7 +27,7 @@ add_task(function testWrapUnwrap() {
// Creating and destroying a widget should correctly deal with panel placeholders // Creating and destroying a widget should correctly deal with panel placeholders
add_task(function testPanelPlaceholders() { add_task(function testPanelPlaceholders() {
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 3 : 1, "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.createWidget({id: kTestWidget2, label: 'Pretty label', tooltiptext: 'Pretty tooltip', defaultArea: CustomizableUI.AREA_PANEL}); CustomizableUI.createWidget({id: kTestWidget2, label: 'Pretty label', tooltiptext: 'Pretty tooltip', defaultArea: CustomizableUI.AREA_PANEL});
let elem = document.getElementById(kTestWidget2); let elem = document.getElementById(kTestWidget2);
let wrapper = document.getElementById("wrapper-" + kTestWidget2); let wrapper = document.getElementById("wrapper-" + kTestWidget2);
@ -35,7 +35,7 @@ add_task(function testPanelPlaceholders() {
ok(wrapper, "There should be a wrapper"); ok(wrapper, "There should be a wrapper");
is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget"); is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget");
is(wrapper.parentNode, panel, "Wrapper should be in panel"); is(wrapper.parentNode, panel, "Wrapper should be in panel");
is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 2 : 3, "The number of placeholders should be correct."); is(panel.querySelectorAll(".panel-customization-placeholder").length, isInWin8() ? 3 : 1, "The number of placeholders should be correct.");
CustomizableUI.destroyWidget(kTestWidget2); CustomizableUI.destroyWidget(kTestWidget2);
wrapper = document.getElementById("wrapper-" + kTestWidget2); wrapper = document.getElementById("wrapper-" + kTestWidget2);
ok(!wrapper, "There should be a wrapper"); ok(!wrapper, "There should be a wrapper");

Просмотреть файл

@ -22,8 +22,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, printButton); simulateItemDrag(zoomControls, printButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -49,8 +48,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, savePageButton); simulateItemDrag(zoomControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -74,8 +72,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, newWindowButton); simulateItemDrag(zoomControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -98,8 +95,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, historyPanelMenu); simulateItemDrag(zoomControls, historyPanelMenu);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -126,8 +122,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, preferencesButton); simulateItemDrag(zoomControls, preferencesButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -154,8 +149,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert); addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(openFileButton, zoomControls); simulateItemDrag(openFileButton, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
@ -194,8 +188,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterInsert); addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(openFileButton, editControls); simulateItemDrag(openFileButton, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
@ -231,8 +224,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, zoomControls); simulateItemDrag(editControls, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -256,8 +248,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, newWindowButton); simulateItemDrag(editControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -284,8 +275,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, privateBrowsingButton); simulateItemDrag(editControls, privateBrowsingButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -312,8 +302,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, savePageButton); simulateItemDrag(editControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -339,8 +328,7 @@ add_task(function() {
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"edit-controls", "edit-controls",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, panel); simulateItemDrag(editControls, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -365,8 +353,7 @@ add_task(function() {
"find-button", "find-button",
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
let paletteChildElementCount = palette.childElementCount; let paletteChildElementCount = palette.childElementCount;
simulateItemDrag(editControls, palette); simulateItemDrag(editControls, palette);
@ -390,8 +377,7 @@ add_task(function() {
yield startCustomizing(); yield startCustomizing();
let editControls = document.getElementById("edit-controls"); let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let numPlaceholders = isInWin8() ? 3 : 1; let numPlaceholders = isInWin8() ? 1 : 2;
is(numPlaceholders, panel.getElementsByClassName("panel-customization-placeholder").length, "correct number of placeholders");
for (let i = 0; i < numPlaceholders; i++) { for (let i = 0; i < numPlaceholders; i++) {
// NB: We can't just iterate over all of the placeholders // NB: We can't just iterate over all of the placeholders
// because each drag-drop action recreates them. // because each drag-drop action recreates them.
@ -407,8 +393,7 @@ add_task(function() {
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"edit-controls", "edit-controls",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, placeholder); simulateItemDrag(editControls, placeholder);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -438,8 +423,6 @@ add_task(function() {
yield startCustomizing(); yield startCustomizing();
let editControls = document.getElementById("edit-controls"); let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let numPlaceholders = isInWin8() ? 3 : 1;
is(panel.getElementsByClassName("panel-customization-placeholder").length, numPlaceholders, "correct number of placeholders");
let target = panel.getElementsByClassName("panel-customization-placeholder")[0]; let target = panel.getElementsByClassName("panel-customization-placeholder")[0];
let placementsAfterMove = ["zoom-controls", let placementsAfterMove = ["zoom-controls",
"new-window-button", "new-window-button",
@ -452,22 +435,18 @@ add_task(function() {
"preferences-button", "preferences-button",
"add-ons-button", "add-ons-button",
"edit-controls", "edit-controls",
"developer-button", "developer-button"];
"social-share-button"];
addSwitchToMetroButtonInWindows8(placementsAfterMove); addSwitchToMetroButtonInWindows8(placementsAfterMove);
if (isInWin8()) {
placementsAfterMove.splice(10, 1);
placementsAfterMove.push("edit-controls");
}
simulateItemDrag(editControls, target); simulateItemDrag(editControls, target);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let itemToDrag = "sync-button"; let itemToDrag = "sync-button";
let button = document.getElementById(itemToDrag); let button = document.getElementById(itemToDrag);
placementsAfterMove.splice(11, 0, itemToDrag);
if (isInWin8()) { if (isInWin8()) {
placementsAfterMove.push(itemToDrag); placementsAfterMove[10] = placementsAfterMove[11];
} else { placementsAfterMove[11] = placementsAfterMove[12];
placementsAfterMove.splice(10, 1, itemToDrag); placementsAfterMove[12] = placementsAfterMove[13];
placementsAfterMove.push("edit-controls"); placementsAfterMove[13] = "edit-controls";
} }
simulateItemDrag(button, editControls); simulateItemDrag(button, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);

Просмотреть файл

@ -11,13 +11,15 @@ add_task(function() {
yield startCustomizing(); yield startCustomizing();
let btn = document.getElementById("open-file-button"); let btn = document.getElementById("open-file-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
CustomizableUI.removeWidgetFromArea("social-share-button");
if (isInWin8()) { if (isInWin8()) {
CustomizableUI.removeWidgetFromArea("switch-to-metro-button"); CustomizableUI.removeWidgetFromArea("switch-to-metro-button");
placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
} else {
ok(CustomizableUI.inDefaultState, "Should be in default state.");
} }
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements); assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting"); is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting");
@ -26,7 +28,6 @@ add_task(function() {
yield startCustomizing(); yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders after re-entering"); is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders after re-entering");
CustomizableUI.addWidgetToArea("social-share-button", CustomizableUI.AREA_PANEL);
if (isInWin8()) { if (isInWin8()) {
CustomizableUI.addWidgetToArea("switch-to-metro-button", CustomizableUI.AREA_PANEL); CustomizableUI.addWidgetToArea("switch-to-metro-button", CustomizableUI.AREA_PANEL);
} }
@ -38,7 +39,6 @@ add_task(function() {
yield startCustomizing(); yield startCustomizing();
let btn = document.getElementById("open-file-button"); let btn = document.getElementById("open-file-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
CustomizableUI.removeWidgetFromArea("social-share-button");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
let placementsAfterAppend = placements; let placementsAfterAppend = placements;
@ -49,7 +49,7 @@ add_task(function() {
} }
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
ok(!CustomizableUI.inDefaultState, "Should not be in default state"); is(CustomizableUI.inDefaultState, isInWin8(), "Should only be in default state if on Win8");
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder before exiting"); is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder before exiting");
yield endCustomizing(); yield endCustomizing();
@ -63,24 +63,26 @@ add_task(function() {
btn = document.getElementById("open-file-button"); btn = document.getElementById("open-file-button");
simulateItemDrag(btn, palette); simulateItemDrag(btn, palette);
} }
CustomizableUI.addWidgetToArea("social-share-button", CustomizableUI.AREA_PANEL);
ok(CustomizableUI.inDefaultState, "Should be in default state again."); ok(CustomizableUI.inDefaultState, "Should be in default state again.");
}); });
// Two orphaned items should have one placeholder next to them (case 2). // Two orphaned items should have one placeholder next to them (case 2).
add_task(function() { add_task(function() {
yield startCustomizing(); yield startCustomizing();
let buttonsToMove = ["add-ons-button", "developer-button", "social-share-button"]; let btn = document.getElementById("add-ons-button");
if (isInWin8()) { let btn2 = document.getElementById("developer-button");
buttonsToMove.push("switch-to-metro-button"); let btn3 = document.getElementById("switch-to-metro-button");
}
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette"); let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
let placementsAfterAppend = placements.filter(p => buttonsToMove.indexOf(p) < 0); let placementsAfterAppend = placements.filter(p => p != btn.id && p != btn2.id);
for (let i in buttonsToMove) { simulateItemDrag(btn, palette);
CustomizableUI.removeWidgetFromArea(buttonsToMove[i]); simulateItemDrag(btn2, palette);
if (isInWin8()) {
placementsAfterAppend = placementsAfterAppend.filter(p => p != btn3.id);
simulateItemDrag(btn3, palette);
} }
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend); assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
@ -91,8 +93,11 @@ add_task(function() {
yield startCustomizing(); yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder after re-entering"); is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder after re-entering");
for (let i in buttonsToMove) { simulateItemDrag(btn, panel);
CustomizableUI.addWidgetToArea(buttonsToMove[i], CustomizableUI.AREA_PANEL); simulateItemDrag(btn2, panel);
if (isInWin8()) {
simulateItemDrag(btn3, panel);
} }
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements); assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
@ -107,7 +112,6 @@ add_task(function() {
let metroBtn = document.getElementById("switch-to-metro-button"); let metroBtn = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette"); let palette = document.getElementById("customization-palette");
CustomizableUI.removeWidgetFromArea("social-share-button");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
placements.pop(); placements.pop();
@ -129,7 +133,6 @@ add_task(function() {
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering"); is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
simulateItemDrag(developerButton, panel); simulateItemDrag(developerButton, panel);
CustomizableUI.addWidgetToArea("social-share-button", CustomizableUI.AREA_PANEL);
if (isInWin8()) { if (isInWin8()) {
simulateItemDrag(metroBtn, panel); simulateItemDrag(metroBtn, panel);
} }
@ -138,10 +141,10 @@ add_task(function() {
ok(CustomizableUI.inDefaultState, "Should be in default state again."); ok(CustomizableUI.inDefaultState, "Should be in default state again.");
}); });
// The default placements should have one placeholder at the bottom (or 3 in metro-enabled win8). // The default placements should have two placeholders at the bottom (or 1 in win8).
add_task(function() { add_task(function() {
yield startCustomizing(); yield startCustomizing();
let numPlaceholders = isInWin8() ? 3 : 1; let numPlaceholders = isInWin8() ? 1 : 2;
let panel = document.getElementById(CustomizableUI.AREA_PANEL); let panel = document.getElementById(CustomizableUI.AREA_PANEL);
ok(CustomizableUI.inDefaultState, "Should be in default state."); ok(CustomizableUI.inDefaultState, "Should be in default state.");
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting"); is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting");