refactor: migrate NavigatorWatcher to lifecycle events (#1141)

This patch:
- migrates navigation watcher to use protocol-issued lifecycle events.
- removes `networkIdleTimeout` and `networkIdleInflight` options for
  `page.goto` method
- adds a new `networkidle0` value to the waitUntil option of navigation
  methods

References #728.

BREAKING CHANGE:

As an implication of this new approach, the `networkIdleTimeout` and
`networkIdleInflight` options are no longer supported. Interested
clients should implement the behavior themselves using the `request` and
`response` events.
This commit is contained in:
Andrey Lushnikov
2017-10-23 18:10:59 -07:00
committed by GitHub
parent 126ab7b90e
commit ce8a952044
9 changed files with 67 additions and 73 deletions

View File

@@ -43,7 +43,7 @@ function listenFor(type) {
await listenFor('app-ready'); // Listen for "app-ready" custom event on page load.
await page.goto('https://www.chromestatus.com/features', {waitUntil: 'networkidle'});
await page.goto('https://www.chromestatus.com/features', {waitUntil: 'networkidle2'});
await browser.close();

View File

@@ -38,7 +38,7 @@ function sniffDetector() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.evaluateOnNewDocument(sniffDetector);
await page.goto('https://www.google.com', {waitUntil: 'networkidle'});
await page.goto('https://www.google.com', {waitUntil: 'networkidle2'});
console.log('Sniffed: ' + (await page.evaluate(() => !!navigator.sniffed)));
await browser.close();

View File

@@ -22,7 +22,7 @@ const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle'});
await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});
// page.pdf() is currently supported only in headless mode.
// @see https://bugs.chromium.org/p/chromium/issues/detail?id=753118
await page.pdf({

View File

@@ -22,7 +22,7 @@ const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.com', {waitUntil: 'networkidle'});
await page.goto('https://google.com', {waitUntil: 'networkidle2'});
// Type our query into the search bar
await page.type('input[name=q]', 'puppeteer');