Bug 1584539: Stop propagation of event. r=Gijs
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Thu, 03 Oct 2019 14:42:29 +0000
changeset 496192 f1d5fcf421a4a0670d95a91dbcce277dcfefba87
parent 496191 eec117b846313015dab60e5c437450bc51996f1e
child 496193 eb3f06b807587f023efa7d9e919df5b72c71a156
push id97087
push usergijskruitbosch@gmail.com
push dateThu, 03 Oct 2019 14:43:05 +0000
treeherderautoland@f1d5fcf421a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1584539
milestone71.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 1584539: Stop propagation of event. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D48027
browser/components/downloads/DownloadsViewUI.jsm
browser/components/downloads/content/downloads.js
--- a/browser/components/downloads/DownloadsViewUI.jsm
+++ b/browser/components/downloads/DownloadsViewUI.jsm
@@ -164,16 +164,20 @@ this.DownloadsViewUI.DownloadElementShel
   },
   get active() {
     return !!this._active;
   },
 
   connect() {
     let document = this.element.ownerDocument;
     let downloadListItemFragment = gDownloadListItemFragments.get(document);
+    // When changing the markup within the fragment, please ensure that
+    // the functions within DownloadsView still operate correctly.
+    // E.g. onDownloadClick() relies on brittle logic and performs/prevents
+    // actions based on the check if originaltarget was not a button.
     if (!downloadListItemFragment) {
       let MozXULElement = document.defaultView.MozXULElement;
       downloadListItemFragment = MozXULElement.parseXULToFragment(`
         <hbox class="downloadMainArea" flex="1" align="center">
           <stack>
             <image class="downloadTypeIcon" validate="always"/>
             <image class="downloadBlockedBadge" />
           </stack>
--- a/browser/components/downloads/content/downloads.js
+++ b/browser/components/downloads/content/downloads.js
@@ -809,20 +809,17 @@ var DownloadsView = {
     this._visibleViewItems.delete(download);
     this._itemsForElements.delete(element);
   },
 
   // User interface event functions
 
   onDownloadClick(aEvent) {
     // Handle primary clicks only, and exclude the action button.
-    if (
-      aEvent.button == 0 &&
-      !aEvent.originalTarget.hasAttribute("oncommand")
-    ) {
+    if (aEvent.button == 0 && aEvent.originalTarget.localName != "button") {
       let target = aEvent.target;
       while (target.nodeName != "richlistitem") {
         target = target.parentNode;
       }
       let download = DownloadsView.itemForElement(target).download;
       if (download.hasBlockedData) {
         goDoCommand("downloadsCmd_showBlockedInfo");
       } else {