[Extensions] Disable browser namespace for extensions with devtools [chromium/src : main]

0 views
Skip to first unread message

Justin Lulejian (Gerrit)

unread,
Jan 23, 2026, 12:04:16 PM (8 days ago) Jan 23
to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
Attention needed from Devlin Cronin

Justin Lulejian added 1 comment

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Justin Lulejian . resolved

Hi Devlin! Keeping it consistent with devtools related CLs 😄 I use the manifest key in the extension to detect if the extension could use the devtools API. Do you think that is robust enough of a check?

Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
Gerrit-Change-Number: 7511146
Gerrit-PatchSet: 4
Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Comment-Date: Fri, 23 Jan 2026 17:04:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Jan 23, 2026, 4:31:58 PM (7 days ago) Jan 23
to Justin Lulejian, Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
Attention needed from Justin Lulejian

Devlin Cronin added 5 comments

Patchset-level comments
Devlin Cronin . resolved

Thanks, Justin! This mostly looks good, but a couple comments

File extensions/common/extension_features.h
Line 328, Patchset 4 (Latest):bool IsExtensionBrowserNamespaceAndPolyfillSupportEnabledForExtension(
Devlin Cronin . unresolved

I think this would be cleaner putting it more proximal to the code that uses it; I worry that otherwise, extension_features will explode in size (if everything puts logic related to the _application_ of the feature here)

File extensions/common/extension_features.cc
Line 205, Patchset 4 (Latest): !manifest_values.Find(extensions::manifest_keys::kDevToolsPage);
Devlin Cronin . unresolved

I think using `!GetDevToolsPage(extension).is_empty()` is maybe more robust. That would validate that the value is present in the manifest, can be used by the extension (i.e., is available), and is valid.

File extensions/renderer/api/messaging/one_time_message_handler.cc
Line 100, Patchset 4 (Latest): return script_context && script_context->extension() &&
Devlin Cronin . unresolved

this means it's not enabled for non-extension contexts -- this controls the promise-based returns of messaging, right? If so, I think we also want that in web contexts?

Line 106, Patchset 4 (Latest):bool IsMessagePolyfillSupportEnabled(ScriptContext& script_context) {
Devlin Cronin . unresolved

nit: we should probably just update callers to adapt them to use the variant above

Open in Gerrit

Related details

Attention is currently required from:
  • Justin Lulejian
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
    Gerrit-Change-Number: 7511146
    Gerrit-PatchSet: 4
    Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
    Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
    Gerrit-Comment-Date: Fri, 23 Jan 2026 21:31:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Justin Lulejian (Gerrit)

    unread,
    Jan 23, 2026, 7:55:07 PM (7 days ago) Jan 23
    to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
    Attention needed from Devlin Cronin

    Justin Lulejian added 4 comments

    File extensions/common/extension_features.h
    Line 328, Patchset 4:bool IsExtensionBrowserNamespaceAndPolyfillSupportEnabledForExtension(
    Devlin Cronin . resolved

    I think this would be cleaner putting it more proximal to the code that uses it; I worry that otherwise, extension_features will explode in size (if everything puts logic related to the _application_ of the feature here)

    Justin Lulejian

    Done

    File extensions/common/extension_features.cc
    Line 205, Patchset 4: !manifest_values.Find(extensions::manifest_keys::kDevToolsPage);
    Devlin Cronin . resolved

    I think using `!GetDevToolsPage(extension).is_empty()` is maybe more robust. That would validate that the value is present in the manifest, can be used by the extension (i.e., is available), and is valid.

    Justin Lulejian

    Done

    File extensions/renderer/api/messaging/one_time_message_handler.cc
    Line 100, Patchset 4: return script_context && script_context->extension() &&
    Devlin Cronin . resolved

    this means it's not enabled for non-extension contexts -- this controls the promise-based returns of messaging, right? If so, I think we also want that in web contexts?

    Justin Lulejian

    Done

    Line 106, Patchset 4:bool IsMessagePolyfillSupportEnabled(ScriptContext& script_context) {
    Devlin Cronin . resolved

    nit: we should probably just update callers to adapt them to use the variant above

    Justin Lulejian

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Devlin Cronin
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
      Gerrit-Change-Number: 7511146
      Gerrit-PatchSet: 6
      Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Comment-Date: Sat, 24 Jan 2026 00:55:01 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Devlin Cronin (Gerrit)

      unread,
      Jan 26, 2026, 2:19:22 PM (4 days ago) Jan 26
      to Justin Lulejian, Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
      Attention needed from Justin Lulejian

      Devlin Cronin voted and added 2 comments

      Votes added by Devlin Cronin

      Code-Review+1

      2 comments

      Patchset-level comments
      File-level comment, Patchset 6 (Latest):
      Devlin Cronin . resolved

      LGTM; thanks, Justin!

      File extensions/renderer/api/messaging/one_time_message_handler.cc
      Line 105, Patchset 6 (Latest): if (extension) {
      return IsExtensionBrowserNamespaceAndPolyfillSupportEnabledForExtension(
      extension);
      }
      // For example a non-extension webpage that can communicate with extensions.
      return base::FeatureList::IsEnabled(
      extensions_features::kExtensionBrowserNamespaceAndPolyfillSupport);
      Devlin Cronin . unresolved

      optional: I'd use a ternary here to save a couple lines, but up to you

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Justin Lulejian
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
      Gerrit-Change-Number: 7511146
      Gerrit-PatchSet: 6
      Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Comment-Date: Mon, 26 Jan 2026 19:19:10 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Devlin Cronin (Gerrit)

      unread,
      Jan 27, 2026, 4:10:15 PM (3 days ago) Jan 27
      to Justin Lulejian, Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
      Attention needed from Justin Lulejian

      Devlin Cronin voted and added 4 comments

      Votes added by Devlin Cronin

      Code-Review+1

      4 comments

      Patchset-level comments
      File-level comment, Patchset 7 (Latest):
      Devlin Cronin . resolved

      s lgtm

      File extensions/renderer/native_extension_bindings_system.cc
      Line 754, Patchset 7 (Latest): url::Origin::Create(
      chrome_manifest_urls::GetDevToolsPage(extension)) &&
      Devlin Cronin . unresolved

      nit: prefer just using extension->origin() (it should be guaranteed to be the same origin as the devtools page)

      File extensions/renderer/native_extension_bindings_system_unittest.cc
      Line 1484, Patchset 7 (Latest): .SetManifestVersion(3)
      Devlin Cronin . unresolved

      nit: unnecessary (this is the default)

      Line 1503, Patchset 7 (Latest): EXPECT_TRUE(browser->IsUndefined());
      Devlin Cronin . unresolved

      optional: could verify that `chrome` is available as a safety check

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Justin Lulejian
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
      Gerrit-Change-Number: 7511146
      Gerrit-PatchSet: 7
      Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
      Gerrit-Comment-Date: Tue, 27 Jan 2026 21:10:03 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Justin Lulejian (Gerrit)

      unread,
      Jan 30, 2026, 3:56:23 PM (9 hours ago) Jan 30
      to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
      Attention needed from Devlin Cronin

      Justin Lulejian voted and added 5 comments

      Votes added by Justin Lulejian

      Auto-Submit+1

      5 comments

      Patchset-level comments
      File-level comment, Patchset 8:
      Justin Lulejian . resolved

      Hi Devlin! Unfortunately the upstream changes seem to have subtracted the +1, but there's little significant diff between patchset 7 and 9.

      File extensions/renderer/api/messaging/one_time_message_handler.cc
      Line 105, Patchset 6: if (extension) {

      return IsExtensionBrowserNamespaceAndPolyfillSupportEnabledForExtension(
      extension);
      }
      // For example a non-extension webpage that can communicate with extensions.
      return base::FeatureList::IsEnabled(
      extensions_features::kExtensionBrowserNamespaceAndPolyfillSupport);
      Devlin Cronin . resolved

      optional: I'd use a ternary here to save a couple lines, but up to you

      Justin Lulejian

      I love a ternary but curiously enough it ends up adding a couple lines due to the length of the method/feature names and format wrapping (at least when I tried `return extension ? ...;`) so I'll stick with it as-is in this case.

      File extensions/renderer/native_extension_bindings_system.cc
      Line 754, Patchset 7: url::Origin::Create(
      chrome_manifest_urls::GetDevToolsPage(extension)) &&
      Devlin Cronin . resolved

      nit: prefer just using extension->origin() (it should be guaranteed to be the same origin as the devtools page)

      Justin Lulejian
      File extensions/renderer/native_extension_bindings_system_unittest.cc
      Line 1484, Patchset 7: .SetManifestVersion(3)
      Devlin Cronin . resolved

      nit: unnecessary (this is the default)

      Justin Lulejian

      Removed this test upstream since it wasn't going to work as a unit test after I made the new devtools context check.

      Line 1503, Patchset 7: EXPECT_TRUE(browser->IsUndefined());
      Devlin Cronin . resolved

      optional: could verify that `chrome` is available as a safety check

      Justin Lulejian

      Ditto to above.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Devlin Cronin
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
        Gerrit-Change-Number: 7511146
        Gerrit-PatchSet: 9
        Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
        Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
        Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
        Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
        Gerrit-Comment-Date: Fri, 30 Jan 2026 20:56:17 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Devlin Cronin (Gerrit)

        unread,
        Jan 30, 2026, 3:59:14 PM (9 hours ago) Jan 30
        to Justin Lulejian, Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
        Attention needed from Justin Lulejian

        Devlin Cronin voted and added 1 comment

        Votes added by Devlin Cronin

        Code-Review+1
        Commit-Queue+2

        1 comment

        Patchset-level comments
        File-level comment, Patchset 9 (Latest):
        Devlin Cronin . resolved

        LGTM; thanks, Justin!

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Justin Lulejian
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
          Gerrit-Change-Number: 7511146
          Gerrit-PatchSet: 9
          Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
          Gerrit-Attention: Justin Lulejian <jlul...@chromium.org>
          Gerrit-Comment-Date: Fri, 30 Jan 2026 20:59:03 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Justin Lulejian (Gerrit)

          unread,
          Jan 30, 2026, 5:34:09 PM (7 hours ago) Jan 30
          to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

          Justin Lulejian voted Commit-Queue+2

          Commit-Queue+2
          Open in Gerrit

          Related details

          Attention set is empty
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
          Gerrit-Change-Number: 7511146
          Gerrit-PatchSet: 10
          Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
          Gerrit-Comment-Date: Fri, 30 Jan 2026 22:34:00 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Justin Lulejian (Gerrit)

          unread,
          Jan 30, 2026, 5:35:37 PM (7 hours ago) Jan 30
          to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
          Gerrit-Comment-Date: Fri, 30 Jan 2026 22:35:28 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          satisfied_requirement
          open
          diffy

          Chromium LUCI CQ (Gerrit)

          unread,
          Jan 30, 2026, 6:41:22 PM (6 hours ago) Jan 30
          to Justin Lulejian, Devlin Cronin, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

          Chromium LUCI CQ submitted the change

          Unreviewed changes

          9 is the latest approved patch-set.
          No files were changed between the latest approved patch-set and the submitted one.

          Change information

          Commit message:
          [Extensions] Disable browser namespace for extensions with devtools

          Before this change the kExtensionBrowserNamespaceAndPolyfillSupport
          feature, when enabled, applied to all extensions. This caused an issue
          because some extensions using the (webextension
          polyfill](https://github.com/mozilla/webextension-polyfill) were using
          it to allow promise returns from devtools API calls that are not
          supported by the API itself. When the
          kExtensionBrowserNamespaceAndPolyfillSupport turned on it would no-op
          the webextension-polyfill and these calls would be syntax errors.

          After this change we use
          IsExtensionBrowserNamespaceAndPolyfillSupportEnabledForExtension() to
          disable the feature for extension script contexts when the extension
          has a devtools_page (and could use the devtools API). This restricts
          the browser namespace and polyfill support from being enabled for all
          script contexts for these specific extensions.

          Also:
          * updates NativeExtensionBindingsSystem and OneTimeMessageHandler to
          use this extension-specific check.
          * updates tests to reflect that browser is undefined in these
          contexts and disables the DevToolsApiAliasing test since it's not
          relevant until this exception is eventually removed.

          Bug: 401226626,439644930,40753031


          in prog devtools bypass
          Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
          Commit-Queue: Justin Lulejian <jlul...@chromium.org>
          Reviewed-by: Devlin Cronin <rdevlin...@chromium.org>
          Auto-Submit: Justin Lulejian <jlul...@chromium.org>
          Cr-Commit-Position: refs/heads/main@{#1577601}
          Files:
          • M chrome/browser/extensions/native_bindings_apitest.cc
          • M extensions/renderer/BUILD.gn
          • M extensions/renderer/api/messaging/one_time_message_handler.cc
          • M extensions/renderer/native_extension_bindings_system.cc
          • A extensions/renderer/polyfill_util.cc
          • A extensions/renderer/polyfill_util.h
          Change size: M
          Delta: 6 files changed, 129 insertions(+), 58 deletions(-)
          Branch: refs/heads/main
          Submit Requirements:
          • requirement satisfiedCode-Review: +1 by Devlin Cronin
          Open in Gerrit
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: merged
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ib6dd8dfd45d820511c24906ffaea9f1a87e5f8a7
          Gerrit-Change-Number: 7511146
          Gerrit-PatchSet: 11
          Gerrit-Owner: Justin Lulejian <jlul...@chromium.org>
          Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Reviewer: Justin Lulejian <jlul...@chromium.org>
          open
          diffy
          satisfied_requirement
          Reply all
          Reply to author
          Forward
          0 new messages