Backed out changeset 3199da11173f (bug 944887)
authorMike Conley <mconley@mozilla.com>
Tue, 03 Dec 2013 23:24:15 -0500
changeset 174149 8f6dc3a5ab670cfdfe0e6e01328f68466382d9e2
parent 174148 ff14f9d94e4448bee8c974deb8f94bb1c959e41f
child 174150 9a2aa1fbe02ee33c630d68b56033b60a9df13f5f
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs944887
milestone28.0a1
backs out3199da11173f05885934929115726fbd16449088
Backed out changeset 3199da11173f (bug 944887)
browser/components/customizableui/src/CustomizableUI.jsm
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_944887_destroyWidget_should_destroy_in_palette.js
--- a/browser/components/customizableui/src/CustomizableUI.jsm
+++ b/browser/components/customizableui/src/CustomizableUI.jsm
@@ -631,17 +631,17 @@ let CustomizableUIInternal = {
 
     LOG("Searching for " + aWidgetId + " in toolbox.");
     let node = this.findWidgetInWindow(aWidgetId, aWindow);
     if (node) {
       return [ CustomizableUI.PROVIDER_XUL, node ];
     }
 
     LOG("No node for " + aWidgetId + " found.");
-    return [null, null];
+    return [];
   },
 
   registerMenuPanel: function(aPanel) {
     if (gBuildAreas.has(CustomizableUI.AREA_PANEL) &&
         gBuildAreas.get(CustomizableUI.AREA_PANEL).has(aPanel)) {
       return;
     }
 
@@ -1872,33 +1872,37 @@ let CustomizableUIInternal = {
           defaultPlacements.splice(widgetIndex, 1);
         }
       }
     }
 
     // This will not remove the widget from gPlacements - we want to keep the
     // setting so the widget gets put back in it's old position if/when it
     // returns.
-    for (let [window, ] of gBuildWindows) {
-      let windowCache = gSingleWrapperCache.get(window);
-      if (windowCache) {
-        windowCache.delete(aWidgetId);
-      }
-      let widgetNode = window.document.getElementById(aWidgetId) ||
-                       window.gNavToolbox.palette.querySelector(idToSelector(aWidgetId));
-      if (widgetNode) {
-        widgetNode.remove();
-      }
-      if (widget.type == "view") {
-        let viewNode = window.document.getElementById(widget.viewId);
-        if (viewNode) {
-          for (let eventName of kSubviewEvents) {
-            let handler = "on" + eventName;
-            if (typeof widget[handler] == "function") {
-              viewNode.removeEventListener(eventName, widget[handler], false);
+
+    let area = widget.currentArea;
+    let buildAreaNodes = area && gBuildAreas.get(area);
+    if (buildAreaNodes) {
+      for (let buildNode of buildAreaNodes) {
+        let widgetNode = buildNode.ownerDocument.getElementById(aWidgetId);
+        let windowCache = gSingleWrapperCache.get(buildNode.ownerDocument.defaultView);
+        if (windowCache) {
+          windowCache.delete(aWidgetId);
+        }
+        if (widgetNode) {
+          widgetNode.parentNode.removeChild(widgetNode);
+        }
+        if (widget.type == "view") {
+          let viewNode = buildNode.ownerDocument.getElementById(widget.viewId);
+          if (viewNode) {
+            for (let eventName of kSubviewEvents) {
+              let handler = "on" + eventName;
+              if (typeof widget[handler] == "function") {
+                viewNode.removeEventListener(eventName, widget[handler], false);
+              }
             }
           }
         }
       }
     }
 
     gPalette.delete(aWidgetId);
     gGroupWrapperCache.delete(aWidgetId);
--- a/browser/components/customizableui/test/browser.ini
+++ b/browser/components/customizableui/test/browser.ini
@@ -38,10 +38,9 @@ skip-if = os == "mac"
 
 [browser_938980_navbar_collapsed.js]
 [browser_938995_indefaultstate_nonremovable.js]
 [browser_940013_registerToolbarNode_calls_registerArea.js]
 [browser_940946_removable_from_navbar_customizemode.js]
 [browser_941083_invalidate_wrapper_cache_createWidget.js]
 [browser_942581_unregisterArea_keeps_placements.js]
 [browser_943683_migration_test.js]
-[browser_944887_destroyWidget_should_destroy_in_palette.js]
 [browser_panel_toggle.js]
deleted file mode 100644
--- a/browser/components/customizableui/test/browser_944887_destroyWidget_should_destroy_in_palette.js
+++ /dev/null
@@ -1,25 +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/. */
-
-const kWidgetId = "test-destroy-in-palette";
-
-let gTests = [
-  {
-    desc: "Check destroyWidget destroys the node if it's in the palette",
-    run: function() {
-      CustomizableUI.createWidget({id: kWidgetId, label: "Test destroying widgets in palette."});
-      yield startCustomizing();
-      yield endCustomizing();
-      ok(gNavToolbox.palette.querySelector("#" + kWidgetId), "Widget still exists in palette.");
-      CustomizableUI.destroyWidget(kWidgetId);
-      ok(!gNavToolbox.palette.querySelector("#" + kWidgetId), "Widget no longer exists in palette.");
-    },
-  },
-];
-
-function test() {
-  waitForExplicitFinish();
-  runTests(gTests);
-}
-