Bug 1530402 - Add package-protected isPopup setting to hide GeckoSessions from extensions. r=snorp
☠☠ backed out by 17db3abeba1a ☠ ☠
authorAgi Sferro <agi@sferro.dev>
Thu, 14 Nov 2019 19:08:42 +0000
changeset 563879 701de7bcb4840b7bdd70dbf3ecb44ffc46e0d2d8
parent 563878 ab7b21969769b3296eb6de6e67d988d6792cf71a
child 563880 f57bc0ee284b453b2f619cb6e735f0c69512ea12
push id12351
push userffxbld-merge
push dateMon, 02 Dec 2019 11:32:26 +0000
treeherdermozilla-beta@dba4410526a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1530402
milestone72.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 1530402 - Add package-protected isPopup setting to hide GeckoSessions from extensions. r=snorp Differential Revision: https://phabricator.services.mozilla.com/D51918
mobile/android/chrome/geckoview/geckoview.js
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSessionSettings.java
--- a/mobile/android/chrome/geckoview/geckoview.js
+++ b/mobile/android/chrome/geckoview/geckoview.js
@@ -192,16 +192,21 @@ var ModuleManager = {
     this.browser.focus();
     return true;
   },
 
   _updateSettings(aSettings) {
     Object.assign(this._settings, aSettings);
     this._frozenSettings = Object.freeze(Object.assign({}, this._settings));
 
+    const windowType = aSettings.isPopup
+      ? "navigator:popup"
+      : "navigator:geckoview";
+    window.document.documentElement.setAttribute("windowType", windowType);
+
     this.forEach(module => {
       if (module.impl) {
         module.impl.onSettingsUpdate();
       }
     });
 
     this._browser.messageManager.sendAsyncMessage(
       "GeckoView:UpdateSettings",
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSessionSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSessionSettings.java
@@ -332,16 +332,23 @@ public final class GeckoSessionSettings 
             new Key<Boolean>("allowJavascript", /* initOnly */ false, /* values */ null);
     /**
      * Key to specify if entire accessible tree should be exposed with no caching.
      */
     private static final Key<Boolean> FULL_ACCESSIBILITY_TREE =
             new Key<Boolean>("fullAccessibilityTree", /* initOnly */ false, /* values */ null);
 
     /**
+     * Key to specify if this GeckoSession is a Popup or not. Popup sessions can paint over other
+     * sessions and are not exposed to the tabs WebExtension API.
+     */
+    private static final Key<Boolean> IS_POPUP =
+            new Key<Boolean>("isPopup", /* initOnly */ false, /* values */ null);
+
+    /**
      * Internal Gecko key to specify the session context ID.
      * Derived from `UNSAFE_CONTEXT_ID`.
      */
     private static final Key<String> CONTEXT_ID =
         new Key<String>("sessionContextId", /* initOnly */ true, /* values */ null);
 
     /**
      * User-provided key to specify the session context ID.
@@ -373,16 +380,17 @@ public final class GeckoSessionSettings 
         mBundle.putString(CHROME_URI.name, null);
         mBundle.putInt(SCREEN_ID.name, 0);
         mBundle.putBoolean(USE_TRACKING_PROTECTION.name, false);
         mBundle.putBoolean(USE_PRIVATE_MODE.name, false);
         mBundle.putBoolean(USE_MULTIPROCESS.name, true);
         mBundle.putBoolean(SUSPEND_MEDIA_WHEN_INACTIVE.name, false);
         mBundle.putBoolean(ALLOW_JAVASCRIPT.name, true);
         mBundle.putBoolean(FULL_ACCESSIBILITY_TREE.name, false);
+        mBundle.putBoolean(IS_POPUP.name, false);
         mBundle.putInt(USER_AGENT_MODE.name, USER_AGENT_MODE_MOBILE);
         mBundle.putString(USER_AGENT_OVERRIDE.name, null);
         mBundle.putInt(VIEWPORT_MODE.name, VIEWPORT_MODE_MOBILE);
         mBundle.putInt(DISPLAY_MODE.name, DISPLAY_MODE_BROWSER);
         mBundle.putString(CONTEXT_ID.name, null);
         mBundle.putString(UNSAFE_CONTEXT_ID.name, null);
     }
 
@@ -444,16 +452,20 @@ public final class GeckoSessionSettings 
      *
      * @param value A flag determining full accessibility tree should be exposed.
      *             Default is false.
      */
     public void setFullAccessibilityTree(final boolean value) {
         setBoolean(FULL_ACCESSIBILITY_TREE, value);
     }
 
+    /* package */ void setIsPopup(final boolean value) {
+        setBoolean(IS_POPUP, value);
+    }
+
     private void setBoolean(final Key<Boolean> key, final boolean value) {
         synchronized (mBundle) {
             if (valueChangedLocked(key, value)) {
                 mBundle.putBoolean(key.name, value);
                 dispatchUpdate();
             }
         }
     }
@@ -517,16 +529,20 @@ public final class GeckoSessionSettings 
      * Whether entire accessible tree is exposed with no caching.
      *
      * @return true if accessibility tree is exposed, false if not.
      */
     public boolean getFullAccessibilityTree() {
         return getBoolean(FULL_ACCESSIBILITY_TREE);
     }
 
+    /* package */ boolean getIsPopup() {
+        return getBoolean(IS_POPUP);
+    }
+
     private boolean getBoolean(final Key<Boolean> key) {
         synchronized (mBundle) {
             return mBundle.getBoolean(key.name);
         }
     }
 
     /**
      * Set the screen id.