mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 19:55:39 +00:00
Bug 1493594 - replace customizationTarget XBL property by CustomizableUI method, r=gijs
This commit is contained in:
parent
2ea3b7c4a7
commit
17f55aee76
@ -552,6 +552,25 @@ var CustomizableUIInternal = {
|
||||
this.saveState();
|
||||
},
|
||||
|
||||
getCustomizationTarget(aElement) {
|
||||
if (!aElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!aElement._customizationTarget && aElement.hasAttribute("customizable")) {
|
||||
let id = aElement.getAttribute("customizationtarget");
|
||||
if (id) {
|
||||
aElement._customizationTarget = aElement.ownerDocument.getElementById(id);
|
||||
}
|
||||
|
||||
if (!aElement._customizationTarget) {
|
||||
aElement._customizationTarget = aElement;
|
||||
}
|
||||
}
|
||||
|
||||
return aElement._customizationTarget;
|
||||
},
|
||||
|
||||
wrapWidget(aWidgetId) {
|
||||
if (gGroupWrapperCache.has(aWidgetId)) {
|
||||
return gGroupWrapperCache.get(aWidgetId);
|
||||
@ -684,7 +703,8 @@ var CustomizableUIInternal = {
|
||||
let existingAreaNodes = gBuildAreas.get(aName);
|
||||
if (existingAreaNodes) {
|
||||
for (let areaNode of existingAreaNodes) {
|
||||
this.notifyListeners("onAreaNodeUnregistered", aName, areaNode.customizationTarget,
|
||||
this.notifyListeners("onAreaNodeUnregistered", aName,
|
||||
this.getCustomizationTarget(areaNode),
|
||||
CustomizableUI.REASON_AREA_UNREGISTERED);
|
||||
}
|
||||
}
|
||||
@ -743,7 +763,8 @@ var CustomizableUIInternal = {
|
||||
if (gDirtyAreaCache.has(area)) {
|
||||
this.buildArea(area, placements, aToolbar);
|
||||
}
|
||||
this.notifyListeners("onAreaNodeRegistered", area, aToolbar.customizationTarget);
|
||||
this.notifyListeners("onAreaNodeRegistered", area,
|
||||
this.getCustomizationTarget(aToolbar));
|
||||
} finally {
|
||||
this.endBatchUpdate();
|
||||
}
|
||||
@ -753,7 +774,7 @@ var CustomizableUIInternal = {
|
||||
let document = aAreaNode.ownerDocument;
|
||||
let window = document.defaultView;
|
||||
let inPrivateWindow = PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
let container = aAreaNode.customizationTarget;
|
||||
let container = this.getCustomizationTarget(aAreaNode);
|
||||
let areaIsPanel = gAreas.get(aArea).get("type") == CustomizableUI.TYPE_MENU_PANEL;
|
||||
|
||||
if (!container) {
|
||||
@ -980,8 +1001,7 @@ var CustomizableUIInternal = {
|
||||
return;
|
||||
}
|
||||
|
||||
aPanelContents.customizationTarget = aPanelContents;
|
||||
|
||||
aPanelContents._customizationTarget = aPanelContents;
|
||||
this.addPanelCloseListeners(this._getPanelForNode(aPanelContents));
|
||||
|
||||
let placements = gPlacements.get(aArea);
|
||||
@ -1029,7 +1049,7 @@ var CustomizableUIInternal = {
|
||||
continue;
|
||||
}
|
||||
|
||||
let container = areaNode.customizationTarget;
|
||||
let container = this.getCustomizationTarget(areaNode);
|
||||
let widgetNode = window.document.getElementById(aWidgetId);
|
||||
if (widgetNode && isOverflowable) {
|
||||
container = areaNode.overflowable.getContainerFor(widgetNode);
|
||||
@ -1123,7 +1143,8 @@ var CustomizableUIInternal = {
|
||||
let areaProperties = gAreas.get(areaId);
|
||||
for (let node of areaNodes) {
|
||||
if (node.ownerDocument == document) {
|
||||
this.notifyListeners("onAreaNodeUnregistered", areaId, node.customizationTarget,
|
||||
this.notifyListeners("onAreaNodeUnregistered", areaId,
|
||||
this.getCustomizationTarget(node),
|
||||
CustomizableUI.REASON_WINDOW_CLOSED);
|
||||
if (areaProperties.has("overflowable")) {
|
||||
node.overflowable.uninit();
|
||||
@ -1229,7 +1250,7 @@ var CustomizableUIInternal = {
|
||||
return aAreaNode.overflowable.findOverflowedInsertionPoints(aNode);
|
||||
}
|
||||
|
||||
let container = aAreaNode.customizationTarget;
|
||||
let container = this.getCustomizationTarget(aAreaNode);
|
||||
let placements = gPlacements.get(areaId);
|
||||
let nodeIndex = placements.indexOf(aNode.id);
|
||||
|
||||
@ -1358,7 +1379,7 @@ var CustomizableUIInternal = {
|
||||
let node = document.getElementById(aId);
|
||||
if (node) {
|
||||
let parent = node.parentNode;
|
||||
while (parent && !(parent.customizationTarget ||
|
||||
while (parent && !(this.getCustomizationTarget(parent) ||
|
||||
parent == aWindow.gNavToolbox.palette)) {
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
@ -1367,7 +1388,7 @@ var CustomizableUIInternal = {
|
||||
let nodeInArea = node.parentNode.localName == "toolbarpaletteitem" ?
|
||||
node.parentNode : node;
|
||||
// Check if we're in a customization target, or in the palette:
|
||||
if ((parent.customizationTarget == nodeInArea.parentNode &&
|
||||
if ((this.getCustomizationTarget(parent) == nodeInArea.parentNode &&
|
||||
gBuildWindows.get(aWindow).has(aWindow.gNavToolbox)) ||
|
||||
aWindow.gNavToolbox.palette == nodeInArea.parentNode) {
|
||||
// Normalize the removable attribute. For backwards compat, if
|
||||
@ -1376,7 +1397,7 @@ var CustomizableUIInternal = {
|
||||
if (!node.hasAttribute("removable")) {
|
||||
// If we first see this in customization mode, it may be in the
|
||||
// customization palette instead of the toolbox palette.
|
||||
node.setAttribute("removable", !parent.customizationTarget);
|
||||
node.setAttribute("removable", !this.getCustomizationTarget(parent));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@ -2551,7 +2572,7 @@ var CustomizableUIInternal = {
|
||||
|
||||
for (let node of buildAreaNodes) {
|
||||
if (node.ownerGlobal == aWindow) {
|
||||
return node.customizationTarget ? node.customizationTarget : node;
|
||||
return this.getCustomizationTarget(node) || node;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2785,7 +2806,7 @@ var CustomizableUIInternal = {
|
||||
}
|
||||
}
|
||||
}
|
||||
addUnskippedChildren(container.customizationTarget);
|
||||
addUnskippedChildren(this.getCustomizationTarget(container));
|
||||
if (container.getAttribute("overflowing") == "true") {
|
||||
let overflowTarget = container.getAttribute("overflowtarget");
|
||||
addUnskippedChildren(container.ownerDocument.getElementById(overflowTarget));
|
||||
@ -3924,6 +3945,10 @@ var CustomizableUI = {
|
||||
|
||||
parent.appendChild(aSubview);
|
||||
},
|
||||
|
||||
getCustomizationTarget(aElement) {
|
||||
return CustomizableUIInternal.getCustomizationTarget(aElement);
|
||||
},
|
||||
};
|
||||
Object.freeze(this.CustomizableUI);
|
||||
Object.freeze(this.CustomizableUI.windows);
|
||||
@ -4196,9 +4221,9 @@ function OverflowableToolbar(aToolbarNode) {
|
||||
|
||||
this._toolbar.setAttribute("overflowable", "true");
|
||||
let doc = this._toolbar.ownerDocument;
|
||||
this._target = this._toolbar.customizationTarget;
|
||||
this._target = CustomizableUI.getCustomizationTarget(this._toolbar);
|
||||
this._list = doc.getElementById(this._toolbar.getAttribute("overflowtarget"));
|
||||
this._list.customizationTarget = this._list;
|
||||
this._list._customizationTarget = this._list;
|
||||
|
||||
let window = this._toolbar.ownerGlobal;
|
||||
if (window.gBrowserInit.delayedStartupFinished) {
|
||||
|
@ -510,7 +510,7 @@ CustomizeMode.prototype = {
|
||||
for (let i = 0; i < numberOfAreas; i++) {
|
||||
let area = areas[i];
|
||||
let areaNode = aNode.ownerDocument.getElementById(area);
|
||||
let customizationTarget = areaNode && areaNode.customizationTarget;
|
||||
let customizationTarget = CustomizableUI.getCustomizationTarget(areaNode);
|
||||
if (customizationTarget && customizationTarget != areaNode) {
|
||||
areas.push(customizationTarget.id);
|
||||
}
|
||||
@ -1736,7 +1736,7 @@ CustomizeMode.prototype = {
|
||||
// We need to determine the place that the widget is being dropped in
|
||||
// the target.
|
||||
let dragOverItem, dragValue;
|
||||
if (targetNode == targetArea.customizationTarget) {
|
||||
if (targetNode == CustomizableUI.getCustomizationTarget(targetArea)) {
|
||||
// We'll assume if the user is dragging directly over the target, that
|
||||
// they're attempting to append a child to that target.
|
||||
dragOverItem = (targetAreaType == "toolbar"
|
||||
@ -1788,7 +1788,7 @@ CustomizeMode.prototype = {
|
||||
}
|
||||
|
||||
if (dragOverItem != this._dragOverItem || dragValue != dragOverItem.getAttribute("dragover")) {
|
||||
if (dragOverItem != targetArea.customizationTarget) {
|
||||
if (dragOverItem != CustomizableUI.getCustomizationTarget(targetArea)) {
|
||||
this._setDragActive(dragOverItem, dragValue, draggedItemId, targetAreaType);
|
||||
}
|
||||
this._dragOverItem = dragOverItem;
|
||||
@ -1900,6 +1900,8 @@ CustomizeMode.prototype = {
|
||||
}
|
||||
|
||||
// Skipintoolbarset items won't really be moved:
|
||||
let areaCustomizationTarget =
|
||||
CustomizableUI.getCustomizationTarget(aTargetArea);
|
||||
if (draggedItem.getAttribute("skipintoolbarset") == "true") {
|
||||
// These items should never leave their area:
|
||||
if (aTargetArea != aOriginArea) {
|
||||
@ -1907,11 +1909,11 @@ CustomizeMode.prototype = {
|
||||
}
|
||||
let place = draggedItem.parentNode.getAttribute("place");
|
||||
this.unwrapToolbarItem(draggedItem.parentNode);
|
||||
if (aTargetNode == aTargetArea.customizationTarget) {
|
||||
aTargetArea.customizationTarget.appendChild(draggedItem);
|
||||
if (aTargetNode == areaCustomizationTarget) {
|
||||
areaCustomizationTarget.appendChild(draggedItem);
|
||||
} else {
|
||||
this.unwrapToolbarItem(aTargetNode.parentNode);
|
||||
aTargetArea.customizationTarget.insertBefore(draggedItem, aTargetNode);
|
||||
areaCustomizationTarget.insertBefore(draggedItem, aTargetNode);
|
||||
this.wrapToolbarItem(aTargetNode, place);
|
||||
}
|
||||
this.wrapToolbarItem(draggedItem, place);
|
||||
@ -1920,7 +1922,7 @@ CustomizeMode.prototype = {
|
||||
|
||||
// Is the target the customization area itself? If so, we just add the
|
||||
// widget to the end of the area.
|
||||
if (aTargetNode == aTargetArea.customizationTarget) {
|
||||
if (aTargetNode == areaCustomizationTarget) {
|
||||
CustomizableUI.addWidgetToArea(aDraggedItemId, aTargetArea.id);
|
||||
this._onDragEnd(aEvent);
|
||||
return;
|
||||
@ -2227,7 +2229,8 @@ CustomizeMode.prototype = {
|
||||
},
|
||||
|
||||
_getDragOverNode(aEvent, aAreaElement, aAreaType, aDraggedItemId) {
|
||||
let expectedParent = aAreaElement.customizationTarget || aAreaElement;
|
||||
let expectedParent =
|
||||
CustomizableUI.getCustomizationTarget(aAreaElement) || aAreaElement;
|
||||
if (!expectedParent.contains(aEvent.target)) {
|
||||
return expectedParent;
|
||||
}
|
||||
|
@ -35,22 +35,6 @@
|
||||
.map(node => node.id);
|
||||
CustomizableUI.registerToolbarNode(this, children);
|
||||
]]></constructor>
|
||||
|
||||
<property name="customizationTarget" readonly="true">
|
||||
<getter><![CDATA[
|
||||
if (this._customizationTarget)
|
||||
return this._customizationTarget;
|
||||
|
||||
let id = this.getAttribute("customizationtarget");
|
||||
if (id)
|
||||
this._customizationTarget = document.getElementById(id);
|
||||
|
||||
if (!this._customizationTarget)
|
||||
this._customizationTarget = this;
|
||||
|
||||
return this._customizationTarget;
|
||||
]]></getter>
|
||||
</property>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
|
@ -16,7 +16,7 @@ add_task(async function() {
|
||||
is(button.getAttribute(kAnchorAttribute), "nav-bar-overflow-button",
|
||||
"Button (" + button.id + ") starts out with correct anchor");
|
||||
|
||||
let navbar = document.getElementById("nav-bar").customizationTarget;
|
||||
let navbar = CustomizableUI.getCustomizationTarget(document.getElementById("nav-bar"));
|
||||
let onMouseUp = BrowserTestUtils.waitForEvent(navbar, "mouseup");
|
||||
simulateItemDrag(button, navbar);
|
||||
await onMouseUp;
|
||||
|
@ -35,8 +35,8 @@ async function ensureVisible(node) {
|
||||
var move = {
|
||||
"drag": async function(id, target) {
|
||||
let targetNode = document.getElementById(target);
|
||||
if (targetNode.customizationTarget) {
|
||||
targetNode = targetNode.customizationTarget;
|
||||
if (CustomizableUI.getCustomizationTarget(targetNode)) {
|
||||
targetNode = CustomizableUI.getCustomizationTarget(targetNode);
|
||||
}
|
||||
let nodeToMove = document.getElementById(id);
|
||||
await ensureVisible(nodeToMove);
|
||||
@ -45,8 +45,8 @@ var move = {
|
||||
},
|
||||
"dragToItem": async function(id, target) {
|
||||
let targetNode = document.getElementById(target);
|
||||
if (targetNode.customizationTarget) {
|
||||
targetNode = targetNode.customizationTarget;
|
||||
if (CustomizableUI.getCustomizationTarget(targetNode)) {
|
||||
targetNode = CustomizableUI.getCustomizationTarget(targetNode);
|
||||
}
|
||||
let items = targetNode.querySelectorAll("toolbarpaletteitem");
|
||||
if (target == kPanel) {
|
||||
@ -68,14 +68,18 @@ var move = {
|
||||
|
||||
function isLast(containerId, defaultPlacements, id) {
|
||||
assertAreaPlacements(containerId, defaultPlacements.concat([id]));
|
||||
is(document.getElementById(containerId).customizationTarget.lastElementChild.firstElementChild.id, id,
|
||||
let thisTarget =
|
||||
CustomizableUI.getCustomizationTarget(document.getElementById(containerId));
|
||||
is(thisTarget.lastElementChild.firstElementChild.id, id,
|
||||
"Widget " + id + " should be in " + containerId + " in customizing window.");
|
||||
is(otherWin.document.getElementById(containerId).customizationTarget.lastElementChild.id, id,
|
||||
let otherTarget =
|
||||
CustomizableUI.getCustomizationTarget(otherWin.document.getElementById(containerId));
|
||||
is(otherTarget.lastElementChild.id, id,
|
||||
"Widget " + id + " should be in " + containerId + " in other window.");
|
||||
}
|
||||
|
||||
function getLastVisibleNodeInToolbar(containerId, win = window) {
|
||||
let container = win.document.getElementById(containerId).customizationTarget;
|
||||
let container = CustomizableUI.getCustomizationTarget(win.document.getElementById(containerId));
|
||||
let rv = container.lastElementChild;
|
||||
while (rv && (rv.getAttribute("hidden") == "true" || (rv.firstElementChild && rv.firstElementChild.getAttribute("hidden") == "true"))) {
|
||||
rv = rv.previousElementSibling;
|
||||
@ -106,9 +110,13 @@ function isLastVisibleInToolbar(containerId, defaultPlacements, id) {
|
||||
|
||||
function isFirst(containerId, defaultPlacements, id) {
|
||||
assertAreaPlacements(containerId, [id].concat(defaultPlacements));
|
||||
is(document.getElementById(containerId).customizationTarget.firstElementChild.firstElementChild.id, id,
|
||||
let thisTarget =
|
||||
CustomizableUI.getCustomizationTarget(document.getElementById(containerId));
|
||||
is(thisTarget.firstElementChild.firstElementChild.id, id,
|
||||
"Widget " + id + " should be in " + containerId + " in customizing window.");
|
||||
is(otherWin.document.getElementById(containerId).customizationTarget.firstElementChild.id, id,
|
||||
let otherTarget =
|
||||
CustomizableUI.getCustomizationTarget(otherWin.document.getElementById(containerId));
|
||||
is(otherTarget.firstElementChild.id, id,
|
||||
"Widget " + id + " should be in " + containerId + " in other window.");
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ var gLazyArea;
|
||||
add_task(async function() {
|
||||
let dummyBtn = createDummyXULButton(kButtonId, "Dummy");
|
||||
dummyBtn.setAttribute("removable", "true");
|
||||
gNavBar.customizationTarget.appendChild(dummyBtn);
|
||||
CustomizableUI.getCustomizationTarget(gNavBar).appendChild(dummyBtn);
|
||||
let popupSet = document.getElementById("mainPopupSet");
|
||||
gLazyArea = document.createElementNS(kNSXUL, "panel");
|
||||
gLazyArea.id = kLazyAreaId;
|
||||
@ -29,10 +29,10 @@ add_task(async function() {
|
||||
"Placements should have changed because widget is removable.");
|
||||
let btn = document.getElementById(kButtonId);
|
||||
btn.setAttribute("removable", "false");
|
||||
gLazyArea.customizationTarget = gLazyArea;
|
||||
gLazyArea._customizationTarget = gLazyArea;
|
||||
CustomizableUI.registerToolbarNode(gLazyArea, []);
|
||||
assertAreaPlacements(kLazyAreaId, [], "Placements should no longer include widget.");
|
||||
is(btn.parentNode.id, gNavBar.customizationTarget.id,
|
||||
is(btn.parentNode.id, CustomizableUI.getCustomizationTarget(gNavBar).id,
|
||||
"Button shouldn't actually have moved as it's not removable");
|
||||
btn = document.getElementById(kButtonId);
|
||||
if (btn) btn.remove();
|
||||
|
@ -9,12 +9,12 @@ add_task(async function() {
|
||||
let originalWindowWidth = window.outerWidth;
|
||||
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
|
||||
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
|
||||
let oldChildCount = navbar.customizationTarget.childElementCount;
|
||||
let oldChildCount = CustomizableUI.getCustomizationTarget(navbar).childElementCount;
|
||||
window.resizeTo(kForceOverflowWidthPx, window.outerHeight);
|
||||
await waitForCondition(() => navbar.hasAttribute("overflowing"));
|
||||
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
|
||||
|
||||
ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
|
||||
ok(CustomizableUI.getCustomizationTarget(navbar).childElementCount < oldChildCount, "Should have fewer children.");
|
||||
let newWindow = await openAndLoadWindow();
|
||||
let otherNavBar = newWindow.document.getElementById(CustomizableUI.AREA_NAVBAR);
|
||||
await waitForCondition(() => otherNavBar.hasAttribute("overflowing"));
|
||||
|
@ -15,12 +15,13 @@ add_task(async function() {
|
||||
let originalWindowWidth = window.outerWidth;
|
||||
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
|
||||
ok(CustomizableUI.inDefaultState, "Should start in default state.");
|
||||
let oldChildCount = navbar.customizationTarget.childElementCount;
|
||||
let navbarTarget = CustomizableUI.getCustomizationTarget(navbar);
|
||||
let oldChildCount = navbarTarget.childElementCount;
|
||||
window.resizeTo(kForceOverflowWidthPx, window.outerHeight);
|
||||
await waitForCondition(() => navbar.hasAttribute("overflowing"));
|
||||
ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
|
||||
ok(CustomizableUI.inDefaultState, "Should still be in default state when overflowing.");
|
||||
ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
|
||||
ok(navbarTarget.childElementCount < oldChildCount, "Should have fewer children.");
|
||||
window.resizeTo(originalWindowWidth, window.outerHeight);
|
||||
await waitForCondition(() => !navbar.hasAttribute("overflowing"));
|
||||
ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
|
||||
@ -29,14 +30,14 @@ add_task(async function() {
|
||||
// Verify actual physical placements match those of the placement array:
|
||||
let placementCounter = 0;
|
||||
let placements = CustomizableUI.getWidgetIdsInArea(CustomizableUI.AREA_NAVBAR);
|
||||
for (let node of navbar.customizationTarget.children) {
|
||||
for (let node of navbarTarget.children) {
|
||||
if (node.getAttribute("skipintoolbarset") == "true") {
|
||||
continue;
|
||||
}
|
||||
is(placements[placementCounter++], node.id, "Nodes should match after overflow");
|
||||
}
|
||||
is(placements.length, placementCounter, "Should have as many nodes as expected");
|
||||
is(navbar.customizationTarget.childElementCount, oldChildCount, "Number of nodes should match");
|
||||
is(navbarTarget.childElementCount, oldChildCount, "Number of nodes should match");
|
||||
});
|
||||
|
||||
// Enter and exit customization mode, check that default state is correct.
|
||||
|
@ -15,7 +15,7 @@ add_task(async function() {
|
||||
skippedItem.setAttribute("label", "Test");
|
||||
skippedItem.setAttribute("skipintoolbarset", "true");
|
||||
skippedItem.setAttribute("removable", "true");
|
||||
navbar.customizationTarget.appendChild(skippedItem);
|
||||
CustomizableUI.getCustomizationTarget(navbar).appendChild(skippedItem);
|
||||
let libraryButton = document.getElementById("library-button");
|
||||
await startCustomizing();
|
||||
await waitForElementShown(skippedItem);
|
||||
|
@ -13,7 +13,7 @@ add_task(async function() {
|
||||
// Force the menu to be shown.
|
||||
const kAutohide = menubar.getAttribute("autohide");
|
||||
menubar.setAttribute("autohide", "false");
|
||||
simulateItemDrag(menuItems, navbar.customizationTarget);
|
||||
simulateItemDrag(menuItems, CustomizableUI.getCustomizationTarget(navbar));
|
||||
|
||||
is(getAreaWidgetIds("nav-bar").indexOf("menubar-items"), -1, "Menu bar shouldn't be in the navbar.");
|
||||
ok(!navbar.querySelector("#menubar-items"), "Shouldn't find menubar items in the navbar.");
|
||||
|
@ -9,7 +9,7 @@ const kTestBtnId = "test-removable-navbar-customize-mode";
|
||||
// Items without the removable attribute in the navbar should be considered non-removable
|
||||
add_task(async function() {
|
||||
let btn = createDummyXULButton(kTestBtnId, "Test removable in navbar in customize mode");
|
||||
document.getElementById("nav-bar").customizationTarget.appendChild(btn);
|
||||
CustomizableUI.getCustomizationTarget(document.getElementById("nav-bar")).appendChild(btn);
|
||||
await startCustomizing();
|
||||
ok(!CustomizableUI.isWidgetRemovable(kTestBtnId), "Widget should not be considered removable");
|
||||
await endCustomizing();
|
||||
|
@ -45,7 +45,8 @@ add_task(async function() {
|
||||
// not over a particular item.
|
||||
await startCustomizing();
|
||||
let homeButton = document.getElementById("home-button");
|
||||
simulateItemDrag(homeButton, navbar.customizationTarget, "end");
|
||||
let navbarTarget = CustomizableUI.getCustomizationTarget(navbar);
|
||||
simulateItemDrag(homeButton, navbarTarget, "end");
|
||||
|
||||
await endCustomizing();
|
||||
|
||||
|
@ -232,11 +232,11 @@ add_task(async function() {
|
||||
// navbar has "settled"
|
||||
await waitForCondition(() => {
|
||||
return navbar.hasAttribute("overflowing") &&
|
||||
navbar.customizationTarget.lastElementChild.getAttribute("overflows") == "false";
|
||||
CustomizableUI.getCustomizationTarget(navbar).lastElementChild.getAttribute("overflows") == "false";
|
||||
});
|
||||
|
||||
// Find last widget that doesn't allow overflowing
|
||||
let nonOverflowing = navbar.customizationTarget.lastElementChild;
|
||||
let nonOverflowing = CustomizableUI.getCustomizationTarget(navbar).lastElementChild;
|
||||
is(nonOverflowing.getAttribute("overflows"), "false", "Last child is expected to not allow overflowing");
|
||||
isnot(nonOverflowing.getAttribute("skipintoolbarset"), "true", "Last child is expected to not be skipintoolbarset");
|
||||
|
||||
|
@ -16,7 +16,7 @@ add_task(async function() {
|
||||
draggedItem.setAttribute("label", "Test");
|
||||
draggedItem.setAttribute("removable", "true");
|
||||
let navbar = document.getElementById("nav-bar");
|
||||
navbar.customizationTarget.appendChild(draggedItem);
|
||||
CustomizableUI.getCustomizationTarget(navbar).appendChild(draggedItem);
|
||||
await startCustomizing();
|
||||
simulateItemDrag(draggedItem, gCustomizeMode.visiblePalette);
|
||||
is(document.documentElement.hasAttribute("customizing-movingItem"), false,
|
||||
@ -32,9 +32,9 @@ add_task(async function() {
|
||||
draggedItem.setAttribute("removable", "true");
|
||||
let dest = createToolbarWithPlacements("test-dragEnd");
|
||||
let navbar = document.getElementById("nav-bar");
|
||||
navbar.customizationTarget.appendChild(draggedItem);
|
||||
CustomizableUI.getCustomizationTarget(navbar).appendChild(draggedItem);
|
||||
await startCustomizing();
|
||||
simulateItemDrag(draggedItem, dest.customizationTarget);
|
||||
simulateItemDrag(draggedItem, CustomizableUI.getCustomizationTarget(dest));
|
||||
is(document.documentElement.hasAttribute("customizing-movingItem"), false,
|
||||
"Make sure customizing-movingItem is removed");
|
||||
await endCustomizing();
|
||||
|
@ -26,10 +26,10 @@ add_task(async function addOverflowingToolbar() {
|
||||
}
|
||||
|
||||
isnot(toolbarNode.overflowable, null, "Toolbar should have overflowable controller");
|
||||
isnot(toolbarNode.customizationTarget, null, "Toolbar should have customization target");
|
||||
isnot(toolbarNode.customizationTarget, toolbarNode, "Customization target should not be toolbar node");
|
||||
isnot(CustomizableUI.getCustomizationTarget(toolbarNode), null, "Toolbar should have customization target");
|
||||
isnot(CustomizableUI.getCustomizationTarget(toolbarNode), toolbarNode, "Customization target should not be toolbar node");
|
||||
|
||||
let oldChildCount = toolbarNode.customizationTarget.childElementCount;
|
||||
let oldChildCount = CustomizableUI.getCustomizationTarget(toolbarNode).childElementCount;
|
||||
let overflowableList = document.getElementById(kToolbarName + "-overflow-list");
|
||||
let oldOverflowCount = overflowableList.childElementCount;
|
||||
|
||||
@ -38,7 +38,7 @@ add_task(async function addOverflowingToolbar() {
|
||||
window.resizeTo(kForceOverflowWidthPx, window.outerHeight);
|
||||
await waitForCondition(() => toolbarNode.hasAttribute("overflowing"));
|
||||
ok(toolbarNode.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
|
||||
ok(toolbarNode.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
|
||||
ok(CustomizableUI.getCustomizationTarget(toolbarNode).childElementCount < oldChildCount, "Should have fewer children.");
|
||||
ok(overflowableList.childElementCount > oldOverflowCount, "Should have more overflowed widgets.");
|
||||
|
||||
window.resizeTo(originalWindowWidth, window.outerHeight);
|
||||
|
@ -431,7 +431,7 @@ add_task(async function custom_context_menus() {
|
||||
is(widget.getAttribute("context"), "", "Should not have own context menu when in the panel.");
|
||||
is(widget.getAttribute("wrapped-context"), expectedContext, "Should keep own context menu wrapped now that we're in the panel.");
|
||||
|
||||
simulateItemDrag(widget, document.getElementById("nav-bar").customizationTarget);
|
||||
simulateItemDrag(widget, CustomizableUI.getCustomizationTarget(document.getElementById("nav-bar")));
|
||||
is(widget.getAttribute("context"), "", "Should not have own context menu when back in toolbar because we're still customizing.");
|
||||
is(widget.getAttribute("wrapped-context"), expectedContext, "Should keep own context menu wrapped now that we're back in the toolbar.");
|
||||
|
||||
|
@ -91,7 +91,7 @@ add_task(async function test_panelui_opened() {
|
||||
add_task(async function test_panelui_customize_to_toolbar() {
|
||||
await startCustomizing();
|
||||
let navbar = document.getElementById("nav-bar");
|
||||
simulateItemDrag(document.getElementById("edit-controls"), navbar.customizationTarget, "end");
|
||||
simulateItemDrag(document.getElementById("edit-controls"), CustomizableUI.getCustomizationTarget(navbar), "end");
|
||||
await endCustomizing();
|
||||
|
||||
// updateEditUIVisibility should be called when customization ends but isn't. See bug 1359790.
|
||||
|
@ -25,7 +25,7 @@ add_task(async function() {
|
||||
let button = document.getElementById("real-button");
|
||||
ok(button, "Button should exist");
|
||||
if (button) {
|
||||
let expectedContainer = document.getElementById(toolbar).customizationTarget;
|
||||
let expectedContainer = CustomizableUI.getCustomizationTarget(document.getElementById(toolbar));
|
||||
is(button.parentNode, expectedContainer, "Button should be in the toolbar");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user