Bug 1287914 - Buttons in sliding panel overlay are not clickable. r=jaws
☠☠ backed out by 07c2278d03ee ☠ ☠
authorDrew Willcoxon <adw@mozilla.com>
Tue, 26 Jul 2016 16:18:35 -0700
changeset 348846 6e79dedcd251514c129c87c998bf44ee63d197f6
parent 348845 c6c3985e15fadfe6997bc371cac8914c6ca315fb
child 348847 6bd2b7d2ebe3f81c513e4519812b2a8f3d1ca5a0
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1287914
milestone50.0a1
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 1287914 - Buttons in sliding panel overlay are not clickable. r=jaws MozReview-Commit-ID: JF8LYbyubk6
browser/components/downloads/content/downloads.js
browser/components/downloads/test/browser/browser_downloads_panel_block.js
--- a/browser/components/downloads/content/downloads.js
+++ b/browser/components/downloads/content/downloads.js
@@ -1189,17 +1189,27 @@ const DownloadsViewController = {
     // Firstly, determine if this is a command that we can handle.
     if (!DownloadsViewUI.isCommandName(aCommand)) {
       return false;
     }
     if (!(aCommand in this) &&
         !(aCommand in DownloadsViewItem.prototype)) {
       return false;
     }
-    // Secondly, determine if focus is on a control in the downloads list.
+    // The currently supported commands depend on whether the blocked subview is
+    // showing.  If it is, then take the following path.
+    if (DownloadsBlockedSubview.view.showingSubView) {
+      let blockedSubviewCmds = [
+        "downloadsCmd_chooseOpen",
+        "cmd_delete",
+      ];
+      return blockedSubviewCmds.indexOf(aCommand) >= 0;
+    }
+    // If the blocked subview is not showing, then determine if focus is on a
+    // control in the downloads list.
     let element = document.commandDispatcher.focusedElement;
     while (element && element != DownloadsView.richListBox) {
       element = element.parentNode;
     }
     // We should handle the command only if the downloads list is among the
     // ancestors of the focused element.
     return !!element;
   },
@@ -1599,16 +1609,19 @@ const DownloadsBlockedSubview = {
     }
   },
 
   /**
    * Slides out the blocked subview and shows the main view.
    */
   hide() {
     this.view.showMainView();
+    // The point of this is to focus the proper element in the panel now that
+    // the main view is showing again.  showPanel handles that.
+    DownloadsPanel.showPanel();
   },
 
   /**
    * Deletes the download and hides the entire panel.
    */
   confirmBlock() {
     goDoCommand("cmd_delete");
     DownloadsPanel.hidePanel();
--- a/browser/components/downloads/test/browser/browser_downloads_panel_block.js
+++ b/browser/components/downloads/test/browser/browser_downloads_panel_block.js
@@ -34,31 +34,33 @@ add_task(function* mainTest() {
 
     // Show the subview again.
     EventUtils.sendMouseEvent({ type: "click" }, item);
     yield promiseSubviewShown(true);
 
     // Click the Open button.  The alert blocked-download dialog should be
     // shown.
     let dialogPromise = promiseAlertDialogOpen("cancel");
-    DownloadsBlockedSubview.elements.openButton.click();
+    EventUtils.synthesizeMouse(DownloadsBlockedSubview.elements.openButton,
+                               10, 10, {}, window);
     yield dialogPromise;
 
     window.focus();
     yield SimpleTest.promiseFocus(window);
 
     // Reopen the panel and show the subview again.
     yield openPanel();
 
     EventUtils.sendMouseEvent({ type: "click" }, item);
     yield promiseSubviewShown(true);
 
     // Click the Remove button.  The panel should close and the item should be
     // removed from it.
-    DownloadsBlockedSubview.elements.deleteButton.click();
+    EventUtils.synthesizeMouse(DownloadsBlockedSubview.elements.deleteButton,
+                               10, 10, {}, window);
     yield promisePanelHidden();
     yield openPanel();
 
     Assert.ok(!item.parentNode);
     DownloadsPanel.hidePanel();
     yield promisePanelHidden();
   }
 
@@ -146,20 +148,29 @@ function makeDownload(verdict) {
       becauseBlockedByReputationCheck: true,
       reputationCheckVerdict:  verdict,
     },
   };
 }
 
 function promiseSubviewShown(shown) {
   return new Promise(resolve => {
-    if (shown == DownloadsBlockedSubview.view.showingSubView) {
+    if (shown == DownloadsBlockedSubview.view.showingSubView &&
+        !DownloadsBlockedSubview.view._transitioning) {
+      info("promiseSubviewShown: already showing");
       resolve();
       return;
     }
-    let event = shown ? "ViewShowing" : "ViewHiding";
-    let subview = DownloadsBlockedSubview.subview;
-    subview.addEventListener(event, function showing() {
-      subview.removeEventListener(event, showing);
-      resolve();
-    });
+    let subviews = DownloadsBlockedSubview.view._subViews;
+    let onTransition = event => {
+      info("promiseSubviewShown: transitionend observed," +
+           " target=" + event.target +
+           " target.className=" + event.target.className);
+      if (event.target == subviews) {
+        info("promiseSubviewShown: got transitionend");
+        subviews.removeEventListener("transitionend", onTransition);
+        setTimeout(resolve, 0);
+      }
+    };
+    subviews.addEventListener("transitionend", onTransition);
+    info("promiseSubviewShown: waiting on transitionend");
   });
 }