Skip to content

nw version 23.5 -load-extension :ERR_BLOCKED_BY_CLIENT #6004

@chatcan

Description

@chatcan

package.json

{
  "main": "index.html",
  "name": "canhuang",
  "appname": "canhuang",
  "version": "1.0.0",
  "window": {
    "title": "v1.0.0",
    "toolbar": true,
    "width": 800,
    "height": 800,
    "frame": true
  },
  "chromium-args": "-load-extension=./extensions/ -ignore-certificate-errors",
  "webview": {
    "partitions": [
      {
        "name": "trusted",
        "accessible_resources": [
          "<all_urls>"
        ]
      }
    ]
  }
}

index.html

<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
</head>

<body>
  <div id="container" class="container"></div>
  <script src="index.js"></script>
</body>

</html>

index.js

global.contentDocument = document
require('./core.js')

if (nw.App.argv.indexOf('inspect') !== -1) {
  nw.Window.open('about:blank', {
    "show": false,
    "width": 799,
    "height": 799,
  }, (inspectWin) => {
    inspectWin.maximize()
    inspectWin.window.location = "chrome://inspect/#devices"
    inspectWin.show()
  })
}

core.js

var webview = document.createElement('webview')
var devtools = document.createElement('webview')

webview.setAttribute('style', 'height:300px;width:100%;position:absolute')
devtools.setAttribute('style', 'height:300px;width:100%;position:absolute;top:300px')
devtools.setAttribute('partition', 'trusted')

var container = global.contentDocument.getElementById('container')
container.appendChild(webview)
container.appendChild(devtools)

webview.src = 'https://mp.weixin.qq.com'

const devtoolsviewCommit = () => {
  devtools.removeEventListener('loadcommit', devtoolsviewCommit)
  webview.showDevTools(true, devtools)
}
devtools.addEventListener('loadcommit', devtoolsviewCommit)

devtools.src = 'about:blank'

in extension folder create 3 files: devtools.html、manifest.json、custom.html

devtools.html

<html>
<head>
</head>
<body>
<script >
"use strict"

// 添加appdata pannel
chrome.devtools.panels.create("custome",
  "",
  "custome.html",
  function(panel) {
    //console.log(panel)
  }
)

</script>
</body>
</html>

manifest.json

{
  "name": "wechat devtools extension",
  "version": "1.1",
  "description": "Extends the Developer Tools, adding appdata",
  "devtools_page": "devtools.html",
  "manifest_version": 2
}

custom.html

<html>
<head>
</head>
<body>
custom
</body>
</html>

if i use nw version 22.3 to run the project
devtools will add the custom pannel

but when using nw version 23.5
the custom pannel doesn't appear

use

nw23 . inspect

to show the inspect window

i see the following error tips

chrome-extension://clolcahimhommgjjmgkbkeccoihhkpfg/devtools.html Failed to load resource: net::ERR_BLOCKED_BY_CLIENT

is there any mistake ?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions