Skip to content

[Feature]: [Extensions] Code injection before any Extension code runs #3852

Open
@RendijsSmukulis

Description

@RendijsSmukulis

Describe the feature/enhancement you need

To achieve some functionality, we had to change the behaviour of some Chrome Extension APIs, for example chrome.tabs.query . This was achieved by injecting JS shims into the extension code which replaced the API behaviour.

There are currently two ways we found to inject JS into extensions:

  1. runtime: attaching chrome devtools session to the extension, then calling "Runtime.evaluate" to execute JS in the context of the extension. This then replaces the real API (e.g. chrome.tabs.query) with the modified one.
  2. at rest: modify the extension file itself. While doable, this can cause licensing issues with software that can't have its sources modified.

The "runtime" approach would be ideal, however there is currently a timing issue - there is no way to guarantee execution of the injected shim code before extension code starts executing. For websites, we could use a workaround by using chromium devtools to ensure they websites start in a "wait for debugger" mode, but we have not yet discovered a way how to load extension in the same manner.

Ideally, an API similar to AddScriptToExecuteOnDocumentCreatedAsync would be provided for extensions as well.

The scenario/use case where you would use this feature

As we're building a browser with intention to host extensions, some amount of app-to-extension communication needs to happen as we need to re-implement some of the chrome extension APIs, e.g. chrome.tabs.query

How important is this request to you?

Impactful. My app's user experience would be significantly compromised without it.

Suggested implementation

No response

What does your app do? Is there a pending deadline for this request?

No response

AB#46892733

Metadata

Metadata

Labels

feature requestfeature requesttrackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions