【问题标题】:"Not allowed to load local resource" error is seen while launching the chrome crash url启动 chrome 崩溃 url 时出现“不允许加载本地资源”错误
【发布时间】:2020-08-27 21:35:42
【问题描述】:

为了我的应用程序测试目的,我想在一个单独的窗口中崩溃 chrome url, 但是下面的代码给了我“不允许加载本地资源”的错误。

有什么方法可以通过 window.open 启动 chrome 崩溃 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>

【问题讨论】:

    标签: javascript html google-chrome google-chrome-extension chromium


    【解决方案1】:
    • 网页无法导航到chrome:// 网址intentionally
    • 不允许像 chrome.tabs 或 chrome.windows 这样的普通扩展 API 打开导致浏览器/渲染器进程崩溃的 URL intentionally

     

    解决方案 1。

    chrome extension 可以通过chrome.debugger API 发送Browser.crash 命令。

    manifest.json 摘录:

    "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');
      });
    });
    

     

    解决方案 2。

    外部 CDP 工具(如 puppeteer (example))可以发送相同的命令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-08
      相关资源
      最近更新 更多