Introduce Page.waitForNavigation (#94)

This patch introduces Page.waitForNavigation which allows to wait
for render-initiated navigation.

This patch also does a nice refactoring, replacing Navigator with NavigatorWatcher which
is not a part of a page state.

References #89
This commit is contained in:
Pavel Feldman
2017-07-18 18:54:24 -07:00
committed by Andrey Lushnikov
parent bef9982687
commit 98c3894c84
5 changed files with 74 additions and 35 deletions

View File

@@ -427,6 +427,17 @@ describe('Puppeteer', function() {
}));
});
describe('Page.waitForNavigation', function() {
it('should work', SX(async function() {
await page.navigate(EMPTY_PAGE);
const result = page.waitForNavigation();
page.evaluate(url => window.location.href = url, PREFIX + '/grid.html');
const response = await result;
expect(response.ok).toBe(true);
expect(response.url).toContain('grid.html');
}));
});
describe('Page.setInPageCallback', function() {
it('should work', SX(async function() {
await page.setInPageCallback('callController', function(a, b) {