author | Gijs Kruitbosch <gijskruitbosch@gmail.com> |
Mon, 31 Jul 2017 18:26:38 +0100 | |
changeset 372893 | a8891e2183d071d2fb7bb7d7170a0b35420cfd6e |
parent 372892 | a8502931b53d010bc63224e4097fa4ba6b3251c6 |
child 372894 | 06eeb43124facd718fb95cf2a92b658902f32c4b |
push id | 48021 |
push user | gijskruitbosch@gmail.com |
push date | Fri, 04 Aug 2017 12:09:30 +0000 |
treeherder | autoland@4fb560842d16 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | adw |
bugs | 1354117 |
milestone | 57.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
|
--- a/browser/components/customizableui/test/browser.ini +++ b/browser/components/customizableui/test/browser.ini @@ -9,29 +9,27 @@ support-files = [browser_873501_handle_specials.js] [browser_876926_customize_mode_wrapping.js] [browser_876944_customize_mode_create_destroy.js] [browser_877006_missing_view.js] [browser_877178_unregisterArea.js] [browser_877447_skip_missing_ids.js] [browser_878452_drag_to_panel.js] [browser_880164_customization_context_menus.js] -[browser_880382_drag_wide_widgets_in_panel.js] [browser_884402_customize_from_overflow.js] skip-if = os == "linux" [browser_885052_customize_mode_observers_disabed.js] tags = fullscreen # Bug 951403 - Disabled on OSX for frequent failures skip-if = os == "mac" [browser_885530_showInPrivateBrowsing.js] [browser_886323_buildArea_removable_nodes.js] [browser_887438_currentset_shim.js] [browser_888817_currentset_updating.js] -[browser_890140_orphaned_placeholders.js] [browser_890262_destroyWidget_after_add_to_panel.js] [browser_892955_isWidgetRemovable_for_removed_widgets.js] [browser_892956_destroyWidget_defaultPlacements.js] [browser_909779_overflow_toolbars_new_window.js] skip-if = os == "linux" [browser_901207_searchbar_in_panel.js] [browser_913972_currentset_overflow.js]
--- a/browser/components/customizableui/test/browser_876926_customize_mode_wrapping.js +++ b/browser/components/customizableui/test/browser_876926_customize_mode_wrapping.js @@ -1,17 +1,17 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const kXULWidgetId = "a-test-button"; // we'll create a button with this ID. const kAPIWidgetId = "feed-button"; -const kPanel = CustomizableUI.AREA_PANEL; +const kPanel = CustomizableUI.AREA_FIXED_OVERFLOW_PANEL; const kToolbar = CustomizableUI.AREA_NAVBAR; const kVisiblePalette = "customization-palette"; const kPlaceholderClass = "panel-customization-placeholder"; function checkWrapper(id) { is(document.querySelectorAll("#wrapper-" + id).length, 1, "There should be exactly 1 wrapper for " + id + " in the customizing window."); } @@ -150,37 +150,48 @@ function createXULButtonForWindow(win) { function removeXULButtonForWindow(win) { win.gNavToolbox.palette.querySelector(`#${kXULWidgetId}`).remove(); } var otherWin; // Moving widgets in two windows, one with customize mode and one without, should work. add_task(async function MoveWidgetsInTwoWindows() { - await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]}); + CustomizableUI.createWidget({ + id: "cui-mode-wrapping-some-panel-item", + label: "Test panel wrapping", + }); await startCustomizing(); otherWin = await openAndLoadWindow(null, true); await otherWin.PanelUI.ensureReady(); // Create the XUL button to use in the test in both windows. createXULButtonForWindow(window); createXULButtonForWindow(otherWin); ok(CustomizableUI.inDefaultState, "Should start in default state"); for (let widgetId of [kXULWidgetId, kAPIWidgetId]) { for (let method of ["API", "drag", "dragToItem"]) { info("Moving widget " + widgetId + " using " + method); checkToolbar(widgetId, method); + // We add an item to the panel because otherwise we can't test dragging + // to items that are already there. We remove it because + // 'checkPalette' checks that we leave the browser in the default state. + CustomizableUI.addWidgetToArea("cui-mode-wrapping-some-panel-item", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); checkPanel(widgetId, method); + CustomizableUI.removeWidgetFromArea("cui-mode-wrapping-some-panel-item"); checkPalette(widgetId, method); + CustomizableUI.addWidgetToArea("cui-mode-wrapping-some-panel-item", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); checkPanel(widgetId, method); checkToolbar(widgetId, method); + CustomizableUI.removeWidgetFromArea("cui-mode-wrapping-some-panel-item"); checkPalette(widgetId, method); } } await promiseWindowClosed(otherWin); otherWin = null; await endCustomizing(); removeXULButtonForWindow(window); }); add_task(async function asyncCleanup() { + CustomizableUI.destroyWidget("cui-mode-wrapping-some-panel-item"); await resetCustomization(); });
--- a/browser/components/customizableui/test/browser_876944_customize_mode_create_destroy.js +++ b/browser/components/customizableui/test/browser_876944_customize_mode_create_destroy.js @@ -1,65 +1,32 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const kTestWidget1 = "test-customize-mode-create-destroy1"; -const kTestWidget2 = "test-customize-mode-create-destroy2"; // Creating and destroying a widget should correctly wrap/unwrap stuff add_task(async function testWrapUnwrap() { - await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]}); await startCustomizing(); CustomizableUI.createWidget({id: kTestWidget1, label: "Pretty label", tooltiptext: "Pretty tooltip"}); let elem = document.getElementById(kTestWidget1); let wrapper = document.getElementById("wrapper-" + kTestWidget1); ok(elem, "There should be an item"); ok(wrapper, "There should be a wrapper"); is(wrapper.firstChild.id, kTestWidget1, "Wrapper should have test widget"); is(wrapper.parentNode.id, "customization-palette", "Wrapper should be in palette"); CustomizableUI.destroyWidget(kTestWidget1); wrapper = document.getElementById("wrapper-" + kTestWidget1); ok(!wrapper, "There should be a wrapper"); let item = document.getElementById(kTestWidget1); ok(!item, "There should no longer be an item"); }); -// Creating and destroying a widget should correctly deal with panel placeholders -add_task(async function testPanelPlaceholders() { - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - // The value of expectedPlaceholders depends on the default palette layout. - // Bug 1229236 is for these tests to be smarter so the test doesn't need to - // change when the default placements change. - let expectedPlaceholders = 1; - if (isInNightly()) { - expectedPlaceholders += 2; - } - is(panel.querySelectorAll(".panel-customization-placeholder").length, expectedPlaceholders, "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"); - expectedPlaceholders = (expectedPlaceholders - 1) || 3; - is(panel.querySelectorAll(".panel-customization-placeholder").length, expectedPlaceholders, "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"); - await endCustomizing(); -}); - add_task(async function asyncCleanup() { await endCustomizing(); try { CustomizableUI.destroyWidget(kTestWidget1); } catch (ex) {} - try { - CustomizableUI.destroyWidget(kTestWidget2); - } catch (ex) {} await resetCustomization(); });
--- a/browser/components/customizableui/test/browser_878452_drag_to_panel.js +++ b/browser/components/customizableui/test/browser_878452_drag_to_panel.js @@ -1,64 +1,67 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +CustomizableUI.createWidget({id: "cui-panel-item-to-drag-to", defaultArea: CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, label: "Item in panel to drag to"}); // Dragging an item from the palette to another button in the panel should work. add_task(async function() { - await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]}); await startCustomizing(); let btn = document.getElementById("feed-button"); - let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); + let placements = getAreaWidgetIds(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); let lastButtonIndex = placements.length - 1; let lastButton = placements[lastButtonIndex]; let placementsAfterInsert = placements.slice(0, lastButtonIndex).concat(["feed-button", lastButton]); let lastButtonNode = document.getElementById(lastButton); simulateItemDrag(btn, lastButtonNode); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert); + assertAreaPlacements(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, placementsAfterInsert); ok(!CustomizableUI.inDefaultState, "Should no longer be in default state."); let palette = document.getElementById("customization-palette"); simulateItemDrag(btn, palette); + CustomizableUI.removeWidgetFromArea("cui-panel-item-to-drag-to"); ok(CustomizableUI.inDefaultState, "Should be in default state again."); }); // Dragging an item from the palette to the panel itself should also work. add_task(async function() { + CustomizableUI.addWidgetToArea("cui-panel-item-to-drag-to", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); await startCustomizing(); let btn = document.getElementById("feed-button"); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); + let panel = document.getElementById(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); + let placements = getAreaWidgetIds(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); let placementsAfterAppend = placements.concat(["feed-button"]); simulateItemDrag(btn, panel); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend); + assertAreaPlacements(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, placementsAfterAppend); ok(!CustomizableUI.inDefaultState, "Should no longer be in default state."); let palette = document.getElementById("customization-palette"); simulateItemDrag(btn, palette); + CustomizableUI.removeWidgetFromArea("cui-panel-item-to-drag-to"); ok(CustomizableUI.inDefaultState, "Should be in default state again."); }); // Dragging an item from the palette to an empty panel should also work. add_task(async function() { - let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_PANEL); + let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); while (widgetIds.length) { CustomizableUI.removeWidgetFromArea(widgetIds.shift()); } await startCustomizing(); let btn = document.getElementById("feed-button"); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); + let panel = document.getElementById(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL); assertAreaPlacements(panel.id, []); let placementsAfterAppend = ["feed-button"]; simulateItemDrag(btn, panel); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend); + assertAreaPlacements(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, placementsAfterAppend); ok(!CustomizableUI.inDefaultState, "Should no longer be in default state."); let palette = document.getElementById("customization-palette"); simulateItemDrag(btn, palette); assertAreaPlacements(panel.id, []); }); add_task(async function asyncCleanup() { await endCustomizing();
deleted file mode 100644 --- a/browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js +++ /dev/null @@ -1,520 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -requestLongerTimeout(5); - -// Dragging the zoom controls to be before the print button should not move any controls. -add_task(async function() { - await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]}); - await startCustomizing(); - let zoomControls = document.getElementById("zoom-controls"); - let printButton = document.getElementById("print-button"); - let placementsAfterMove = ["edit-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "zoom-controls", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(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."); -}); - -// Dragging the zoom controls to be before the save button should not move any controls. -add_task(async function() { - await startCustomizing(); - let zoomControls = document.getElementById("zoom-controls"); - let savePageButton = document.getElementById("save-page-button"); - let placementsAfterMove = ["edit-controls", - "zoom-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(placementsAfterMove); - simulateItemDrag(zoomControls, savePageButton); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); - ok(CustomizableUI.inDefaultState, "Should be in default state."); -}); - - -// Dragging the zoom controls to be before the new-window button should not move any widgets. -add_task(async function() { - await startCustomizing(); - let zoomControls = document.getElementById("zoom-controls"); - let newWindowButton = document.getElementById("new-window-button"); - let placementsAfterMove = ["edit-controls", - "zoom-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(placementsAfterMove); - simulateItemDrag(zoomControls, newWindowButton); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); - ok(CustomizableUI.inDefaultState, "Should still be in default state."); -}); - -// Dragging the zoom controls to be before the history-panelmenu should move the zoom-controls in to the row higher than the history-panelmenu. -add_task(async function() { - await startCustomizing(); - let zoomControls = document.getElementById("zoom-controls"); - let historyPanelMenu = document.getElementById("history-panelmenu"); - let placementsAfterMove = ["edit-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "zoom-controls", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(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."); -}); - -// Dragging the zoom controls to be before the preferences-button should move the zoom-controls -// in to the row higher than the preferences-button. -add_task(async function() { - await startCustomizing(); - let zoomControls = document.getElementById("zoom-controls"); - let preferencesButton = document.getElementById("preferences-button"); - let placementsAfterMove = ["edit-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "zoom-controls", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(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."); -}); - -// Dragging an item from the palette to before the zoom-controls should move it and two other buttons before the zoom controls. -add_task(async function() { - await startCustomizing(); - let openFileButton = document.getElementById("open-file-button"); - let zoomControls = document.getElementById("zoom-controls"); - let placementsAfterInsert = ["edit-controls", - "open-file-button", - "new-window-button", - "privatebrowsing-button", - "zoom-controls", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(placementsAfterInsert); - simulateItemDrag(openFileButton, 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, - "feed-button should be a child of wrapper-feed-button"); - is(feedWrapper.getAttribute("place"), "palette", - "The feed-button wrapper should have it's place set to 'palette'"); - simulateItemDrag(openFileButton, palette); - is(openFileButton.parentNode.tagName, "toolbarpaletteitem", - "The open-file-button should be wrapped by a toolbarpaletteitem"); - let newWindowButton = document.getElementById("new-window-button"); - simulateItemDrag(zoomControls, newWindowButton); - ok(CustomizableUI.inDefaultState, "Should be in default state again."); -}); - -// Dragging an item from the palette to before the edit-controls -// should move it and two other buttons before the edit and zoom controls. -add_task(async function() { - await startCustomizing(); - let openFileButton = document.getElementById("open-file-button"); - let editControls = document.getElementById("edit-controls"); - let placementsAfterInsert = ["open-file-button", - "new-window-button", - "privatebrowsing-button", - "edit-controls", - "zoom-controls", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(placementsAfterInsert); - simulateItemDrag(openFileButton, 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, - "feed-button should be a child of wrapper-feed-button"); - is(feedWrapper.getAttribute("place"), "palette", - "The feed-button wrapper should have it's place set to 'palette'"); - simulateItemDrag(openFileButton, palette); - is(openFileButton.parentNode.tagName, "toolbarpaletteitem", - "The open-file-button should be wrapped by a toolbarpaletteitem"); - ok(CustomizableUI.inDefaultState, "Should be in default state again."); -}); - -// Dragging the edit-controls to be before the zoom-controls button -// should not move any widgets. -add_task(async function() { - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let zoomControls = document.getElementById("zoom-controls"); - let placementsAfterMove = ["edit-controls", - "zoom-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(placementsAfterMove); - simulateItemDrag(editControls, zoomControls); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); - ok(CustomizableUI.inDefaultState, "Should still be in default state."); -}); - -// Dragging the edit-controls to be before the new-window-button should -// move the zoom-controls before the edit-controls. -add_task(async function() { - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let newWindowButton = document.getElementById("new-window-button"); - let placementsAfterMove = ["zoom-controls", - "edit-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(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."); -}); - -// Dragging the edit-controls to be before the privatebrowsing-button -// should move the edit-controls in to the row higher than the -// privatebrowsing-button. -add_task(async function() { - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let privateBrowsingButton = document.getElementById("privatebrowsing-button"); - let placementsAfterMove = ["zoom-controls", - "edit-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(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."); -}); - -// Dragging the edit-controls to be before the save-page-button -// should move the edit-controls in to the row higher than the -// save-page-button. -add_task(async function() { - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let savePageButton = document.getElementById("save-page-button"); - let placementsAfterMove = ["zoom-controls", - "edit-controls", - "new-window-button", - "privatebrowsing-button", - "save-page-button", - "print-button", - "history-panelmenu", - "fullscreen-button", - "find-button", - "preferences-button", - "add-ons-button", - "developer-button", - "sync-button", - "webcompat-reporter-button" - ]; - removeNonReleaseButtons(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."); -}); - -// Dragging the edit-controls to the panel itself should append -// the edit controls to the bottom of the panel. -add_task(async function editControlsToPanelEmptySpace() { - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - 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", - "developer-button", - "sync-button", - ]; - removeNonReleaseButtons(placementsAfterMove); - if (isNotReleaseOrBeta()) { - CustomizableUI.removeWidgetFromArea("webcompat-reporter-button"); - } - simulateItemDrag(editControls, panel); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); - let zoomControls = document.getElementById("zoom-controls"); - simulateItemDrag(editControls, zoomControls); - if (isNotReleaseOrBeta()) { - CustomizableUI.addWidgetToArea("webcompat-reporter-button", CustomizableUI.AREA_PANEL); - } - ok(CustomizableUI.inDefaultState, "Should still be in default state."); -}); - -// Dragging the edit-controls to the customization-palette and -// back should work. -add_task(async function() { - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let palette = document.getElementById("customization-palette"); - 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", - "developer-button", - "sync-button", - "webcompat-reporter-button", - ]; - removeNonReleaseButtons(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", - "The edit-controls should have the place of 'palette'."); - let zoomControls = document.getElementById("zoom-controls"); - simulateItemDrag(editControls, zoomControls); - is(paletteChildElementCount, palette.childElementCount, - "The palette child count should have returned to its prior value."); - ok(CustomizableUI.inDefaultState, "Should still be in default state."); -}); - -// Dragging the edit-controls to each of the panel placeholders -// should append the edit-controls to the bottom of the panel. -add_task(async function editControlsToPanelPlaceholders() { - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - let numPlaceholders = 2; - for (let i = 0; i < numPlaceholders; i++) { - // This test relies on there being a specific number of widgets in the - // panel. The addition of sync-button and webcompat-reporter-button screwed - // this up, so we remove them here. We should either fix the tests to not - // rely on the specific layout, or fix bug 1007910 which would change the - // placeholder logic in different ways. Bug 1229236 is for these tests to - // be smarter. - removeNonOriginalButtons(); - // 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", - "developer-button", - ]; - removeNonReleaseButtons(placementsAfterMove); - simulateItemDrag(editControls, placeholder); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); - let zoomControls = document.getElementById("zoom-controls"); - simulateItemDrag(editControls, zoomControls); - restoreNonOriginalButtons(); - ok(CustomizableUI.inDefaultState, "Should still be in default state."); - } -}); - -// Dragging the open-file-button back on to itself should work. -add_task(async function() { - await startCustomizing(); - let openFileButton = document.getElementById("open-file-button"); - is(openFileButton.parentNode.tagName, "toolbarpaletteitem", - "open-file-button should be wrapped by a toolbarpaletteitem"); - simulateItemDrag(openFileButton, openFileButton); - is(openFileButton.parentNode.tagName, "toolbarpaletteitem", - "open-file-button should be wrapped by a toolbarpaletteitem"); - let editControls = document.getElementById("edit-controls"); - is(editControls.parentNode.tagName, "toolbarpaletteitem", - "edit-controls should be wrapped by a toolbarpaletteitem"); - ok(CustomizableUI.inDefaultState, "Should still be in default state."); -}); - -// Dragging a small button onto the last big button should work. -add_task(async function() { - // Bug 1007910 requires there be a placeholder on the final row for this - // test to work as written. The addition of sync-button and - // webcompat-reporter-button meant that's not true so we remove them from - // here. Bug 1229236 is for these tests to be smarter. - removeNonOriginalButtons(); - await startCustomizing(); - let editControls = document.getElementById("edit-controls"); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - let target = panel.getElementsByClassName("panel-customization-placeholder")[0]; - 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", - "developer-button", - ]; - removeNonReleaseButtons(placementsAfterMove); - simulateItemDrag(editControls, target); - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove); - let itemToDrag = "email-link-button"; // any button in the palette by default. - let button = document.getElementById(itemToDrag); - 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); - restoreNonOriginalButtons(); - ok(CustomizableUI.inDefaultState, "Should be in default state again."); -}); - -add_task(async function asyncCleanup() { - await endCustomizing(); - await resetCustomization(); -});
deleted file mode 100644 --- a/browser/components/customizableui/test/browser_890140_orphaned_placeholders.js +++ /dev/null @@ -1,211 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -requestLongerTimeout(2); - -// One orphaned item should have two placeholders next to it. -add_task(async function() { - await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]}); - await startCustomizing(); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL); - ok(!CustomizableUI.inDefaultState, "Should no longer be in default state."); - } - if (!isInDevEdition()) { - ok(CustomizableUI.inDefaultState, "Should be in default state."); - } else { - ok(!CustomizableUI.inDefaultState, "Should not be in default state if on DevEdition."); - } - - // This test relies on an exact number of widgets being in the panel. - // Remove the buttons to satisfy that. (bug 1229236) - removeNonOriginalButtons(); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); - - assertAreaPlacements(CustomizableUI.AREA_PANEL, placements); - is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting"); - - await endCustomizing(); - await startCustomizing(); - is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders after re-entering"); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2); - } - - restoreNonOriginalButtons(); - ok(CustomizableUI.inDefaultState, "Should be in default state again."); -}); - -// Two orphaned items should have one placeholder next to them (case 1). -add_task(async function() { - await startCustomizing(); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL); - } - - // This test relies on an exact number of widgets being in the panel. - // Remove the button to satisfy that. (bug 1229236) - removeNonOriginalButtons() - - let btn = document.getElementById("open-file-button"); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); - let placementsAfterAppend = placements; - - placementsAfterAppend = placements.concat(["open-file-button"]); - simulateItemDrag(btn, panel); - - assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend); - - ok(!CustomizableUI.inDefaultState, "Should not be in default state."); - - is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder before exiting"); - - await endCustomizing(); - await startCustomizing(); - is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder after re-entering"); - - let palette = document.getElementById("customization-palette"); - simulateItemDrag(btn, palette); - - btn = document.getElementById("open-file-button"); - simulateItemDrag(btn, palette); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2); - } - - restoreNonOriginalButtons(); - ok(CustomizableUI.inDefaultState, "Should be in default state again."); -}); - -// Two orphaned items should have one placeholder next to them (case 2). -add_task(async function() { - await startCustomizing(); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL); - } - // This test relies on an exact number of widgets being in the panel. - // Remove the buttons to satisfy that. (bug 1229236) - removeNonOriginalButtons(); - - let btn = document.getElementById("add-ons-button"); - let btn2 = document.getElementById("developer-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 && p != btn2.id); - simulateItemDrag(btn, palette); - 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 placeholder before exiting"); - - await endCustomizing(); - await startCustomizing(); - is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder after re-entering"); - - simulateItemDrag(btn, panel); - simulateItemDrag(btn2, panel); - - assertAreaPlacements(CustomizableUI.AREA_PANEL, placements); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2); - } - - restoreNonOriginalButtons(); - ok(CustomizableUI.inDefaultState, "Should be in default state again."); -}); - -// A wide widget at the bottom of the panel should have three placeholders after it. -add_task(async function() { - await startCustomizing(); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL); - } - - // This test relies on an exact number of widgets being in the panel. - // Remove the buttons to satisfy that. (bug 1229236) - removeNonOriginalButtons(); - - let btn = document.getElementById("edit-controls"); - let btn2 = document.getElementById("developer-button"); - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - let palette = document.getElementById("customization-palette"); - let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL); - - placements.pop(); - simulateItemDrag(btn2, 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"); - - await endCustomizing(); - await startCustomizing(); - is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering"); - - simulateItemDrag(btn2, panel); - - let zoomControls = document.getElementById("zoom-controls"); - simulateItemDrag(btn, zoomControls); - - if (isInDevEdition()) { - CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2); - } - - restoreNonOriginalButtons(); - ok(CustomizableUI.inDefaultState, "Should be in default state again."); -}); - -// The default placements should have two placeholders at the bottom (or 1 in win8). -add_task(async function() { - await startCustomizing(); - let numPlaceholders = -1; - - if (isInDevEdition()) { - numPlaceholders = 3; - } else { - numPlaceholders = 2; - } - - let panel = document.getElementById(CustomizableUI.AREA_PANEL); - ok(CustomizableUI.inDefaultState, "Should be in default state."); - - // This test relies on an exact number of widgets being in the panel. - // Remove the buttons to satisfy that. (bug 1229236) - removeNonOriginalButtons(); - - is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting"); - - await endCustomizing(); - await startCustomizing(); - is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders after re-entering"); - - restoreNonOriginalButtons(); - ok(CustomizableUI.inDefaultState, "Should still be in default state."); -}); - -add_task(async function asyncCleanup() { - await endCustomizing(); - await resetCustomization(); -}); - -function getVisiblePlaceholderCount(aPanel) { - let visiblePlaceholders = aPanel.querySelectorAll(".panel-customization-placeholder:not([hidden=true])"); - return visiblePlaceholders.length; -}