mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(page): page.click should work with disabled javascript (#2907)
Unfortunately, disabling javascript in page prevents any microtasks to be executed even from puppeteer-originating javascript. As a result, the IntersectionObserver hack we use to conditionally scroll into view doesn't work. To workaround this, we start always scrolling before clicking if page's javascript is disabled. Fixes #2898
This commit is contained in:
@@ -88,6 +88,7 @@ class Page extends EventEmitter {
|
||||
this._ignoreHTTPSErrors = ignoreHTTPSErrors;
|
||||
this._coverage = new Coverage(client);
|
||||
this._defaultNavigationTimeout = 30000;
|
||||
this._javascriptEnabled = true;
|
||||
|
||||
this._screenshotTaskQueue = screenshotTaskQueue;
|
||||
|
||||
@@ -714,6 +715,9 @@ class Page extends EventEmitter {
|
||||
* @param {boolean} enabled
|
||||
*/
|
||||
async setJavaScriptEnabled(enabled) {
|
||||
if (this._javascriptEnabled === enabled)
|
||||
return;
|
||||
this._javascriptEnabled = enabled;
|
||||
await this._client.send('Emulation.setScriptExecutionDisabled', { value: !enabled });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user