Open Bug 1735474 Opened 1 year ago Updated 10 months ago

[meta] Implement `scripting.executeScript()`

Categories

(WebExtensions :: General, enhancement, P2)

enhancement

Tracking

(Not tracked)

People

(Reporter: willdurand, Assigned: willdurand)

References

(Depends on 2 open bugs, Blocks 1 open bug)

Details

(Keywords: dev-doc-needed, meta)

Attachments

(1 obsolete file)

Bug 1687764 is about implementing the entire MV3 API. Let's start small and focus on executScript() only with this bug: https://developer.chrome.com/docs/extensions/reference/scripting/#method-executeScript

Attachment #9245672 - Attachment description: WIP: Bug 1735474 - Implement `browser.scripting.executeScript()` → WIP: Bug 1735474 - Implement `browser.scripting.executeScript()`. r=robwu
Severity: -- → N/A
Priority: -- → P2
Attachment #9245672 - Attachment description: WIP: Bug 1735474 - Implement `browser.scripting.executeScript()`. r=robwu → Bug 1735474 - Implement `browser.scripting.executeScript()`. r=robwu
Blocks: 1736574
Blocks: 1736575
Blocks: 1736576

One thing to maybe consider in the future, making target optional and defaulting to the active tab: https://bugs.chromium.org/p/chromium/issues/detail?id=1194519&q=component%3APlatform%3EExtensions%3EAPI

Depends on: 1739643

FYI relevant design docs from Chrome's side:

It seems that the documents are not accounting for non-serializable or non-callable functions. E.g.:

  • class X{} = cannot be called, only with new.
  • Math.min = function() { [native functon] } cannot be serialized.
  • new Proxy(function() {}, {}); = Proxy around function.
  • a = {async prop(){}, prop2() {}}; -> a.prop and a.prop2 cannot be called after trivial serialization ((async prop(){})() and (prop2(){})() are syntactically invalid)

The docs do account for cases where func.toString has been overridden with a custom implementation.
In practice, Xray vision in Firefox ensures that func.toString uses the native toString implementation, but it would be good to have unit tests nevertheless. Consider making that part of the initial patch, or a follow-up bug.

Depends on: 1740601
No longer blocks: 1736574, 1736575, 1736576
Depends on: 1736574, 1736575, 1736576
Summary: Implement `scripting.executeScript()` → [meta] Implement `scripting.executeScript()`

Comment on attachment 9245672 [details]
Bug 1735474 - Implement browser.scripting.executeScript(). r=robwu

Revision D128339 was moved to bug 1740601. Setting attachment 9245672 [details] to obsolete.

Attachment #9245672 - Attachment is obsolete: true
Type: task → enhancement
Depends on: 1740608
Depends on: 1740615
Whiteboard: [mv3-m2]
Depends on: 1750765
Depends on: 1751154
Depends on: 1759932

For scripting.executeScript(), we currently have a limitation around the world parameter. It only supports "ISOLATED", which is the default (see Bug 1759932). Adding support for other execution worlds is tracked in Bug 1736575.

Keywords: dev-doc-needed
Depends on: 1762366
Blocks: 1764566
You need to log in before you can comment on or make changes to this bug.