Closed Bug 1597879 Opened 5 years ago Closed 5 years ago

Implement Page.addScriptToEvaluateOnNewDocument

Categories

(Remote Protocol :: CDP, enhancement, P1)

enhancement

Tracking

(firefox73 fixed)

RESOLVED FIXED
Tracking Status
firefox73 --- fixed

People

(Reporter: impossibus, Assigned: impossibus)

References

Details

(Whiteboard: [puppeteer-alpha-reserve])

Attachments

(1 file)

Evaluates given script in every frame upon creation (before loading frame's scripts) and returns script's id.

Example

"method":"Page.addScriptToEvaluateOnNewDocument","params":{"source":"//# sourceURL=__puppeteer_evaluation_script__","worldName":"__puppeteer_utility_world__"}
"result":{"identifier":"1"}

Since this figures in Puppeteer's FrameManager._ensureIsolatedWorld, it might also block many gutenberg tests as in https://bugzilla.mozilla.org/show_bug.cgi?id=1597877#c1 -- but this is unclear right now.

Priority: P2 → P3

Three concerns that should be investigated here:

  • How does Chromium deal with deprecation in the script cache?
  • Is there a memory limitation on the maximum number of allowed scripts?
  • When during document loading is the script evaluated? (load vs DOMContentLoaded for example)
Whiteboard: [puppeteer-alpha] → [puppeteer-alpha-reserve]

Another thing which comes into my mind is also the order of the scripts to evaluate. There could be code that gets modified by multiple registered scripts. As such the order would matter. Maybe it is just by the time when scripts got added.

Whiteboard: [puppeteer-alpha-reserve] → [puppeteer-alpha]
Priority: P3 → P2
Priority: P2 → P3
Whiteboard: [puppeteer-alpha] → [puppeteer-alpha-reserve]

If the "worldName" parameter is specified, then this command "creates an isolated world with the given name and evaluates given script in it. This world name will be used as the ExecutionContextDescription::name when the corresponding event is emitted."

This part is what creates the "secondary world" in Puppeteer after each navigation, so it's definitely blocking gutenberg and more. It's the other piece of the puzzle, alongside Bug 1597877.

Looks like Puppeteer registers a dummy script with this command and only relies on it for execution contexts for their "secondary world", as described above.

Assignee: nobody → mjzffr
Status: NEW → ASSIGNED
Priority: P3 → P1
Pushed by mjzffr@gmail.com: https://hg.mozilla.org/integration/autoland/rev/f988a09bb821 Implement Page.addScriptToEvaluateOnNewDocument; r=remote-protocol-reviewers,whimboo,ato
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Regressions: 1603984
Component: CDP: Page → CDP
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: