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): execute frame.waitFor{Selector,XPath} in secondary world #3856
fix(page): execute frame.waitFor{Selector,XPath} in secondary world #3856
Conversation
This patch starts executing frame.waitForSelector and frame.waitForXPath in secondary world. As a result, websites that mutate page global context (e.g. removing global MutationObserver) don't break Puppeteer's behavior. Fixes puppeteer#609
* @return {Promise<Puppeteer.ElementHandle>} | ||
*/ | ||
async _adoptElementHandle(elementHandle) { | ||
assert(elementHandle.executionContext() !== this, 'Cannot adopt handle that already belongs to this execution context'); |
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.
Fine for now. But in the case of a future public version we should probably return elementHandle
here instead of asserting.
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.
Public API will be either on DOMWorld or on ElementHandle, so we'll have an opportunity to think about it
objectId: elementHandle._remoteObject.objectId, | ||
}); | ||
const {object} = await this._client.send('DOM.resolveNode', { | ||
backendNodeId: nodeInfo.node.backendNodeId, |
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.
how does this work without taking a worldName?
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.
Follow-up: #3857
This patch starts executing frame.waitForSelector and frame.waitForXPath
in secondary world. As a result, websites that mutate page global
context (e.g. removing global MutationObserver) don't break Puppeteer's
behavior.
Fixes #609