Skip to content

Commit 45fe865

Browse files
GauthamBanasandratargos
authored andcommitted
inspector: use js_app.html as the landing page for chrome devtools
As of this commit in chromium - https://chromium-review.googlesource.com/c/chromium/src/+/905450 a new landing page (js_app.html) has been added and inspector.html has been made as the fallback page. Another motivation for this patch is the following bug in chromium - https://bugs.chromium.org/p/chromium/issues/detail?id=846642 due to which, source maps won't get applied with inspector.html, but works with js_app.html In order to maintain compatibility, this patch adds a URL "devtoolsFrontendUrlCompat" to the response of /json/list REST API so that those using Chrome browsers older than 66.0.3345.0 could use this to open DevTools. PR-URL: #21385 Refs: https://bugs.chromium.org/p/chromium/issues/detail?id=846642 Refs: https://chromium-review.googlesource.com/c/chromium/src/+/905450 Reviewed-By: Aleksei Koziatinskii <ak239spb@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com>
1 parent 51a434f commit 45fe865

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

doc/api/debugger.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,15 @@ flag instead of `--inspect`.
187187
$ node --inspect index.js
188188
Debugger listening on 127.0.0.1:9229.
189189
To start debugging, open the following URL in Chrome:
190-
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
190+
chrome-devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
191191
```
192192

193193
(In the example above, the UUID dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
194194
at the end of the URL is generated on the fly, it varies in different
195195
debugging sessions.)
196196

197+
If the Chrome browser is older than 66.0.3345.0,
198+
use `inspector.html` instead of `js_app.html` in the above URL.
199+
197200
[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/
198201
[V8 Inspector]: #debugger_v8_inspector_integration_for_node_js

src/inspector_socket_server.cc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,27 @@ void InspectorSocketServer::SendListResponse(InspectorSocket* socket,
334334
detected_host = FormatHostPort(socket->GetHost(),
335335
session->server_port());
336336
}
337-
std::ostringstream frontend_url;
338-
frontend_url << "chrome-devtools://devtools/bundled";
339-
frontend_url << "/inspector.html?experiments=true&v8only=true&ws=";
340-
frontend_url << FormatAddress(detected_host, id, false);
341-
target_map["devtoolsFrontendUrl"] += frontend_url.str();
337+
std::string formatted_address = FormatAddress(detected_host, id, false);
338+
target_map["devtoolsFrontendUrl"] = GetFrontendURL(false,
339+
formatted_address);
340+
// The compat URL is for Chrome browsers older than 66.0.3345.0
341+
target_map["devtoolsFrontendUrlCompat"] = GetFrontendURL(true,
342+
formatted_address);
342343
target_map["webSocketDebuggerUrl"] = FormatAddress(detected_host, id, true);
343344
}
344345
SendHttpResponse(socket, MapsToString(response));
345346
}
346347

348+
std::string InspectorSocketServer::GetFrontendURL(bool is_compat,
349+
const std::string &formatted_address) {
350+
std::ostringstream frontend_url;
351+
frontend_url << "chrome-devtools://devtools/bundled/";
352+
frontend_url << (is_compat ? "inspector" : "js_app");
353+
frontend_url << ".html?experiments=true&v8only=true&ws=";
354+
frontend_url << formatted_address;
355+
return frontend_url.str();
356+
}
357+
347358
bool InspectorSocketServer::Start() {
348359
CHECK_NE(delegate_, nullptr);
349360
CHECK_EQ(state_, ServerState::kNew);

src/inspector_socket_server.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class InspectorSocketServer {
8181

8282
void SendListResponse(InspectorSocket* socket, const std::string& host,
8383
SocketSession* session);
84+
std::string GetFrontendURL(bool is_compat,
85+
const std::string &formatted_address);
8486
bool TargetExists(const std::string& id);
8587

8688
enum class ServerState {kNew, kRunning, kStopping, kStopped};

0 commit comments

Comments
 (0)