From e1c5b8d2441db8384288f70c545cb622f00b7f0c Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Mon, 7 Aug 2017 15:13:17 -0700 Subject: [PATCH] Aborted network requests should use protocol's "Failed" status (#215) This patch starts using "Failed" command for request interception instead of "Aborted". The "Aborted" status also has a side-effect of cancelling the navigation, so there will be no error on the page and form puppeteer's standpoint, the navigation will never complete. --- lib/NetworkManager.js | 2 +- test/test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/NetworkManager.js b/lib/NetworkManager.js index 3029286b..9932f8a0 100644 --- a/lib/NetworkManager.js +++ b/lib/NetworkManager.js @@ -243,7 +243,7 @@ class InterceptedRequest { this._handled = true; this._client.send('Network.continueInterceptedRequest', { interceptionId: this._interceptionId, - errorReason: 'Aborted' + errorReason: 'Failed' }); } diff --git a/test/test.js b/test/test.js index 21591947..f5f70d4c 100644 --- a/test/test.js +++ b/test/test.js @@ -770,6 +770,17 @@ describe('Page', function() { ]); expect(request.headers['foo']).toBe('bar'); })); + it('should fail navigation when aborting main resource', SX(async function() { + page.setRequestInterceptor(request => request.abort()); + let error = null; + try { + await page.navigate(EMPTY_PAGE); + } catch (e) { + error = e; + } + expect(error).toBeTruthy(); + expect(error.message).toContain('Failed to navigate'); + })); }); describe('Page.Events.Dialog', function() {