我想在一个单独的窗口中崩溃chrome网址,用于我的应用程序测试目的,但下面的代码给我'不允许加载本地资源'错误。
有什么办法可以让我通过window.open启动chrome crash url而不收到这个错误?
下面是我的尝试。
<html>
<head>
<title>Sample Test</title>
<script type="text/javascript">
function crashTest() {
window.open("chrome://inducebrowsercrashforrealz", "windowInMyApp", "left=50, top=100, width=600, height=400, toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}
</script>
</head>
<body>
<div>
<br />
<button onclick="crashTest();">Navigate</button>
</div>
</body>
</html>
A 浏览器扩展 可发 Browser.crash
命令通过 chrome.debugger API。
manifest.json excerpt。
"permissions": ["debugger"]
browser_action的popup.js或background.js。
chrome.tabs.create({url: 'about:blank', active: false}, ({id: tabId}) => {
chrome.debugger.attach({tabId}, '1.3', () => {
chrome.debugger.sendCommand({tabId}, 'Browser.crash');
});
});
同样的命令可以由外部的CDP工具如puppeteer(例子).