Skip to content
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

Merged
merged 1 commit into from Jan 22, 2019

Conversation

aslushnikov
Copy link
Contributor

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, whereas frame.waitForSelector in secondary.

Fix #3327.

@aslushnikov aslushnikov deleted the helper-dom-world branch January 22, 2019 20:48
@aslushnikov aslushnikov restored the helper-dom-world branch January 22, 2019 20:55
@aslushnikov aslushnikov reopened this Jan 22, 2019
This patch starts creating secondary DOMWorld for every connected
page and switches `page.select()` to run inside the secondary world.

Fix puppeteer#3327.
const {LifecycleWatcher} = require('./LifecycleWatcher');
const {DOMWorld} = require('./DOMWorld');

const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';

Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -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()),
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@aslushnikov aslushnikov merged commit 678b8e8 into puppeteer:master Jan 22, 2019
@aslushnikov aslushnikov deleted the helper-dom-world branch January 22, 2019 22:55
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.

None yet

2 participants