mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
This patch fixes `page.goto` for websites that re-request document URL with javascript. Fixes #1391.
This commit is contained in:
parent
aed7019146
commit
c866c175f8
@ -494,7 +494,10 @@ class Page extends EventEmitter {
|
||||
|
||||
const requests = new Map();
|
||||
const eventListeners = [
|
||||
helper.addEventListener(this._networkManager, NetworkManager.Events.Request, request => requests.set(request.url(), request))
|
||||
helper.addEventListener(this._networkManager, NetworkManager.Events.Request, request => {
|
||||
if (!requests.get(request.url()))
|
||||
requests.set(request.url(), request);
|
||||
})
|
||||
];
|
||||
|
||||
const mainFrame = this._frameManager.mainFrame();
|
||||
|
5
test/assets/self-request.html
Normal file
5
test/assets/self-request.html
Normal file
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
var req = new XMLHttpRequest();
|
||||
req.open('GET', '/self-request.html');
|
||||
req.send(null);
|
||||
</script>
|
@ -1193,6 +1193,11 @@ describe('Page', function() {
|
||||
expect(requests.length).toBe(1);
|
||||
expect(requests[0].url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
it('should work with self requesting page', async({page, server}) => {
|
||||
const response = await page.goto(server.PREFIX + '/self-request.html');
|
||||
expect(response.status()).toBe(200);
|
||||
expect(response.url()).toContain('self-request.html');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForNavigation', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user