mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 890262 - destroyWidget shouldn't throw an exception when the widget is in a non-built area, r=mconley
--HG-- extra : rebase_source : ec36ef644e38ab87413fe79ac86516b680a74a44
This commit is contained in:
parent
7e8383e273
commit
cd19ca2203
@ -1508,9 +1508,9 @@ let CustomizableUIInternal = {
|
||||
// returns.
|
||||
|
||||
let area = widget.currentArea;
|
||||
if (area) {
|
||||
let buildArea = gBuildAreas.get(area);
|
||||
for (let buildNode of buildArea) {
|
||||
let buildAreaNodes = area && gBuildAreas.get(area);
|
||||
if (buildAreaNodes) {
|
||||
for (let buildNode of buildAreaNodes) {
|
||||
let widgetNode = buildNode.ownerDocument.getElementById(aWidgetId);
|
||||
if (widgetNode) {
|
||||
widgetNode.parentNode.removeChild(widgetNode);
|
||||
|
@ -18,6 +18,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_880382_drag_wide_widgets_in_panel.js \
|
||||
browser_885530_showInPrivateBrowsing.js \
|
||||
browser_887438_currentset_shim.js \
|
||||
browser_890262_destroyWidget_after_add_to_panel.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -0,0 +1,75 @@
|
||||
/* 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/. */
|
||||
|
||||
const kLazyAreaId = "test-890262-lazy-area";
|
||||
const kWidget1Id = "test-890262-widget1";
|
||||
const kWidget2Id = "test-890262-widget2";
|
||||
|
||||
let gTests = [
|
||||
{
|
||||
desc: "Destroying a widget after defaulting it to a non-legacy area should work.",
|
||||
run: function() {
|
||||
CustomizableUI.createWidget({
|
||||
id: kWidget1Id,
|
||||
removable: true,
|
||||
defaultArea: kLazyAreaId
|
||||
});
|
||||
let noError = true;
|
||||
try {
|
||||
CustomizableUI.destroyWidget(kWidget1Id);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
noError = false;
|
||||
}
|
||||
ok(noError, "Shouldn't throw an exception for a widget that was created in a not-yet-constructed area");
|
||||
}
|
||||
},
|
||||
{
|
||||
desc: "Destroying a widget after moving it to a non-legacy area should work.",
|
||||
run: function() {
|
||||
CustomizableUI.createWidget({
|
||||
id: kWidget2Id,
|
||||
removable: true,
|
||||
defaultArea: CustomizableUI.AREA_NAVBAR
|
||||
});
|
||||
|
||||
CustomizableUI.addWidgetToArea(kWidget2Id, kLazyAreaId);
|
||||
let noError = true;
|
||||
try {
|
||||
CustomizableUI.destroyWidget(kWidget2Id);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
noError = false;
|
||||
}
|
||||
ok(noError, "Shouldn't throw an exception for a widget that was added to a not-yet-constructed area");
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
function asyncCleanup() {
|
||||
let lazyArea = document.getElementById(kLazyAreaId);
|
||||
if (lazyArea) {
|
||||
lazyArea.remove();
|
||||
}
|
||||
try {
|
||||
CustomizableUI.unregisterArea(kLazyAreaId);
|
||||
} catch (ex) {} // If we didn't register successfully for some reason
|
||||
yield resetCustomization();
|
||||
}
|
||||
|
||||
function setupArea() {
|
||||
let lazyArea = document.createElementNS(kNSXUL, "hbox");
|
||||
lazyArea.id = kLazyAreaId;
|
||||
document.getElementById("nav-bar").appendChild(lazyArea);
|
||||
CustomizableUI.registerArea(kLazyAreaId, {
|
||||
type: CustomizableUI.TYPE_TOOLBAR,
|
||||
defaultPlacements: []
|
||||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
setupArea();
|
||||
runTests(gTests, asyncCleanup);
|
||||
}
|
Loading…
Reference in New Issue
Block a user