Backed out changeset f66e3ccb0c41 and fdebf60103c3 (bug 981418)

This commit is contained in:
Gijs Kruitbosch 2014-03-11 19:56:55 +00:00
Родитель 4b7cf61154
Коммит e6e1bdda64
4 изменённых файлов: 7 добавлений и 111 удалений

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

@ -325,10 +325,7 @@
</method>
<method name="_syncContainerWithSubView">
<body><![CDATA[
// Need to nullcheck this._currentSubView because we could be called from a
// setTimeout from the overflow handler, which means the view might
// have been removed at this point.
if (!this.ignoreMutations && this._currentSubView && this.showingSubView) {
if (!this.ignoreMutations && this.showingSubView) {
let newHeight = this._heightOfSubview(this._currentSubView, this._subViews);
this._viewContainer.style.height = newHeight + "px";
}
@ -336,11 +333,7 @@
</method>
<method name="_syncContainerWithMainView">
<body><![CDATA[
// Need to nullcheck _mainView because we could be called from a
// setTimeout from the overflow handler, which means the view might
// have been removed at this point.
if (!this.ignoreMutations && this._mainView &&
!this.showingSubView && !this._transitioning) {
if (!this.ignoreMutations && !this.showingSubView && !this._transitioning) {
let height;
if (this.showingSubViewAsMainView) {
height = this._heightOfSubview(this._mainView);

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

@ -1082,15 +1082,16 @@ let CustomizableUIInternal = {
let node;
if (aWidget.type == "custom") {
if (aWidget.onBuild) {
try {
node = aWidget.onBuild(aDocument);
} catch (ex) {
ERROR("Custom widget with id " + aWidget.id + " threw an error: " + ex.message);
}
}
if (!node || !(node instanceof aDocument.defaultView.XULElement))
ERROR("Custom widget with id " + aWidget.id + " does not return a valid node");
}
else {
if (aWidget.onBeforeCreated) {
aWidget.onBeforeCreated(aDocument);
}
node = aDocument.createElementNS(kNSXUL, "toolbarbutton");
node.setAttribute("id", aWidget.id);
@ -1970,7 +1971,6 @@ let CustomizableUIInternal = {
widget.disabled = aData.disabled === true;
this.wrapWidgetEventHandler("onBeforeCreated", widget);
this.wrapWidgetEventHandler("onClick", widget);
this.wrapWidgetEventHandler("onCreated", widget);
@ -2728,12 +2728,6 @@ this.CustomizableUI = {
* function that will be invoked with the document in which
* to build a widget. Should return the DOM node that has
* been constructed.
* - onBeforeCreated(aDoc): Attached to all non-custom widgets; a function
* that will be invoked before the widget gets a DOM node
* constructed, passing the document in which that will happen.
* This is useful especially for 'view' type widgets that need
* to construct their views on the fly (e.g. from bootstrapped
* add-ons)
* - onCreated(aNode): Attached to all widgets; a function that will be invoked
* whenever the widget has a DOM node constructed, passing the
* constructed node as an argument.

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

@ -75,5 +75,4 @@ skip-if = os == "linux"
[browser_975719_customtoolbars_behaviour.js]
[browser_978084_dragEnd_after_move.js]
[browser_980155_add_overflow_toolbar.js]
[browser_981418-widget-onbeforecreated-handler.js]
[browser_panel_toggle.js]

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

@ -1,90 +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";
const kWidgetId = 'test-981418-widget-onbeforecreated';
// Should be able to add broken view widget
add_task(function testAddOnBeforeCreatedWidget() {
let viewShownDeferred = Promise.defer();
let onBeforeCreatedCalled = false;
let widgetSpec = {
id: kWidgetId,
type: 'view',
viewId: kWidgetId + 'idontexistyet',
onBeforeCreated: function(doc) {
let view = doc.createElement("panelview");
view.id = kWidgetId + 'idontexistyet';
let label = doc.createElement("label");
label.setAttribute("value", "Hello world");
label.className = 'panel-subview-header';
view.appendChild(label);
document.getElementById("PanelUI-multiView").appendChild(view);
onBeforeCreatedCalled = true;
},
onViewShowing: function() {
viewShownDeferred.resolve();
}
};
let noError = true;
try {
CustomizableUI.createWidget(widgetSpec);
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_NAVBAR);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Should not throw an exception trying to add the widget.");
ok(onBeforeCreatedCalled, "onBeforeCreated should have been called");
let widgetNode = document.getElementById(kWidgetId);
ok(widgetNode, "Widget should exist");
if (widgetNode) {
try {
widgetNode.click();
let shownTimeout = setTimeout(() => viewShownDeferred.reject("Panel not shown within 20s"), 20000);
yield viewShownDeferred.promise;
clearTimeout(shownTimeout);
ok(true, "Found view shown");
let tempPanel = document.getElementById("customizationui-widget-panel");
let panelHiddenPromise = promisePanelElementHidden(window, tempPanel);
tempPanel.hidePopup();
yield panelHiddenPromise;
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_PANEL);
yield PanelUI.show();
viewShownDeferred = Promise.defer();
widgetNode.click();
shownTimeout = setTimeout(() => viewShownDeferred.reject("Panel not shown within 20s"), 20000);
yield viewShownDeferred.promise;
clearTimeout(shownTimeout);
ok(true, "Found view shown");
let panelHidden = promisePanelHidden(window);
PanelUI.hide();
yield panelHidden;
} catch (ex) {
ok(false, "Unexpected exception (like a timeout for one of the yields) " +
"when testing view widget.");
}
}
noError = true;
try {
CustomizableUI.destroyWidget(kWidgetId);
} catch (ex) {
Cu.reportError(ex);
noError = false;
}
ok(noError, "Should not throw an exception trying to remove the broken view widget.");
});
add_task(function asyncCleanup() {
yield resetCustomization();
});