Skip to content

Commit

Permalink
feat(chromium): roll Chromium to r705776 (puppeteer#5058)
Browse files Browse the repository at this point in the history
This corresponds to Chromium 79.0.3942.0.

This roll includes:

- Support CSS media feature emulation in CDP
  https://chromium-review.googlesource.com/c/chromium/src/+/1821608
- Implement timezone ID verification
  https://chromium-review.googlesource.com/c/chromium/src/+/1822557
- Allow aria-hidden objects into the browser-side ax tree
  https://chromium-review.googlesource.com/c/chromium/src/+/1760862
- Remove pre-BlinkGenPropertyTrees codepaths (affects screenshot clipping)
  https://chromium-review.googlesource.com/c/chromium/src/+/1752244
- Terminate some asynchronous waiting commands on cross-process navigation
  https://chromium-review.googlesource.com/c/chromium/src/+/1766001/21#message-a6a61261b97ffca6ecb180c0a2303b538f7a6476

Per upstream Chromium changes, `page.screenshot` now clips elements to the viewport. This matches the clipping behavior of elements in inner scrollers (i.e., document and overflow scroll clipping now work the same).
  • Loading branch information
mathiasbynens authored and Roman Fojtik committed Dec 21, 2019
1 parent 92d47b7 commit 3dd3f0c
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 45 deletions.
4 changes: 2 additions & 2 deletions experimental/puppeteer-firefox/lib/FrameManager.js
Expand Up @@ -171,7 +171,7 @@ class Frame {
} = options;
const normalizedWaitUntil = normalizeWaitUntil(waitUntil);

const timeoutError = new TimeoutError('Navigation Timeout Exceeded: ' + timeout + 'ms');
const timeoutError = new TimeoutError('Navigation timeout of ' + timeout + ' ms exceeded');
let timeoutCallback;
const timeoutPromise = new Promise(resolve => timeoutCallback = resolve.bind(null, timeoutError));
const timeoutId = timeout ? setTimeout(timeoutCallback, timeout) : null;
Expand Down Expand Up @@ -228,7 +228,7 @@ class Frame {
if (!navigationId)
return;

const timeoutError = new TimeoutError('Navigation Timeout Exceeded: ' + timeout + 'ms');
const timeoutError = new TimeoutError('Navigation timeout of ' + timeout + ' ms exceeded');
let timeoutCallback;
const timeoutPromise = new Promise(resolve => timeoutCallback = resolve.bind(null, timeoutError));
const timeoutId = timeout ? setTimeout(timeoutCallback, timeout) : null;
Expand Down
6 changes: 3 additions & 3 deletions experimental/puppeteer-firefox/lib/Page.js
Expand Up @@ -446,7 +446,7 @@ class Page extends EventEmitter {
if (!navigationId)
return null;

const timeoutError = new TimeoutError('Navigation Timeout Exceeded: ' + timeout + 'ms');
const timeoutError = new TimeoutError('Navigation timeout of ' + timeout + ' ms exceeded');
let timeoutCallback;
const timeoutPromise = new Promise(resolve => timeoutCallback = resolve.bind(null, timeoutError));
const timeoutId = timeout ? setTimeout(timeoutCallback, timeout) : null;
Expand Down Expand Up @@ -479,7 +479,7 @@ class Page extends EventEmitter {
if (!navigationId)
return null;

const timeoutError = new TimeoutError('Navigation Timeout Exceeded: ' + timeout + 'ms');
const timeoutError = new TimeoutError('Navigation timeout of ' + timeout + ' ms exceeded');
let timeoutCallback;
const timeoutPromise = new Promise(resolve => timeoutCallback = resolve.bind(null, timeoutError));
const timeoutId = timeout ? setTimeout(timeoutCallback, timeout) : null;
Expand Down Expand Up @@ -512,7 +512,7 @@ class Page extends EventEmitter {
if (!navigationId)
return null;

const timeoutError = new TimeoutError('Navigation Timeout Exceeded: ' + timeout + 'ms');
const timeoutError = new TimeoutError('Navigation timeout of ' + timeout + ' ms exceeded');
let timeoutCallback;
const timeoutPromise = new Promise(resolve => timeoutCallback = resolve.bind(null, timeoutError));
const timeoutId = timeout ? setTimeout(timeoutCallback, timeout) : null;
Expand Down
5 changes: 4 additions & 1 deletion lib/Accessibility.js
Expand Up @@ -143,6 +143,7 @@ class AXNode {
this._editable = false;
this._focusable = false;
this._expanded = false;
this._hidden = false;
this._name = this._payload.name ? this._payload.name.value : '';
this._role = this._payload.role ? this._payload.role.value : 'Unknown';
this._cachedHasFocusableChild;
Expand All @@ -156,6 +157,8 @@ class AXNode {
this._focusable = property.value.value;
if (property.name === 'expanded')
this._expanded = property.value.value;
if (property.name === 'hidden')
this._hidden = property.value.value;
}
}

Expand Down Expand Up @@ -289,7 +292,7 @@ class AXNode {
*/
isInteresting(insideControl) {
const role = this._role;
if (role === 'Ignored')
if (role === 'Ignored' || this._hidden)
return false;

if (this._focusable || this._richlyEditable)
Expand Down
2 changes: 1 addition & 1 deletion lib/ExecutionContext.js
Expand Up @@ -163,7 +163,7 @@ class ExecutionContext {
if (error.message.includes('Object couldn\'t be returned by value'))
return {result: {type: 'undefined'}};

if (error.message.endsWith('Cannot find context with specified id'))
if (error.message.endsWith('Cannot find context with specified id') || error.message.endsWith('Inspected target navigated or closed'))
throw new Error('Execution context was destroyed, most likely because of a navigation.');
throw error;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/LifecycleWatcher.js
Expand Up @@ -137,7 +137,7 @@ class LifecycleWatcher {
_createTimeoutPromise() {
if (!this._timeout)
return new Promise(() => {});
const errorMessage = 'Navigation Timeout Exceeded: ' + this._timeout + 'ms exceeded';
const errorMessage = 'Navigation timeout of ' + this._timeout + ' ms exceeded';
return new Promise(fulfill => this._maximumTimer = setTimeout(fulfill, this._timeout))
.then(() => new TimeoutError(errorMessage));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"node": ">=8.16.0"
},
"puppeteer": {
"chromium_revision": "686378"
"chromium_revision": "706915"
},
"scripts": {
"unit": "node test/test.js",
Expand Down
Binary file removed test/golden-chromium/screenshot-offscreen-clip.png
Binary file not shown.
Binary file removed test/golden-firefox/screenshot-offscreen-clip.png
Binary file not shown.
4 changes: 2 additions & 2 deletions test/launcher.spec.js
Expand Up @@ -221,13 +221,13 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
expect(spawnargs.indexOf(defaultArgs[2])).toBe(-1);
await browser.close();
});
it_fails_ffox('should have default url when launching browser', async function() {
it_fails_ffox('should have default URL when launching browser', async function() {
const browser = await puppeteer.launch(defaultBrowserOptions);
const pages = (await browser.pages()).map(page => page.url());
expect(pages).toEqual(['about:blank']);
await browser.close();
});
it_fails_ffox('should have custom url when launching browser', async function({server}) {
it_fails_ffox('should have custom URL when launching browser', async function({server}) {
const options = Object.assign({}, defaultBrowserOptions);
options.args = [server.EMPTY_PAGE].concat(options.args || []);
const browser = await puppeteer.launch(options);
Expand Down
8 changes: 4 additions & 4 deletions test/navigation.spec.js
Expand Up @@ -137,7 +137,7 @@ module.exports.addTests = function({testRunner, expect, puppeteer, CHROME}) {
server.setRoute('/empty.html', (req, res) => { });
let error = null;
await page.goto(server.PREFIX + '/empty.html', {timeout: 1}).catch(e => error = e);
expect(error.message).toContain('Navigation Timeout Exceeded: 1ms');
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
});
it('should fail when exceeding default maximum navigation timeout', async({page, server}) => {
Expand All @@ -146,7 +146,7 @@ module.exports.addTests = function({testRunner, expect, puppeteer, CHROME}) {
let error = null;
page.setDefaultNavigationTimeout(1);
await page.goto(server.PREFIX + '/empty.html').catch(e => error = e);
expect(error.message).toContain('Navigation Timeout Exceeded: 1ms');
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
});
it('should fail when exceeding default maximum timeout', async({page, server}) => {
Expand All @@ -155,7 +155,7 @@ module.exports.addTests = function({testRunner, expect, puppeteer, CHROME}) {
let error = null;
page.setDefaultTimeout(1);
await page.goto(server.PREFIX + '/empty.html').catch(e => error = e);
expect(error.message).toContain('Navigation Timeout Exceeded: 1ms');
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
});
it('should prioritize default navigation timeout over default timeout', async({page, server}) => {
Expand All @@ -165,7 +165,7 @@ module.exports.addTests = function({testRunner, expect, puppeteer, CHROME}) {
page.setDefaultTimeout(0);
page.setDefaultNavigationTimeout(1);
await page.goto(server.PREFIX + '/empty.html').catch(e => error = e);
expect(error.message).toContain('Navigation Timeout Exceeded: 1ms');
expect(error.message).toContain('Navigation timeout of 1 ms exceeded');
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
});
it('should disable timeout when its set to 0', async({page, server}) => {
Expand Down
9 changes: 1 addition & 8 deletions test/page.spec.js
Expand Up @@ -18,13 +18,6 @@ const path = require('path');
const utils = require('./utils');
const {waitEvent} = utils;

let asyncawait = true;
try {
new Function('async function foo() {await 1}');
} catch (e) {
asyncawait = false;
}

module.exports.addTests = function({testRunner, expect, headless, puppeteer, CHROME}) {
const {describe, xdescribe, fdescribe, describe_fails_ffox} = testRunner;
const {it, fit, xit, it_fails_ffox} = testRunner;
Expand Down Expand Up @@ -101,7 +94,7 @@ module.exports.addTests = function({testRunner, expect, headless, puppeteer, CHR
});
});

(asyncawait ? describe : xdescribe)('Async stacks', () => {
describe('Async stacks', () => {
it('should work', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.statusCode = 204;
Expand Down
2 changes: 1 addition & 1 deletion test/requestinterception.spec.js
Expand Up @@ -146,7 +146,7 @@ module.exports.addTests = function({testRunner, expect, CHROME}) {
});
expect(status).toBe(200);
});
it('should works with customizing referer headers', async({page, server}) => {
it('should work with custom referer headers', async({page, server}) => {
await page.setExtraHTTPHeaders({ 'referer': server.EMPTY_PAGE });
await page.setRequestInterception(true);
page.on('request', request => {
Expand Down
13 changes: 0 additions & 13 deletions test/screenshot.spec.js
Expand Up @@ -39,19 +39,6 @@ module.exports.addTests = function({testRunner, expect, product}) {
});
expect(screenshot).toBeGolden('screenshot-clip-rect.png');
});
it('should work for offscreen clip', async({page, server}) => {
await page.setViewport({width: 500, height: 500});
await page.goto(server.PREFIX + '/grid.html');
const screenshot = await page.screenshot({
clip: {
x: 50,
y: 600,
width: 100,
height: 100
}
});
expect(screenshot).toBeGolden('screenshot-offscreen-clip.png');
});
it('should run in parallel', async({page, server}) => {
await page.setViewport({width: 500, height: 500});
await page.goto(server.PREFIX + '/grid.html');
Expand Down
9 changes: 1 addition & 8 deletions test/waittask.spec.js
Expand Up @@ -16,13 +16,6 @@

const utils = require('./utils');

let asyncawait = true;
try {
new Function('async function foo() {await 1}');
} catch (e) {
asyncawait = false;
}

module.exports.addTests = function({testRunner, expect, product, puppeteer}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, it_fails_ffox} = testRunner;
Expand Down Expand Up @@ -378,7 +371,7 @@ module.exports.addTests = function({testRunner, expect, product, puppeteer}) {
await page.setContent(`<div class='zombo'>anything</div>`);
expect(await page.evaluate(x => x.textContent, await waitForSelector)).toBe('anything');
});
(asyncawait ? it : xit)('should have correct stack trace for timeout', async({page, server}) => {
it('should have correct stack trace for timeout', async({page, server}) => {
let error;
await page.waitForSelector('.zombo', {timeout: 10}).catch(e => error = e);
expect(error.stack).toContain('waittask.spec.js');
Expand Down

0 comments on commit 3dd3f0c

Please sign in to comment.