This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1518500 - ensure we don't end up without a flexible space if movi…
…ng items directly to toolbars, r=dao Before this patch, we change aDraggedItemId somewhat late in the _applyDrop method - significantly, we do this after the aTargetNode == areaCustomizationTarget check. So we end up bailing out before adjusting aDraggedItemId, and we add the specific dummy item from the palette into the toolbar, rather than adding a new spring to the toolbar, and leaving the existing palette item alone. Simply moving this adjustment to aDraggedItemId earlier into the method is sufficient to fix the issue at hand. Differential Revision: https://phabricator.services.mozilla.com/D62948
- Loading branch information
Showing
3 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
browser/components/customizableui/test/browser_flexible_space_area.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
|
||
function getSpringCount(area) { | ||
return CustomizableUI.getWidgetIdsInArea(area).filter(id => | ||
id.includes("spring") | ||
).length; | ||
} | ||
|
||
/** | ||
* Check that no matter where we add a flexible space, we | ||
* never end up without a flexible space in the palette. | ||
*/ | ||
add_task(async function test_flexible_space_addition() { | ||
await startCustomizing(); | ||
let palette = document.getElementById("customization-palette"); | ||
// Make the bookmarks toolbar visible: | ||
CustomizableUI.setToolbarVisibility(CustomizableUI.AREA_BOOKMARKS, true); | ||
let areas = [CustomizableUI.AREA_NAVBAR, CustomizableUI.AREA_BOOKMARKS]; | ||
if (AppConstants.platform != "macosx") { | ||
areas.push(CustomizableUI.AREA_MENUBAR); | ||
} | ||
|
||
for (let area of areas) { | ||
let spacer = palette.querySelector("toolbarspring"); | ||
let toolbar = document.getElementById(area); | ||
toolbar = CustomizableUI.getCustomizationTarget(toolbar); | ||
|
||
let springCount = getSpringCount(area); | ||
simulateItemDrag(spacer, toolbar); | ||
// Check we added the spring: | ||
is( | ||
springCount + 1, | ||
getSpringCount(area), | ||
"Should now have an extra spring" | ||
); | ||
|
||
// Check there's still one in the palette: | ||
let newSpacer = palette.querySelector("toolbarspring"); | ||
ok(newSpacer, "Should have created a new spring"); | ||
} | ||
}); | ||
registerCleanupFunction(async function asyncCleanup() { | ||
await endCustomizing(); | ||
await resetCustomization(); | ||
}); |