Bug 1353857 - Include the tab ID when notifying about leaving/entering a web app's scope. r?daleharvey,walkingice draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Mon, 17 Apr 2017 16:37:58 +0200
changeset 568921 befea92ccce91faaa8fefc4c5adec9a3e5f381b8
parent 568920 8ab255628f9bb0a159538b2bd3fb43bdfcffc05b
child 626063 4f28fa57c2f4a2901c9a2276fe47e18b07175764
push id56020
push usermozilla@buttercookie.de
push dateWed, 26 Apr 2017 18:35:14 +0000
reviewersdaleharvey, walkingice
bugs1353857
milestone55.0a1
Bug 1353857 - Include the tab ID when notifying about leaving/entering a web app's scope. r?daleharvey,walkingice We only want to process the AppEntered/Left message if it actually concerns our currently displayed tab. MozReview-Commit-ID: EJ8RzRzDNAz
mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java
@@ -106,16 +106,19 @@ public class WebAppActivity extends Sing
     @Override
     public int getLayout() {
         return R.layout.customtabs_activity;
     }
 
     @Override
     public void handleMessage(final String event, final GeckoBundle message,
                               final EventCallback callback) {
+        if (!message.containsKey("tabId") || message.getInt("tabId") != mLastSelectedTabId) {
+            return;
+        }
         switch (event) {
             case "Website:AppEntered":
                 getSupportActionBar().hide();
                 break;
 
             case "Website:AppLeft":
                 getSupportActionBar().show();
                 break;
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2197,22 +2197,26 @@ var BrowserApp = {
 
     return {
       "historyItems": listitems,
       "toIndex": toIndex
     };
   },
 };
 
-async function notifyManifestStatus(browser) {
+async function notifyManifestStatus(tab) {
   try {
-    const manifest = await Manifests.getManifest(browser);
+    const manifest = await Manifests.getManifest(tab.browser);
     const evtType = (manifest && manifest.installed) ?
       "Website:AppEntered" : "Website:AppLeft";
-    GlobalEventDispatcher.sendRequest({type: evtType});
+
+    GlobalEventDispatcher.sendRequest({
+      type: evtType,
+      tabId: tab.id,
+    });
   } catch (err) {
     Cu.reportError("Error sending status: " + err.message);
   }
 }
 
 async function installManifest(browser, data) {
   try {
     const manifest = await Manifests.getManifest(browser, data.manifestUrl);
@@ -4510,17 +4514,17 @@ Tab.prototype = {
       sameDocument: sameDocument,
 
       canGoBack: webNav.canGoBack,
       canGoForward: webNav.canGoForward,
     };
 
     GlobalEventDispatcher.sendRequest(message);
 
-    notifyManifestStatus(this.browser);
+    notifyManifestStatus(this);
 
     if (!sameDocument) {
       // XXX This code assumes that this is the earliest hook we have at which
       // browser.contentDocument is changed to the new document we're loading
       this.contentDocumentIsDisplayed = false;
       this.hasTouchListener = false;
       Services.obs.notifyObservers(this.browser, "Session:NotifyLocationChange");
     }