最近在一些软件更新(自动 Windows 10 更新,可能还有 Chrome 自动更新)之后,用于从 Qt 的 QWebEngine 进行远程调试的开发人员工具停止工作。 JavaScript 控制台显示:
Uncaught TypeError: document.registerElement is not a function
at Object.UI.registerCustomElement (shell.js:formatted:18064)
at shell.js:formatted:18178
at shell.js:formatted:18266
devtools_app.js:formatted:2606 Uncaught ReferenceError: SDK is not defined
at devtools_app.js:formatted:2606
有问题的代码(来自 shell.js)是这样的:
UI.registerCustomElement = function(localName, typeExtension, prototype) {
return document.registerElement(typeExtension, {
prototype: Object.create(prototype),
extends: localName
});
}
什么是 shell.js,它来自哪里?这个问题的原因可能是什么?
该网页实际上是在Qt 5.12.3网络浏览器中运行的,但是我(远程)将Chrome用于开发者工具。
我也同时将 Angular 7.x 升级到 Angular 8,但不再相信这是相关的。
我的 Chrome 当前版本为 80.0.3987.116(官方版本)(64 位)。
更新
我只是尝试下载旧版本的 Chromium。 (我尝试了 77.0.3823.0 版,因为这可以追溯到 2019 年年中。)并且在那里调试有效。
最佳答案
Chrome 80 已弃用这些开发工具使用的 WebComponents v0。
解决方案是使用额外的参数启动 Chrome 以重新启用该功能(当它仍在引擎中时):
--enable-blink-features=ShadowDOMV0,CustomElementsV0
或者使用对应于 Chrome 79.x 的 Chromium 版本,例如Windows: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/706915/
Mac: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/706915/
Linux: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/706915/
参见:Chrome devtools inspector showing blank white screen while debugging with Samsung TV Tizen Web application
关于angular - Qt QWebEngine 远程调试 : Chrome developer tools no longer work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60292131/