Skip to content

Commit

Permalink
feat(page): use secondary world to drive clicks (#3828)
Browse files Browse the repository at this point in the history
References #2671
  • Loading branch information
aslushnikov committed Jan 23, 2019
1 parent 89a5c39 commit fb71012
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/FrameManager.js
Expand Up @@ -472,15 +472,15 @@ class Frame {
* @return {!Promise<String>}
*/
async content() {
return this._mainWorld.content();
return this._secondaryWorld.content();
}

/**
* @param {string} html
* @param {!{timeout?: number, waitUntil?: string|!Array<string>}=} options
*/
async setContent(html, options = {}) {
return this._mainWorld.setContent(html, options);
return this._secondaryWorld.setContent(html, options);
}

/**
Expand Down Expand Up @@ -539,21 +539,21 @@ class Frame {
* @param {!{delay?: number, button?: "left"|"right"|"middle", clickCount?: number}=} options
*/
async click(selector, options) {
return this._mainWorld.click(selector, options);
return this._secondaryWorld.click(selector, options);
}

/**
* @param {string} selector
*/
async focus(selector) {
return this._mainWorld.focus(selector);
return this._secondaryWorld.focus(selector);
}

/**
* @param {string} selector
*/
async hover(selector) {
return this._mainWorld.hover(selector);
return this._secondaryWorld.hover(selector);
}

/**
Expand All @@ -569,7 +569,7 @@ class Frame {
* @param {string} selector
*/
async tap(selector) {
return this._mainWorld.tap(selector);
return this._secondaryWorld.tap(selector);
}

/**
Expand Down Expand Up @@ -634,7 +634,7 @@ class Frame {
* @return {!Promise<string>}
*/
async title() {
return this._mainWorld.title();
return this._secondaryWorld.title();
}

/**
Expand Down
6 changes: 6 additions & 0 deletions test/click.spec.js
Expand Up @@ -28,6 +28,12 @@ module.exports.addTests = function({testRunner, expect}) {
await page.click('button');
expect(await page.evaluate(() => result)).toBe('Clicked');
});
it('should click the button if window.Node is removed', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.evaluate(() => delete window.Node);
await page.click('button');
expect(await page.evaluate(() => result)).toBe('Clicked');
});
it('should click the button after navigation ', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.click('button');
Expand Down
6 changes: 6 additions & 0 deletions test/mouse.spec.js
Expand Up @@ -64,6 +64,12 @@ module.exports.addTests = function({testRunner, expect}) {
await page.hover('#button-91');
expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-91');
});
it('should trigger hover state with removed window.Node', async({page, server}) => {
await page.goto(server.PREFIX + '/input/scrollable.html');
await page.evaluate(() => delete window.Node);
await page.hover('#button-6');
expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6');
});
it('should set modifier keys on click', async({page, server}) => {
await page.goto(server.PREFIX + '/input/scrollable.html');
await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window.lastEvent = e, true));
Expand Down

0 comments on commit fb71012

Please sign in to comment.