diff --git a/docs/api.md b/docs/api.md index 90e61a6371d51..1f2ed56683314 100644 --- a/docs/api.md +++ b/docs/api.md @@ -294,8 +294,6 @@ - [class: Response](#class-response) * [response.buffer()](#responsebuffer) * [response.frame()](#responseframe) - * [response.fromCache()](#responsefromcache) - * [response.fromServiceWorker()](#responsefromserviceworker) * [response.headers()](#responseheaders) * [response.json()](#responsejson) * [response.ok()](#responseok) @@ -3783,16 +3781,6 @@ page.on('request', request => { #### response.frame() - returns: A [Frame] that initiated this response, or `null` if navigating to error pages. -#### response.fromCache() -- returns: <[boolean]> - -True if the response was served from either the browser's disk cache or memory cache. - -#### response.fromServiceWorker() -- returns: <[boolean]> - -True if the response was served by a service worker. - #### response.headers() - returns: <[Object]> An object with HTTP headers associated with the response. All header names are lower-case. diff --git a/src/chromium/NetworkManager.ts b/src/chromium/NetworkManager.ts index 00d1baeee73eb..82fb05a1e471f 100644 --- a/src/chromium/NetworkManager.ts +++ b/src/chromium/NetworkManager.ts @@ -53,7 +53,6 @@ export class NetworkManager extends EventEmitter { this._client.on('Fetch.requestPaused', this._onRequestPaused.bind(this)); this._client.on('Fetch.authRequired', this._onAuthRequired.bind(this)); this._client.on('Network.requestWillBeSent', this._onRequestWillBeSent.bind(this)); - this._client.on('Network.requestServedFromCache', this._onRequestServedFromCache.bind(this)); this._client.on('Network.responseReceived', this._onResponseReceived.bind(this)); this._client.on('Network.loadingFinished', this._onLoadingFinished.bind(this)); this._client.on('Network.loadingFailed', this._onLoadingFailed.bind(this)); @@ -204,12 +203,6 @@ export class NetworkManager extends EventEmitter { } - _onRequestServedFromCache(event: Protocol.Network.requestServedFromCachePayload) { - const request = this._requestIdToRequest.get(event.requestId); - if (request) - request._fromMemoryCache = true; - } - _handleRequestRedirect(request: Request, responsePayload: Protocol.Network.Response) { const response = new Response(this._client, request, responsePayload); request._response = response; @@ -279,7 +272,6 @@ export class Request { private _postData: string; private _headers: {[key: string]: string} = {}; private _frame: Frame; - _fromMemoryCache = false; constructor(client: CDPSession, frame: Frame | null, interceptionId: string, allowInterception: boolean, event: Protocol.Network.requestWillBeSentPayload, redirectChain: Request[]) { this._client = client; @@ -448,8 +440,6 @@ export class Response { private _status: number; private _statusText: string; private _url: string; - private _fromDiskCache: boolean; - private _fromServiceWorker: boolean; private _headers: {[key: string]: string} = {}; private _securityDetails: SecurityDetails; @@ -468,8 +458,6 @@ export class Response { this._status = responsePayload.status; this._statusText = responsePayload.statusText; this._url = request.url(); - this._fromDiskCache = !!responsePayload.fromDiskCache; - this._fromServiceWorker = !!responsePayload.fromServiceWorker; for (const key of Object.keys(responsePayload.headers)) this._headers[key.toLowerCase()] = responsePayload.headers[key]; this._securityDetails = responsePayload.securityDetails ? new SecurityDetails(responsePayload.securityDetails) : null; @@ -531,14 +519,6 @@ export class Response { return this._request; } - fromCache(): boolean { - return this._fromDiskCache || this._request._fromMemoryCache; - } - - fromServiceWorker(): boolean { - return this._fromServiceWorker; - } - frame(): Frame | null { return this._request.frame(); } diff --git a/test/network.spec.js b/test/network.spec.js index 36f8eb44d8628..5eb6813e74342 100644 --- a/test/network.spec.js +++ b/test/network.spec.js @@ -97,52 +97,6 @@ module.exports.addTests = function({testRunner, expect, FFOX, CHROME, WEBKIT}) { }); }); - describe.skip(FFOX)('Response.fromCache', function() { - it.skip(WEBKIT)('should return |false| for non-cached content', async({page, server}) => { - const response = await page.goto(server.EMPTY_PAGE); - expect(response.fromCache()).toBe(false); - }); - - it.skip(WEBKIT)('should work', async({page, server}) => { - const responses = new Map(); - page.on('response', r => !utils.isFavicon(r.request()) && responses.set(r.url().split('/').pop(), r)); - - // Load and re-load to make sure it's cached. - await page.goto(server.PREFIX + '/cached/one-style.html'); - await page.reload(); - - expect(responses.size).toBe(2); - expect(responses.get('one-style.css').status()).toBe(200); - expect(responses.get('one-style.css').fromCache()).toBe(true); - expect(responses.get('one-style.html').status()).toBe(304); - expect(responses.get('one-style.html').fromCache()).toBe(false); - }); - }); - - describe.skip(FFOX)('Response.fromServiceWorker', function() { - it.skip(WEBKIT)('should return |false| for non-service-worker content', async({page, server}) => { - const response = await page.goto(server.EMPTY_PAGE); - expect(response.fromServiceWorker()).toBe(false); - }); - - // FIXME: WebKit responses contain sw.js - it.skip(WEBKIT)('Response.fromServiceWorker', async({page, server}) => { - const responses = new Map(); - page.on('response', r => responses.set(r.url().split('/').pop(), r)); - - // Load and re-load to make sure serviceworker is installed and running. - await page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html', {waitUntil: 'networkidle2'}); - await page.evaluate(async() => await window.activationPromise); - await page.reload(); - - expect(responses.size).toBe(2); - expect(responses.get('sw.html').status()).toBe(200); - expect(responses.get('sw.html').fromServiceWorker()).toBe(true); - expect(responses.get('style.css').status()).toBe(200); - expect(responses.get('style.css').fromServiceWorker()).toBe(true); - }); - }); - describe('Request.postData', function() { it('should work', async({page, server}) => { await page.goto(server.EMPTY_PAGE);