From 7b47d69efe6fec355778c1ea7e1c9c29a2cc3599 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Wed, 11 Apr 2018 23:21:37 +0530 Subject: [PATCH] Remove did-get-response-details and did-get-redirect-request events https://chromium-review.googlesource.com/c/chromium/src/+/805008 https://chromium-review.googlesource.com/c/chromium/src/+/786320 --- atom/browser/api/atom_api_web_contents.cc | 25 --------------- atom/browser/api/atom_api_web_contents.h | 4 --- docs/api/web-contents.md | 33 -------------------- docs/api/webview-tag.md | 27 ---------------- lib/browser/guest-view-manager.js | 2 -- lib/renderer/web-view/guest-view-internal.js | 2 -- spec/api-browser-window-spec.js | 26 --------------- spec/api-web-contents-spec.js | 2 -- spec/webview-spec.js | 27 ---------------- 9 files changed, 148 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 3fabf4e90dd..c4e96e42b4a 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -82,7 +82,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host_view.h" -#include "content/public/browser/resource_request_details.h" #include "content/public/browser/service_worker_context.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/storage_partition.h" @@ -871,30 +870,6 @@ void WebContents::DidStopLoading() { Emit("did-stop-loading"); } -void WebContents::DidGetResourceResponseStart( - const content::ResourceRequestDetails& details) { - // Plznavigate is using blob URLs to deliver the body - // of the main resource to the renderer process. This - // gets better in the future with kNavigationMojoResponse - // feature, which replaces this mechanism with Mojo Datapipe. - if (details.url.SchemeIsBlob() && - (details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME || - details.resource_type == content::RESOURCE_TYPE_SUB_FRAME)) - return; - Emit("-did-get-response-details", details.socket_address.IsEmpty(), - details.url, details.original_url, details.http_response_code, - details.method, details.referrer, details.headers.get(), - ResourceTypeToString(details.resource_type)); -} - -void WebContents::DidGetRedirectForResourceRequest( - const content::ResourceRedirectDetails& details) { - Emit("-did-get-redirect-request", details.url, details.new_url, - (details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME), - details.http_response_code, details.method, details.referrer, - details.headers.get()); -} - void WebContents::DidStartNavigation( content::NavigationHandle* navigation_handle) { bool is_main_frame = navigation_handle->IsInMainFrame(); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 1b410938e1f..e6ef1bb192c 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -353,10 +353,6 @@ class WebContents : public mate::TrackableObject, const base::string16& error_description) override; void DidStartLoading() override; void DidStopLoading() override; - void DidGetResourceResponseStart( - const content::ResourceRequestDetails& details) override; - void DidGetRedirectForResourceRequest( - const content::ResourceRedirectDetails& details) override; void DidStartNavigation( content::NavigationHandle* navigation_handle) override; void DidFinishNavigation( diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 30934409ee2..134384c7161 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -93,39 +93,6 @@ Corresponds to the points in time when the spinner of the tab started spinning. Corresponds to the points in time when the spinner of the tab stopped spinning. -#### Event: 'did-get-response-details' *(Deprecated)* - -Returns: - -* `event` Event -* `status` Boolean -* `newURL` String -* `originalURL` String -* `httpResponseCode` Integer -* `requestMethod` String -* `referrer` String -* `headers` Object -* `resourceType` String - -Emitted when details regarding a requested resource are available. -`status` indicates the socket connection to download the resource. - -**Deprecated**: This event has been deprecated. Use the [`webRequest`](web-request.md) module which provides similar navigation details on a subscription basis. -#### Event: 'did-get-redirect-request' *(Deprecated)* - -Returns: - -* `event` Event -* `oldURL` String -* `newURL` String -* `isMainFrame` Boolean -* `httpResponseCode` Integer -* `requestMethod` String -* `referrer` String -* `headers` Object - -Emitted when a redirect is received while requesting a resource. -**Deprecated**: This event has been deprecated. Use the [`webRequest`](web-request.md) module which provides similar navigation details on a subscription basis. #### Event: 'dom-ready' Returns: diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 7347adfd534..271f723cf69 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -663,33 +663,6 @@ Corresponds to the points in time when the spinner of the tab starts spinning. Corresponds to the points in time when the spinner of the tab stops spinning. -### Event: 'did-get-response-details' *(Deprecated)* - -Returns: - -* `status` Boolean -* `newURL` String -* `originalURL` String -* `httpResponseCode` Integer -* `requestMethod` String -* `referrer` String -* `headers` Object -* `resourceType` String - -Fired when details regarding a requested resource is available. -`status` indicates socket connection to download the resource. - -**Deprecated**: This event has been deprecated. Use the [`webRequest`](web-request.md) module which provides similar navigation details on a subscription basis. -### Event: 'did-get-redirect-request' *(Deprecated)* - -Returns: - -* `oldURL` String -* `newURL` String -* `isMainFrame` Boolean - -Fired when a redirect was received while requesting a resource. -**Deprecated**: This event has been deprecated. Use the [`webRequest`](web-request.md) module which provides similar navigation details on a subscription basis. ### Event: 'dom-ready' Fired when document in the given frame is loaded. diff --git a/lib/browser/guest-view-manager.js b/lib/browser/guest-view-manager.js index a9a99fe2ea7..28f1f4894b6 100644 --- a/lib/browser/guest-view-manager.js +++ b/lib/browser/guest-view-manager.js @@ -14,8 +14,6 @@ const supportedWebViewEvents = [ 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading', - '-did-get-response-details', - '-did-get-redirect-request', 'dom-ready', 'console-message', 'context-menu', diff --git a/lib/renderer/web-view/guest-view-internal.js b/lib/renderer/web-view/guest-view-internal.js index 52ef64cd777..a868b513eb4 100644 --- a/lib/renderer/web-view/guest-view-internal.js +++ b/lib/renderer/web-view/guest-view-internal.js @@ -12,8 +12,6 @@ const WEB_VIEW_EVENTS = { 'did-frame-finish-load': ['isMainFrame', 'frameProcessId', 'frameRoutingId'], 'did-start-loading': [], 'did-stop-loading': [], - '-did-get-response-details': ['status', 'newURL', 'originalURL', 'httpResponseCode', 'requestMethod', 'referrer', 'headers', 'resourceType'], - '-did-get-redirect-request': ['oldURL', 'newURL', 'isMainFrame'], 'dom-ready': [], 'console-message': ['level', 'message', 'line', 'sourceId'], 'context-menu': ['params'], diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 4bd8c5b9927..27dffe981b4 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -157,8 +157,6 @@ describe('BrowserWindow module', () => { it('should not crash when invoked synchronously inside navigation observer', (done) => { const events = [ { name: 'did-start-loading', url: `${server.url}/200` }, - { name: '-did-get-redirect-request', url: `${server.url}/301` }, - { name: '-did-get-response-details', url: `${server.url}/200` }, { name: 'dom-ready', url: `${server.url}/200` }, { name: 'page-title-updated', url: `${server.url}/title` }, { name: 'did-stop-loading', url: `${server.url}/200` }, @@ -223,30 +221,6 @@ describe('BrowserWindow module', () => { w.on('ready-to-show', () => { done() }) w.loadURL('about:blank') }) - // TODO(nitsakh): Deprecated - it('should emit did-get-response-details(deprecated) event', (done) => { - // expected {fileName: resourceType} pairs - const expectedResources = { - 'did-get-response-details.html': 'mainFrame', - 'logo.png': 'image' - } - let responses = 0 - w.webContents.on('-did-get-response-details', (event, status, newUrl, oldUrl, responseCode, method, referrer, headers, resourceType) => { - responses += 1 - const fileName = newUrl.slice(newUrl.lastIndexOf('/') + 1) - const expectedType = expectedResources[fileName] - assert(!!expectedType, `Unexpected response details for ${newUrl}`) - assert(typeof status === 'boolean', 'status should be boolean') - assert.equal(responseCode, 200) - assert.equal(method, 'GET') - assert(typeof referrer === 'string', 'referrer should be string') - assert(!!headers, 'headers should be present') - assert(typeof headers === 'object', 'headers should be object') - assert.equal(resourceType, expectedType, 'Incorrect resourceType') - if (responses === Object.keys(expectedResources).length) done() - }) - w.loadURL(`file://${path.join(fixtures, 'pages', 'did-get-response-details.html')}`) - }) it('should emit did-fail-load event for files that do not exist', (done) => { w.webContents.on('did-fail-load', (event, code, desc, url, isMainFrame) => { assert.equal(code, -6) diff --git a/spec/api-web-contents-spec.js b/spec/api-web-contents-spec.js index 847462e2f48..1cb169e769f 100644 --- a/spec/api-web-contents-spec.js +++ b/spec/api-web-contents-spec.js @@ -650,8 +650,6 @@ describe('webContents module', () => { it('should not crash when invoked synchronously inside navigation observer', (done) => { const events = [ { name: 'did-start-loading', url: `${server.url}/200` }, - { name: '-did-get-redirect-request', url: `${server.url}/301` }, - { name: '-did-get-response-details', url: `${server.url}/200` }, { name: 'dom-ready', url: `${server.url}/200` }, { name: 'did-stop-loading', url: `${server.url}/200` }, { name: 'did-finish-load', url: `${server.url}/200` }, diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 5ee932e8747..29a5acfd7bf 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -1121,33 +1121,6 @@ describe(' tag', function () { }) }) - describe('did-get-response-details event (deprecated)', () => { - it('emits for the page and its resources', (done) => { - // expected {fileName: resourceType} pairs - const expectedResources = { - 'did-get-response-details.html': 'mainFrame', - 'logo.png': 'image' - } - let responses = 0 - webview.addEventListener('-did-get-response-details', (event) => { - responses += 1 - const fileName = event.newURL.slice(event.newURL.lastIndexOf('/') + 1) - const expectedType = expectedResources[fileName] - assert(!!expectedType, `Unexpected response details for ${event.newURL}`) - assert(typeof event.status === 'boolean', 'status should be boolean') - assert.equal(event.httpResponseCode, 200) - assert.equal(event.requestMethod, 'GET') - assert(typeof event.referrer === 'string', 'referrer should be string') - assert(!!event.headers, 'headers should be present') - assert(typeof event.headers === 'object', 'headers should be object') - assert.equal(event.resourceType, expectedType, 'Incorrect resourceType') - if (responses === Object.keys(expectedResources).length) done() - }) - webview.src = `file://${path.join(fixtures, 'pages', 'did-get-response-details.html')}` - document.body.appendChild(webview) - }) - }) - describe('document.visibilityState/hidden', () => { afterEach(() => { ipcMain.removeAllListeners('pong')