Skip to content

Commit

Permalink
fix(Page): fix page.goto to return Response when page pushes new state (
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov authored Apr 28, 2018
1 parent a2a9100 commit 58c4668
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/FrameManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
5 changes: 5 additions & 0 deletions test/assets/historyapi.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
window.addEventListener('DOMContentLoaded', () => {
history.pushState({}, '', '#1');
});
</script>
4 changes: 4 additions & 0 deletions test/page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 58c4668

Please sign in to comment.