New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(page): use secondary DOMWorld to drive page.select() #3809
Conversation
This patch starts creating secondary DOMWorld for every connected page and switches `page.select()` to run inside the secondary world. Fix puppeteer#3327.
47298f2
to
00a21ab
Compare
const {LifecycleWatcher} = require('./LifecycleWatcher'); | ||
const {DOMWorld} = require('./DOMWorld'); | ||
|
||
const UTILITY_WORLD_NAME = '__puppeteer_utility_world__'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s cover connecting two puppeteers to a browser with a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have it already - https://github.com/GoogleChrome/puppeteer/blob/c09835fd70e144cb705eb5ae8b169e49725532bd/test/puppeteer.spec.js#L305-L316
It caused me troubles.
@@ -50,7 +50,7 @@ class Page extends EventEmitter { | |||
client.send('Target.setAutoAttach', {autoAttach: true, waitForDebuggerOnStart: false}), | |||
client.send('Page.setLifecycleEventsEnabled', { enabled: true }), | |||
client.send('Network.enable', {}), | |||
client.send('Runtime.enable', {}), | |||
client.send('Runtime.enable', {}).then(() => page._frameManager.ensureSecondaryDOMWorld()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this have to happen after runtime.enable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All execution contexts will be reported before Runtime.enable returns. If there's the one with helper isolated world, it'll be reported.
This patch starts creating secondary DOMWorld for every connected
page and switches
page.select()
to run inside the secondary world.Drive-by: move
DOMWorld.waitFor
into Frame: in future, the shortcut will expand into calls in different DOMWorlds, e.g.frame.waitForFunction
should be always run in main world, whereasframe.waitForSelector
in secondary.Fix #3327.