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 569606 edd1af6d7027507ecd85c30f74881e1342d821c3
parent 569605 84d995d9822831c10633f776ab309f2f55d4e4d8
child 626260 400b4cb4629d3e31bca20139112b0d19ced5bdb1
push id56233
push usermozilla@buttercookie.de
push dateThu, 27 Apr 2017 18:05:05 +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,21 @@ 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 == null ||
+                !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
@@ -2196,22 +2196,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);
@@ -4509,17 +4513,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");
     }