Closed FWeinb closed 6 years ago
Hah. this PR really sent me on a journey.
page.evaluateOnNewDocument
uses Page.addScriptToEvaluateOnNewDocument
, which says that it applies within iframes.. But that's not working here.
But note this iframe uses iframe.srcdoc = 'about:blank';
. That actually doesn't make sense, as you set the content of the iframe with srcdoc. So it should be iframe.srcdoc = 'page intentionally left blank';
. 😛
Anyhow, if you use the [src] attribute, like iframe.src = 'about:blank';
... then the addScriptToEvaluateOnNewDocument
succeeds.
I'm not sure why there's a difference here, but it at least seems related to this report: https://github.com/GoogleChrome/puppeteer/issues/1106
I think i've found two chromium bugs, thanks to this PR. ;)
details in https://github.com/GoogleChrome/puppeteer/issues/1106#issuecomment-359313898
This is a tricky detection. We can use an iframe to get a fresh
window
object and use that to potential rerun all the tests we did on the firstwindow
object.I mocked the tests for this to show how it would go. The
apply-evasion
script should be injected into each JS context and not only the first one.