From 9bbb73578165bfc1078ef87943eee2cbc0b6a406 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 14 Mar 2018 15:52:02 +0100 Subject: Clicking on a notification should select the originating tab Issue #1641 --- browser/base/content/content.js | 6 +++++- browser/base/content/tabbrowser.xml | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/browser/base/content/content.js b/browser/base/content/content.js index 19032eb84..3587bbeef 100644 --- a/browser/base/content/content.js +++ b/browser/base/content/content.js @@ -61,4 +61,8 @@ addEventListener("blur", function(event) { addMessageListener("Finder:Initialize", function () { let {RemoteFinderListener} = Cu.import("resource://gre/modules/RemoteFinder.jsm", {}); new RemoteFinderListener(global); -}); \ No newline at end of file +}); + +addEventListener("DOMWebNotificationClicked", function(event) { + sendAsyncMessage("DOMWebNotificationClicked", {}); +}, false); diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index b8d5f3e41..8f94ded8a 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -2950,13 +2950,22 @@ let browser = aMessage.target; switch (aMessage.name) { - case "DOMTitleChanged": + case "DOMTitleChanged": { let tab = this.getTabForBrowser(browser); if (!tab) return; let titleChanged = this.setTabTitle(tab); if (titleChanged && !tab.selected && !tab.hasAttribute("busy")) tab.setAttribute("titlechanged", "true"); + } + case "DOMWebNotificationClicked": { + let tab = this._getTabForBrowser(browser); + if (!tab) + return; + this.selectedTab = tab; + window.focus(); + break; + } } ]]> @@ -3022,6 +3031,7 @@ this._outerWindowIDBrowserMap.set(this.mCurrentBrowser.outerWindowID, this.mCurrentBrowser); } + messageManager.addMessageListener("DOMWebNotificationClicked", this); ]]> -- cgit v1.2.3 From 802d364f620e3cbaec74093f8d540aeb9e1943bd Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 14 Mar 2018 16:08:55 +0100 Subject: Use getTabForBrowser insted of _getTabForBrowser (deprecated) Issue #1641 --- browser/base/content/tabbrowser.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 8f94ded8a..085327924 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -2959,7 +2959,7 @@ tab.setAttribute("titlechanged", "true"); } case "DOMWebNotificationClicked": { - let tab = this._getTabForBrowser(browser); + let tab = this.getTabForBrowser(browser); if (!tab) return; this.selectedTab = tab; -- cgit v1.2.3 From 59a8c7bfb05e6151b9b768e7af69f810df28cbd6 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 14 Mar 2018 17:29:00 +0100 Subject: The switch statement - use "break;" for all cases Issue #1641 --- browser/base/content/tabbrowser.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 085327924..51f7063f3 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -2957,6 +2957,7 @@ let titleChanged = this.setTabTitle(tab); if (titleChanged && !tab.selected && !tab.hasAttribute("busy")) tab.setAttribute("titlechanged", "true"); + break; } case "DOMWebNotificationClicked": { let tab = this.getTabForBrowser(browser); -- cgit v1.2.3