fix(Page): fix page.goto to return Response when page pushes new state (#2468)
]Fixes #2411.
This commit is contained in:
parent
a2a9100248
commit
58c46680f3
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
5
test/assets/historyapi.html
Normal file
5
test/assets/historyapi.html
Normal file
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
history.pushState({}, '', '#1');
|
||||
});
|
||||
</script>
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user