Bug 988072 - Australis sidebar widget does not work for SDK add-ons (sidebar API). r=gijs, a=sledru
authorDave Townsend <dtownsend+bugmail>
Wed, 21 May 2014 14:54:00 +0100
changeset 200409 4059390acc463059c9b9177e00574f39d0d6a37a
parent 200408 d74b6d5766d426d054b3d9f20000dc2fb7643b45
child 200410 44bc3af856a4b4202864f9ed27aae1028d601b95
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs, sledru
bugs988072
milestone31.0a2
Bug 988072 - Australis sidebar widget does not work for SDK add-ons (sidebar API). r=gijs, a=sledru
browser/components/customizableui/src/CustomizableWidgets.jsm
--- a/browser/components/customizableui/src/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/src/CustomizableWidgets.jsm
@@ -110,16 +110,35 @@ function fillSubviewFromMenuItems(aMenuI
       // menus (which we don't copy) above the separator.
       if (!fragment.lastChild || fragment.lastChild.localName == "menuseparator") {
         continue;
       }
       subviewItem = doc.createElementNS(kNSXUL, "menuseparator");
     } else if (menuChild.localName == "menuitem") {
       subviewItem = doc.createElementNS(kNSXUL, "toolbarbutton");
       addShortcut(menuChild, doc, subviewItem);
+
+      let item = menuChild;
+      if (!item.hasAttribute("onclick")) {
+        subviewItem.addEventListener("click", event => {
+          let newEvent = new doc.defaultView.MouseEvent(event.type, event);
+          item.dispatchEvent(newEvent);
+        });
+      }
+
+      if (!item.hasAttribute("oncommand")) {
+        subviewItem.addEventListener("command", event => {
+          let newEvent = doc.createEvent("XULCommandEvent");
+          newEvent.initCommandEvent(
+            event.type, event.bubbles, event.cancelable, event.view,
+            event.detail, event.ctrlKey, event.altKey, event.shiftKey,
+            event.metaKey, event.sourceEvent);
+          item.dispatchEvent(newEvent);
+        });
+      }
     } else {
       continue;
     }
     for (let attr of attrs) {
       let attrVal = menuChild.getAttribute(attr);
       if (attrVal)
         subviewItem.setAttribute(attr, attrVal);
     }
@@ -942,9 +961,9 @@ if (Services.prefs.getBoolPref("browser.
   CustomizableWidgets.push({
     id: "e10s-button",
     label: buttonLabel,
     tooltiptext: buttonLabel,
     defaultArea: CustomizableUI.AREA_PANEL,
     onCommand: getCommandFunction(openRemote),
   });
 }
-#endif
\ No newline at end of file
+#endif