Skip to content

Conversation

@dgozman
Copy link
Contributor

@dgozman dgozman commented May 16, 2025

There are three distinct scenarios possible in Chromium today:

  • A page that is opened in a new renderer through BeginNavigation. Such a page will be always navigated to a new document with a new js context, so it does not matter whether we run the init script upon attach in the initial empty context or not.
  • A window.opened page in the same renderer. Such a page currently receives Page.addScriptToEvaluateOnNewDocument and immediately evaluates it. Switching to runImmediately has no effect.
  • A new page created through createWindow() when web security is disabled. Such a page does not run the init script after loading the target url, because the js context is reused (due to security being disabled). In this case, it is essential to run the init script immediately, which the new flag does.

This is covered by init script should run only once tests. See #31458 and #31096 fir prior art.

There are three distinct scenarios possible in Chromium today:
- A page that is opened in a new renderer through `BeginNavigation`.
  Such a page will be always navigated to a new context, so it
  does not matter whether we run the init script upon attach.
- A `window.open`ed page in the same renderer. Such a page currently
  receives `Page.addScriptToEvaluateOnNewDocument` and immediately
  evaluates it. Switching to `runImmediately` has no effect.
- A new page created through `createWindow()` when web security is
  disabled. Such a page does not run the init script after loading
  the target url, because the js context is reused (due to security
  being disabled). In this case, it is essential to run the init
  script immediately, which the new flag does.

This is covered by `init script should run only once` tests.
@github-actions
Copy link
Contributor

Test results for "tests 1"

5 flaky ⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:986:7 › cli codegen › should not throw csp directive violation errors @firefox-ubuntu-22.04-node18
⚠️ [webkit-library] › library/browsercontext-pages.spec.ts:82:3 › should click the button with offset with page scale @webkit-ubuntu-22.04-node18
⚠️ [webkit-library] › library/ignorehttpserrors.spec.ts:30:3 › should isolate contexts @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

39213 passed, 803 skipped
✔️✔️✔️

Merge workflow run.

@dgozman dgozman merged commit 0898662 into microsoft:main May 16, 2025
29 checks passed
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