From cf5224140b64f0df075e0d2ade3de878bcbc89b1 Mon Sep 17 00:00:00 2001 From: Nitish Sakhawalkar Date: Fri, 17 May 2019 15:37:09 -0700 Subject: [PATCH] Chrome changed the devtools url chrome-devtools:// to devtools:// https://chromium.googlesource.com/chromium/src/+/28b21a67f09a13c465b73776aecd9995d8a07737 --- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/atom_browser_client.cc | 2 +- atom/browser/ui/devtools_ui.cc | 4 +--- atom/browser/ui/inspectable_web_contents_impl.cc | 4 ++-- atom/renderer/atom_sandboxed_renderer_client.cc | 2 +- filenames.gni | 2 +- lib/browser/{chrome-devtools.js => devtools.js} | 2 +- lib/browser/init.ts | 2 +- lib/renderer/init.ts | 2 +- lib/sandboxed_renderer/init.js | 2 +- spec/api-web-contents-spec.js | 2 +- spec/chromium-spec.js | 2 +- spec/webview-spec.js | 2 +- 13 files changed, 14 insertions(+), 16 deletions(-) rename lib/browser/{chrome-devtools.js => devtools.js} (98%) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 6ef9dc29b4ad..896c928c386b 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -2080,7 +2080,7 @@ v8::Local WebContents::GetLastWebPreferences( } bool WebContents::IsRemoteModuleEnabled() const { - if (web_contents()->GetVisibleURL().SchemeIs("chrome-devtools")) { + if (web_contents()->GetVisibleURL().SchemeIs("devtools")) { return false; } if (auto* web_preferences = WebContentsPreferences::From(web_contents())) { diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 736312ce4db5..67d5c7507b16 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -500,7 +500,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( content::WebContents* web_contents = GetWebContentsFromProcessID(process_id); if (web_contents) { - if (web_contents->GetVisibleURL().SchemeIs("chrome-devtools")) { + if (web_contents->GetVisibleURL().SchemeIs("devtools")) { command_line->AppendSwitch(switches::kDisableRemoteModule); } auto* web_preferences = WebContentsPreferences::From(web_contents); diff --git a/atom/browser/ui/devtools_ui.cc b/atom/browser/ui/devtools_ui.cc index 8986eb9b6ee3..8e14c5675c77 100644 --- a/atom/browser/ui/devtools_ui.cc +++ b/atom/browser/ui/devtools_ui.cc @@ -23,9 +23,7 @@ const char kChromeUIDevToolsHost[] = "devtools"; const char kChromeUIDevToolsBundledPath[] = "bundled"; std::string PathWithoutParams(const std::string& path) { - return GURL(std::string("chrome-devtools://devtools/") + path) - .path() - .substr(1); + return GURL(std::string("devtools://devtools/") + path).path().substr(1); } std::string GetMimeTypeForPath(const std::string& path) { diff --git a/atom/browser/ui/inspectable_web_contents_impl.cc b/atom/browser/ui/inspectable_web_contents_impl.cc index 797cedb8de3f..c0efe548c2a5 100644 --- a/atom/browser/ui/inspectable_web_contents_impl.cc +++ b/atom/browser/ui/inspectable_web_contents_impl.cc @@ -54,14 +54,14 @@ const double kPresetZoomFactors[] = {0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 2.5, 3.0, 4.0, 5.0}; const char kChromeUIDevToolsURL[] = - "chrome-devtools://devtools/bundled/devtools_app.html?" + "devtools://devtools/bundled/devtools_app.html?" "remoteBase=%s&" "can_dock=%s&" "toolbarColor=rgba(223,223,223,1)&" "textColor=rgba(0,0,0,1)&" "experiments=true"; const char kChromeUIDevToolsRemoteFrontendBase[] = - "https://chrome-devtools-frontend.appspot.com/"; + "https://devtools-frontend.appspot.com/"; const char kChromeUIDevToolsRemoteFrontendPath[] = "serve_file"; const char kDevToolsBoundsPref[] = "electron.devtools.bounds"; diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index c6c524d949b7..f91a6d5e2e28 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -35,7 +35,7 @@ const char kModuleCacheKey[] = "native-module-cache"; bool IsDevTools(content::RenderFrame* render_frame) { return render_frame->GetWebFrame()->GetDocument().Url().ProtocolIs( - "chrome-devtools"); + "devtools"); } bool IsDevToolsExtension(content::RenderFrame* render_frame) { diff --git a/filenames.gni b/filenames.gni index df3e1ec5ca81..9702deb9c841 100644 --- a/filenames.gni +++ b/filenames.gni @@ -34,7 +34,7 @@ filenames = { "lib/browser/api/view.js", "lib/browser/api/web-contents.js", "lib/browser/api/web-contents-view.js", - "lib/browser/chrome-devtools.js", + "lib/browser/devtools.js", "lib/browser/chrome-extension.js", "lib/browser/crash-reporter-init.js", "lib/browser/default-menu.ts", diff --git a/lib/browser/chrome-devtools.js b/lib/browser/devtools.js similarity index 98% rename from lib/browser/chrome-devtools.js rename to lib/browser/devtools.js index 0c7778f249e3..0dabf9b3543b 100644 --- a/lib/browser/chrome-devtools.js +++ b/lib/browser/devtools.js @@ -50,7 +50,7 @@ const getEditMenuItems = function () { const isChromeDevTools = function (pageURL) { const { protocol } = url.parse(pageURL) - return protocol === 'chrome-devtools:' + return protocol === 'devtools:' } const assertChromeDevTools = function (contents, api) { diff --git a/lib/browser/init.ts b/lib/browser/init.ts index 66260b9bdaec..f7b6f326b7ea 100644 --- a/lib/browser/init.ts +++ b/lib/browser/init.ts @@ -154,7 +154,7 @@ if (packageJson.v8Flags != null) { app._setDefaultAppPaths(packagePath) // Load the chrome devtools support. -require('@electron/internal/browser/chrome-devtools') +require('@electron/internal/browser/devtools') // Load the chrome extension support. require('@electron/internal/browser/chrome-extension') diff --git a/lib/renderer/init.ts b/lib/renderer/init.ts index d589856fe3e9..a2b1d9eec52f 100644 --- a/lib/renderer/init.ts +++ b/lib/renderer/init.ts @@ -94,7 +94,7 @@ if (preloadScript) { } switch (window.location.protocol) { - case 'chrome-devtools:': { + case 'devtools:': { // Override some inspector APIs. require('@electron/internal/renderer/inspector') break diff --git a/lib/sandboxed_renderer/init.js b/lib/sandboxed_renderer/init.js index bb9338b23e89..31f28df049d4 100644 --- a/lib/sandboxed_renderer/init.js +++ b/lib/sandboxed_renderer/init.js @@ -109,7 +109,7 @@ const { hasSwitch } = process.electronBinding('command_line') const contextIsolation = hasSwitch('context-isolation') switch (window.location.protocol) { - case 'chrome-devtools:': { + case 'devtools:': { // Override some inspector APIs. require('@electron/internal/renderer/inspector') break diff --git a/spec/api-web-contents-spec.js b/spec/api-web-contents-spec.js index d1b8c30353d2..b226c469bfe3 100644 --- a/spec/api-web-contents-spec.js +++ b/spec/api-web-contents-spec.js @@ -190,7 +190,7 @@ describe('webContents module', () => { w.webContents.setDevToolsWebContents(devtools.webContents) w.webContents.openDevTools() await promise - expect(devtools.getURL().startsWith('chrome-devtools://devtools')).to.be.true() + expect(devtools.getURL().startsWith('devtools://devtools')).to.be.true() const result = await devtools.webContents.executeJavaScript('InspectorFrontendHost.constructor.name') expect(result).to.equal('InspectorFrontendHostImpl') devtools.destroy() diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 079698ecdbd0..c30f6a763df9 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -401,7 +401,7 @@ describe('chromium feature', () => { }).catch(done) }) }) - b = window.open('chrome-devtools://devtools/bundled/inspector.html', '', 'nodeIntegration=no,show=no') + b = window.open('devtools://devtools/bundled/inspector.html', '', 'nodeIntegration=no,show=no') }) it('disables JavaScript when it is disabled on the parent window', (done) => { diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 3dd422f897ca..3d2dca06cd9a 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -787,7 +787,7 @@ describe(' tag', function () { // Its WebContents should be a DevTools. const devtools = webview2.getWebContents() - assert.ok(devtools.getURL().startsWith('chrome-devtools://devtools')) + assert.ok(devtools.getURL().startsWith('devtools://devtools')) const name = await devtools.executeJavaScript('InspectorFrontendHost.constructor.name') document.body.removeChild(webview2)