Bug 1530402 - Add package-protected isPopup setting to hide GeckoSessions from extensions. r=snorp
☠☠ backed out by 8f3cbd66bbc3 ☠ ☠
authorAgi Sferro <agi@sferro.dev>
Wed, 13 Nov 2019 20:29:10 +0000
changeset 501841 e34768ee01dba733f233198ee4395854dc3e6670
parent 501840 b540d7b34ef64ef5989ebe8a84403d58bb5281b6
child 501842 9717ba25582634470b0252311e6585404132273e
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [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.