Skip to content

Commit

Permalink
feat: enable Network Service by default (#3738)
Browse files Browse the repository at this point in the history
References #3471.
  • Loading branch information
aslushnikov committed Jan 9, 2019
1 parent c86bc0f commit 1899e79
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/Launcher.js
Expand Up @@ -34,6 +34,7 @@ const CHROME_PROFILE_PATH = path.join(os.tmpdir(), 'puppeteer_dev_profile-');

const DEFAULT_ARGS = [
'--disable-background-networking',
'--enable-features=NetworkService,NetworkServiceInProcess',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
Expand Down
9 changes: 8 additions & 1 deletion lib/NetworkManager.js
Expand Up @@ -135,7 +135,8 @@ class NetworkManager extends EventEmitter {
* @param {!Protocol.Network.requestWillBeSentPayload} event
*/
_onRequestWillBeSent(event) {
if (this._protocolRequestInterceptionEnabled) {
// Request interception doesn't happen for data URLs with Network Service.
if (this._protocolRequestInterceptionEnabled && !event.request.url.startsWith('data:')) {
const requestHash = generateRequestHash(event.request);
const interceptionId = this._requestHashToInterceptionIds.firstValue(requestHash);
if (interceptionId) {
Expand Down Expand Up @@ -394,6 +395,9 @@ class Request {
* @param {!{url?: string, method?:string, postData?: string, headers?: !Object}} overrides
*/
async continue(overrides = {}) {
// Request interception is not supported for data: urls.
if (this._url.startsWith('data:'))
return;
assert(this._allowInterception, 'Request Interception is not enabled!');
assert(!this._interceptionHandled, 'Request is already handled!');
const {
Expand Down Expand Up @@ -466,6 +470,9 @@ class Request {
* @param {string=} errorCode
*/
async abort(errorCode = 'failed') {
// Request interception is not supported for data: urls.
if (this._url.startsWith('data:'))
return;
const errorReason = errorReasons[errorCode];
assert(errorReason, 'Unknown error code: ' + errorCode);
assert(this._allowInterception, 'Request Interception is not enabled!');
Expand Down
9 changes: 0 additions & 9 deletions test/network.spec.js
Expand Up @@ -495,15 +495,6 @@ module.exports.addTests = function({testRunner, expect}) {
expect(requests.length).toBe(1);
expect(requests[0].url()).toBe(dataURL);
});
it('should abort data server', async({page, server}) => {
await page.setRequestInterception(true);
page.on('request', request => {
request.abort();
});
let error = null;
await page.goto('data:text/html,No way!').catch(err => error = err);
expect(error.message).toContain('net::ERR_FAILED');
});
it('should navigate to URL with hash and and fire requests without hash', async({page, server}) => {
await page.setRequestInterception(true);
const requests = [];
Expand Down

0 comments on commit 1899e79

Please sign in to comment.