Bug 614152, don't set popupNode when opening notification popup, otherwise page context menu won't appear, r=dao, a=blocking
authorNeil Deakin <neil@mozilla.com>
Wed, 24 Nov 2010 13:31:25 -0500
changeset 58175 df43d548da49
parent 58174 1bb96fbc54f8
child 58176 00cabcc7d182
push id17185
push userneil@mozilla.com
push dateWed, 24 Nov 2010 18:33:01 +0000
treeherdermozilla-central@df43d548da49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao, blocking
bugs614152
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 614152, don't set popupNode when opening notification popup, otherwise page context menu won't appear, r=dao, a=blocking
toolkit/content/tests/widgets/test_notificationbox.xul
toolkit/content/widgets/autocomplete.xml
toolkit/content/widgets/browser.xml
toolkit/content/widgets/notification.xml
--- a/toolkit/content/tests/widgets/test_notificationbox.xul
+++ b/toolkit/content/tests/widgets/test_notificationbox.xul
@@ -5,33 +5,36 @@
   XUL Widget Test for notificationbox
   -->
 <window title="Notification Box" width="500" height="600"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script type="application/javascript" src="/MochiKit/packed.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>  
 
   <notificationbox id="nb"/>
+  <menupopup id="menupopup" onpopupshown="this.hidePopup()" onpopuphidden="checkPopupClosed()">
+    <menuitem label="One"/>
+  </menupopup>
 
   <!-- test results are displayed in the html:body -->
   <body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
 
   <!-- test code goes here -->
   <script type="application/javascript"><![CDATA[
 // ise - is exact - compares using ===
 function ise(left, right, name) { SimpleTest.ok(left === right, name); }
 
 SimpleTest.waitForExplicitFinish();
 
 var testtag_notificationbox_buttons = [
   {
     label: "Button 1",
     accesskey: "u",
     callback: testtag_notificationbox_buttonpressed,
-    popup: null
+    popup: "menupopup"
   }
 ];
 
 function testtag_notificationbox_buttonpressed(event)
 {
 }
 
 function testtag_notificationbox(nb)
@@ -268,20 +271,24 @@ var appendPriorityTests = [
     }
   },
   {
     test: function(nb, priority) {
       nb.removeCurrentNotification();
       return priority;
     },
     result: function(nb, priority) {
-      if (priority == nb.PRIORITY_CRITICAL_BLOCK)
-        SimpleTest.finish();
-      else
+      if (priority == nb.PRIORITY_CRITICAL_BLOCK) {
+        let ntf = nb.appendNotification("Notification", "note", "happy.png",
+                                        nb.PRIORITY_INFO_LOW, testtag_notificationbox_buttons);
+        setTimeout(checkPopupTest, 50, nb, ntf);
+      }
+      else {
         runTimedTests(appendPriorityTests, -1, nb, ++priority);
+      }
     }
   }
 ];
 
 function testtag_notificationbox_State(nb, testid, expecteditem, expectedcount)
 {
   ise(nb.currentNotification, expecteditem, testid + " currentNotification");
   ise(nb.allNotifications ? nb.allNotifications.length : "no value",
@@ -314,16 +321,33 @@ function testtag_notification_State(nb, 
     case nb.PRIORITY_CRITICAL_BLOCK:
       type = "critical";
       break;
   }
 
   ise(ntf.type, type, testid + " notification.type");
 }
 
+function checkPopupTest(nb, ntf)
+{
+  if (nb._animating)
+    setTimeout(checkPopupTest, ntf);
+  else {
+    var evt = { target:  ntf, originalTarget: ntf, stopPropagation: function() { } };
+    evt.target.buttonInfo = testtag_notificationbox_buttons[0];
+    ntf._doButtonCommand(evt);
+  }
+}
+
+function checkPopupClosed()
+{
+  is(document.popupNode, null, "popupNode null after popup is closed");
+  SimpleTest.finish();
+}
+
 /**
  * run one or more tests which perform a test operation, wait for a delay,
  * then perform a result operation.
  *
  * tests - array of objects where each object is :
  *           {
  *             test: test function,
  *             result: result function
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -709,18 +709,16 @@
           if (!this.mPopupOpen) {
             this.mInput = aInput;
             this.view = aInput.controller.QueryInterface(Components.interfaces.nsITreeView);
             this.invalidate();
 
             this.showCommentColumn = this.mInput.showCommentColumn;
             this.showImageColumn = this.mInput.showImageColumn;
 
-            document.popupNode = null;
-
             var rect = aElement.getBoundingClientRect();
             var nav = aElement.ownerDocument.defaultView.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                               .getInterface(Components.interfaces.nsIWebNavigation);
             var docShell = nav.QueryInterface(Components.interfaces.nsIDocShell);
             var docViewer = docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);
             var width = (rect.right - rect.left) * docViewer.fullZoom;
             this.setAttribute("width", width > 100 ? width : 100);
 
@@ -804,17 +802,16 @@
       <property name="popupOpen" readonly="true"
                 onget="return this.mPopupOpen;"/>
 
       <method name="closePopup">
         <body>
           <![CDATA[
           if (this.mPopupOpen) {
             this.hidePopup();
-            document.popupNode = null;
             this.removeAttribute("width");
           }
         ]]>
         </body>
       </method>
 
       <!-- This is the default number of rows that we give the autocomplete
            popup when the textbox doesn't have a "maxrows" attribute
@@ -958,17 +955,16 @@
         <parameter name="aInput"/>
         <parameter name="aElement"/>
         <body>
           <![CDATA[
           if (!this.mPopupOpen) {
             this.mInput = aInput;
             // clear any previous selection, see bugs 400671 and 488357
             this.selectedIndex = -1;
-            document.popupNode = null;
 
             var width = aElement.getBoundingClientRect().width;
             this.setAttribute("width", width > 100 ? width : 100);
             // invalidate() depends on the width attribute
             this._invalidate();
 
             // setConsumeRollupEvent() before we call openPopup()
             var nsIPopupBO = Components.interfaces.nsIPopupBoxObject;
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -860,17 +860,16 @@
                 this._autoScrollPopup.setAttribute("scrolldir", "NS");
               }
               else {
                 this._scrollable = null; // abort scrolling
                 return;
               }
             }
 
-            document.popupNode = null;
             this._autoScrollPopup.showPopup(document.documentElement,
                                             event.screenX,
                                             event.screenY,
                                             "popup", null, null);
             this._ignoreMouseEvents = true;
             this._startX = event.screenX;
             this._startY = event.screenY;
             this._screenX = event.screenX;
--- a/toolkit/content/widgets/notification.xml
+++ b/toolkit/content/widgets/notification.xml
@@ -394,19 +394,18 @@
         <parameter name="aEvent"/>
         <body>
           <![CDATA[
             if (!("buttonInfo" in aEvent.target))
               return;
 
             var button = aEvent.target.buttonInfo;
             if (button.popup) {
-              document.popupNode = aEvent.target;
               document.getElementById(button.popup).
-                showPopup(aEvent.originalTarget, -1, -1, "popup", "bottomleft", "topleft");
+                openPopup(aEvent.originalTarget, "after_start", 0, 0, false, false, aEvent);
               aEvent.stopPropagation();
             }
             else {
               var callback = button.callback;
               if (callback) {
                 var result = callback(this, button);
                 if (!result)
                   this.close();