fix(Page): fix page.goto to return Response when page pushes new state (#2468)

]Fixes #2411.
This commit is contained in:
Andrey Lushnikov 2018-04-28 00:15:40 -04:00 committed by GitHub
parent a2a9100248
commit 58c46680f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 1 deletions

View File

@ -774,6 +774,8 @@ class Frame {
*/
_navigated(framePayload) {
this._name = framePayload.name;
// TODO(lushnikov): remove this once requestInterception has loaderId exposed.
this._navigationURL = framePayload.url;
this._url = framePayload.url;
}

View File

@ -515,7 +515,7 @@ class Page extends EventEmitter {
helper.removeEventListeners(eventListeners);
if (error)
throw error;
const request = requests.get(this.mainFrame().url());
const request = requests.get(mainFrame._navigationURL);
return request ? request.response() : null;
/**

View File

@ -0,0 +1,5 @@
<script>
window.addEventListener('DOMContentLoaded', () => {
history.pushState({}, '', '#1');
});
</script>

View File

@ -383,6 +383,10 @@ module.exports.addTests = function({testRunner, expect, puppeteer, DeviceDescrip
const response = await page.goto('about:blank');
expect(response).toBe(null);
});
it('should return response when page changes its URL after load', async({page, server}) => {
const response = await page.goto(server.PREFIX + '/historyapi.html');
expect(response.status()).toBe(200);
});
it('should work with subframes return 204', async({page, server}) => {
server.setRoute('/frames/frame.html', (req, res) => {
res.statusCode = 204;