Skip to content

feat(popups): add BrowserContext.evaluateOnNewDocument - #1136

Merged
Dmitry Gozman (dgozman) merged 1 commit into
microsoft:masterfrom
dgozman:bc-eval-on-new-doc
Feb 28, 2020
Merged

Dmitry Gozman (dgozman) merged 1 commit into
microsoft:masterfrom
dgozman:bc-eval-on-new-doc

Conversation

@dgozman

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread docs/api.md Outdated
- returns: <[Promise]>

Adds a function which would be invoked in one of the following scenarios:
- whenever the page is navigated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whenever a page is created in the context or navigated

Comment thread docs/api.md Outdated

Adds a function which would be invoked in one of the following scenarios:
- whenever the page is navigated
- whenever the child frame is attached or navigated. In this case, the function is invoked in the context of the newly attached frame

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whenever a child frame is attached or navigated in a page in the browser context

Comment thread docs/api.md Outdated
// preload.js

// overwrite the `languages` property to use a custom getter
Object.defineProperty(navigator, "languages", {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a better support for overriding locale, so maybe rewrite the example to use aforementioned Math.random ?

Comment thread docs/api.md
await page.evaluateOnNewDocument(preloadFile);
```

> **NOTE** The order of evaluation of multiple scripts installed via [browserContext.evaluateOnNewDocument(pageFunction[, ...args])](#browsercontextevaluateonnewdocumentpagefunction-args) and [page.evaluateOnNewDocument(pageFunction[, ...args])](#pageevaluateonnewdocumentpagefunction-args) is not defined.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it deterministic, is it chromium backend limitation?

@dgozman
Dmitry Gozman (dgozman) merged commit 7682865 into microsoft:master Feb 28, 2020
Debbie O'Brien (debs-obrien) pushed a commit to debs-obrien/playwright that referenced this pull request Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants