diff --git a/lib/FrameManager.js b/lib/FrameManager.js index b29dcf7ab14..b2e3f965dce 100644 --- a/lib/FrameManager.js +++ b/lib/FrameManager.js @@ -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; } diff --git a/lib/Page.js b/lib/Page.js index 5051addb475..c9303465965 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -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; /** diff --git a/test/assets/historyapi.html b/test/assets/historyapi.html new file mode 100644 index 00000000000..bacaf9e9a00 --- /dev/null +++ b/test/assets/historyapi.html @@ -0,0 +1,5 @@ + diff --git a/test/page.spec.js b/test/page.spec.js index d743b7d076e..aff7215b3af 100644 --- a/test/page.spec.js +++ b/test/page.spec.js @@ -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;