fix(interception): Disable newtork caching when intercepting (#1154)

Request interception might not work properly if caching is enabled.
This commit is contained in:
Andrey Lushnikov 2017-10-24 15:14:25 -07:00 committed by GitHub
parent ce005d480c
commit b9ab6fe4bb
2 changed files with 6 additions and 1 deletions

View File

@ -1007,6 +1007,8 @@ puppeteer.launch().then(async browser => {
> **NOTE** Request interception doesn't work with data URLs. Calling `abort`,
> `continue` or `respond` on requests for data URLs is a noop.
> **NOTE** Enabling request interception disables page caching.
#### page.setUserAgent(userAgent)
- `userAgent` <[string]> Specific user agent to use in this page
- returns: <[Promise]> Promise which resolves when the user agent is set.

View File

@ -117,7 +117,10 @@ class NetworkManager extends EventEmitter {
return;
this._protocolRequestInterceptionEnabled = enabled;
const patterns = enabled ? [{urlPattern: '*'}] : [];
await this._client.send('Network.setRequestInterception', {patterns});
await Promise.all([
this._client.send('Network.setCacheDisabled', {cacheDisabled: enabled}),
this._client.send('Network.setRequestInterception', {patterns})
]);
}
/**