From a21a61d78d6a354be3453952a113454473adba44 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Thu, 28 Jul 2016 11:51:53 -0700 Subject: [PATCH] Bug 1287914 - Buttons in sliding panel overlay are not clickable. r=jaws MozReview-Commit-ID: 91yoPxiMIy8 --- .../components/downloads/content/downloads.js | 15 ++++++++++- .../browser/browser_downloads_panel_block.js | 26 ++++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/browser/components/downloads/content/downloads.js b/browser/components/downloads/content/downloads.js index 6e35842695bc..5abb8ffb3066 100644 --- a/browser/components/downloads/content/downloads.js +++ b/browser/components/downloads/content/downloads.js @@ -1196,7 +1196,17 @@ const DownloadsViewController = { !(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; @@ -1606,6 +1616,9 @@ const DownloadsBlockedSubview = { */ 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(); }, /** diff --git a/browser/components/downloads/test/browser/browser_downloads_panel_block.js b/browser/components/downloads/test/browser/browser_downloads_panel_block.js index edaf21253f85..8d5dc2d670ae 100644 --- a/browser/components/downloads/test/browser/browser_downloads_panel_block.js +++ b/browser/components/downloads/test/browser/browser_downloads_panel_block.js @@ -39,7 +39,8 @@ add_task(function* mainTest() { // 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(); @@ -53,7 +54,8 @@ add_task(function* mainTest() { // 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(); @@ -150,16 +152,16 @@ function makeDownload(verdict) { } function promiseSubviewShown(shown) { + // More terribleness, but I'm tired of fighting intermittent timeouts on try. + // Just poll for the subview and wait a second before resolving the promise. return new Promise(resolve => { - if (shown == DownloadsBlockedSubview.view.showingSubView) { - resolve(); - return; - } - let event = shown ? "ViewShowing" : "ViewHiding"; - let subview = DownloadsBlockedSubview.subview; - subview.addEventListener(event, function showing() { - subview.removeEventListener(event, showing); - resolve(); - }); + let interval = setInterval(() => { + if (shown == DownloadsBlockedSubview.view.showingSubView && + !DownloadsBlockedSubview.view._transitioning) { + clearInterval(interval); + setTimeout(resolve, 1000); + return; + } + }, 0); }); }