Bug 1985997 Comment 3 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

> There seem to be some kind of delay until the preload settings are getting applied.

Note that Playwright expects preload scripts to run *synchronously* in `window.open()`: [This test](https://github.com/microsoft/playwright/blob/f07c8c0ac4d07865c4d7ea3696dc7d8e8ce6572f/tests/library/popup.spec.ts#L222-L243) exposes a binding (which is implemented using `script.addPreloadScript`) and uses it immediately after `window.open('about:blank')`.
The test works if I add `await new Promise(r => win.onload = r)` immediately after `window.open('about:blank')`. So in this case the preload scripts are run, but with some delay.
If I change `window.open('about:blank')` to `window.open()`, the test times out, apparently the `win.onload` callback is never called in this case. If I then change `await new Promise(r => win.onload = r)` to `await new Promise(r => setTimeout(r, 1000))`, the test fails with the error message `TypeError: win.add is not a function`, so apparently the preload script does not run at all in this case.
> There seem to be some kind of delay until the preload settings are getting applied.

Note that Playwright expects preload scripts to run *synchronously* in `window.open()`: [This test](https://github.com/microsoft/playwright/blob/f07c8c0ac4d07865c4d7ea3696dc7d8e8ce6572f/tests/library/popup.spec.ts#L222-L243) exposes a binding (which is implemented using `script.addPreloadScript`) and uses it immediately after `window.open('about:blank')`.
The test works if I add `await new Promise(r => win.onload = r)` immediately after `window.open('about:blank')`. So in this case the preload scripts run, but with some delay.
If I change `window.open('about:blank')` to `window.open()`, the test times out, apparently the `win.onload` callback is never called in this case. If I then change `await new Promise(r => win.onload = r)` to `await new Promise(r => setTimeout(r, 1000))`, the test fails with the error message `TypeError: win.add is not a function`, so apparently the preload script does not run at all in this case.

Back to Bug 1985997 Comment 3