Giter Club home page Giter Club logo

vscode-devtools's Introduction

THIS PROJECT IS NO LONGER UNDER ACTIVE DEVELOPMENT

This was a project that I took on in my spare time to show the potential of having the DevTool embedded directly in VS Code. Unfortunately I no longer have the time to keep this up to date with all the new changes in Chrome, so I am archiving the project and will be removing it from the VS Code marketplace.

However, I think the experiment was a success, and it worked so well in fact, that there is now an officially supported version from Microsoft for the Edge DevTools, which you should check out at the following links:

Microsoft Edge Developer Tools for Visual Studio Code

Microsoft Edge Developer Tools integration in VS Code

You can install the Edge version from the VS Code marketplace

Thanks to everyone that installed/used/filed issues for this project, and I hope it was useful while it lasted.

VSCode DevTools for Chrome

A VSCode extension to host the chrome devtools inside of a webview.

Marketplace badge

Attaching to a running chrome instance:

Demo1

Launching a 'debugger for chrome' project and using screencast:

Demo2

Using the extension

Launching as a Debugger

You can launch the Chrome DevTools hosted in VS Code like you would a debugger, by using a launch.json config file. However, the Chrome DevTools aren't a debugger and any breakpoints set in VS Code won't be hit, you can of course use the script debugger in Chrome DevTools.

To do this in your launch.json add a new debug config with two parameters.

  • type - The name of the debugger which must be devtools-for-chrome. Required.
  • url - The url to launch Chrome at. Optional.
  • file - The local file path to launch Chrome at. Optional.
  • request - Whether a new tab in Chrome should be opened launch or to use an exsisting tab attach matched on URL. Optional.
  • name - A friendly name to show in the VS Code UI. Required.
{
    "version": "0.1.0",
    "configurations": [
        {
            "type": "devtools-for-chrome",
            "request": "launch",
            "name": "Launch Chrome DevTools",
            "file": "${workspaceFolder}/index.html"
        },
        {
            "type": "devtools-for-chrome",
            "request": "attach",
            "name": "Attach Chrome DevTools",
            "url": "http://localhost:8000/"
        }
    ]
}

Launching Chrome manually

  • Start chrome with no extensions and remote-debugging enabled on port 9222:
    • chrome.exe --disable-extensions --remote-debugging-port=9222
  • Open the devtools inside VS Code:
    • Run the command - DevTools for Chrome: Attach to a target
    • Select a target from the drop down

Launching Chrome via the extension

  • Start chrome:
    • Run the command - DevTools for Chrome: Launch Chrome and then attach to a target
    • Navigate to whatever page you want
  • Open the devtools inside VS Code:
    • Select a target from the drop down

Known Issues

  • Prototyping stage
  • Having the DevTools in a non-foreground tab can cause issues while debugging
    • This is due to VS Code suspending script execution of non-foreground webviews
    • The workaround is to put the DevTools in a split view tab so that they are always visible while open
  • Chrome browser extensions can sometimes cause the webview to terminate

Developing the extension itself

  • Start chrome with remote-debugging enabled on port 9222
    • chrome.exe --disable-extensions --remote-debugging-port=9222
  • Run the extension
    • npm install
    • npm run watch or npm run build
    • Open the folder in VSCode
    • F5 to start debugging
  • Open the devtools
    • Run the command - DevTools for Chrome: Attach to a target
    • Select a target from the drop down

vscode-devtools's People

Contributors

andysterland avatar blanksourcecode avatar codemooseus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-devtools's Issues

problem in mac

hello i can't get this to work in both methodes , does this works in macos catalina ?

empty devTools window

After selecting chrometab target, devtool window is empty :'(

image

vscode devtool show following message

[Embedded Page] Refused to load the script 'vscode-resource:/c%3A/Users/tgirard/.vscode/extensions/codemooseus.vscode-devtools-for-chrome-0.0.5/node_modules/chrome-devtools-frontend/front_end/Runtime.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

[Embedded Page] Refused to load the script 'vscode-resource:/c%3A/Users/tgirard/.vscode/extensions/codemooseus.vscode-devtools-for-chrome-0.0.5/node_modules/chrome-devtools-frontend/front_end/inspector.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

[Embedded Page] Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.

image

Dev Tools when coming up empty

I saw a closed issue about this in the release log, but I'm running the latest version of VS Code and this issue is still occurring for me. The Dev Tools window opens, but it is completely empty.

image

image

image

image

Can't get working manually on macOS

I tried to run google manually using the following command

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --disable-extensions

It fires up in new window, then I navigate to any page, then going back to vscode and running Attach to target command. And getting the following error

Could not find any targets for attaching. Did you remember to run Chrome with '--remote-debugging-port=9222'?

how does it work in WSL2 ?

I tried to find wsl related usage in issues, but didn't solve my problem.
how does it work in wsl2 ?

Windows 10 21322.1000
WSL2 - CentOS 7.6

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to Chrome",
      "port": 9222,
      "request": "attach",
      "type": "pwa-chrome",
      "webRoot": "${workspaceFolder}"
    },
    {
      "name": "Launch Chrome",
      "request": "launch",
      "type": "pwa-chrome",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}",
      "port": 9222
    },
    {
      "type": "devtools-for-chrome",
      "request": "launch",
      "name": "Launch Chrome DevTools",
      "url": "http://localhost:3000",
      "chromePath": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
    },
    {
      "type": "devtools-for-chrome",
      "request": "attach",
      "name": "Attach Chrome DevTools",
      "url": "http://localhost:3000/",
      "chromePath": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
    }
  ]
}

settings.json

"vscode-devtools-for-chrome.chromePath": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"

image

Webview crashes shortly after attaching

Even with --disable-extensions (#4), I can't get the extension to work. After using the "Attach to a target" command, the webview flashes for a split second, before switching to a black screen:

VSCode console output after running "Attach to a target"
workbench.main.js:sourcemap:210 [Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
e @ workbench.main.js:sourcemap:210
p @ workbench.main.js:sourcemap:206
t._setListeningToMouseWheel @ workbench.main.js:sourcemap:389
t @ workbench.main.js:sourcemap:387
t @ workbench.main.js:sourcemap:392
t @ workbench.main.js:sourcemap:393
e @ workbench.main.js:sourcemap:394
e @ workbench.main.js:sourcemap:4379
t.create @ workbench.main.js:sourcemap:117
e._createInstance @ workbench.main.js:sourcemap:1389
e.createInstance @ workbench.main.js:sourcemap:1388
t.createBreadcrumbsControl @ workbench.main.js:sourcemap:4460
t.create @ workbench.main.js:sourcemap:4467
t @ workbench.main.js:sourcemap:4460
t @ workbench.main.js:sourcemap:4466
t.create @ workbench.main.js:sourcemap:117
e._createInstance @ workbench.main.js:sourcemap:1389
e.createInstance @ workbench.main.js:sourcemap:1388
t.createTitleAreaControl @ workbench.main.js:sourcemap:5017
t.create @ workbench.main.js:sourcemap:5012
t @ workbench.main.js:sourcemap:5010
t.create @ workbench.main.js:sourcemap:117
e._createInstance @ workbench.main.js:sourcemap:1389
e.createInstance @ workbench.main.js:sourcemap:1388
t.createNew @ workbench.main.js:sourcemap:5010
t.doCreateGroupView @ workbench.main.js:sourcemap:5042
t.doAddGroup @ workbench.main.js:sourcemap:5041
t.addGroup @ workbench.main.js:sourcemap:5041
t.findSideBySideGroup @ workbench.main.js:sourcemap:4578
t.findTargetGroup @ workbench.main.js:sourcemap:4577
t.openEditor @ workbench.main.js:sourcemap:4577
e.createWebview @ workbench.main.js:sourcemap:3663
e.$createWebviewPanel @ workbench.main.js:sourcemap:3687
t._doInvokeHandler @ workbench.main.js:sourcemap:3267
t._invokeHandler @ workbench.main.js:sourcemap:3266
t._receiveRequest @ workbench.main.js:sourcemap:3265
t._receiveOneMessage @ workbench.main.js:sourcemap:3264
(anonymous) @ workbench.main.js:sourcemap:3262
e.fire @ workbench.main.js:sourcemap:181
a @ workbench.main.js:sourcemap:318
n._socketDataListener @ workbench.main.js:sourcemap:318
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.getSelectionBackgroundColor is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.getSelectionForegroundColor is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.getInactiveSelectionBackgroundColor is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.getInactiveSelectionForegroundColor is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.platform is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.loadCompleted is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.bringToFront is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.closeWindow is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setIsDocked is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setInspectedPageBounds is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.inspectElementCompleted is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setInjectedScriptForOrigin is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.inspectedURLChanged is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.copyText is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.openInNewTab is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.showItemInFolder is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.save is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.append is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.close is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.sendMessageToBackend is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.requestFileSystems is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.addFileSystem is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.removeFileSystem is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.isolatedFileSystem is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.loadNetworkResource is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.removePreference is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.clearPreferences is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.upgradeDraggedFileSystemPermissions is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.indexPath is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.stopIndexing is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.searchInPath is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.zoomFactor is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.zoomIn is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.zoomOut is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.resetZoom is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setWhitelistedShortcuts is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setEyeDropperActive is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.showCertificateViewer is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.reattach is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.readyForTest is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.connectionReady is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setOpenNewWindowForPopups is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setDevicesDiscoveryConfig is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.setDevicesUpdatesEnabled is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.performActionOnRemotePage is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.openRemotePage is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.openNodeFrontend is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.showContextMenuAtPoint is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Incompatible embedder: method InspectorFrontendHost.isHostedMode is missing. Using stub instead.
workbench.main.js:sourcemap:3669 [Embedded Page] Main._createAppUI: 18.60302734375ms
workbench.main.js:sourcemap:3669 [Embedded Page] Main._showAppUI: 7.087158203125ms
workbench.main.js:sourcemap:3669 [Embedded Page] Uncaught (in promise) TypeError: target.emulationAgent(...).setFocusEmulationEnabled is not a function
workbench.main.js:sourcemap:3669 embedded page crashed
(anonymous) @ workbench.main.js:sourcemap:3669
dispatchEvent @ C:\Users\jgierer12\AppData\Local\Programs\Microsoft VS Code\resources\electron.asar\renderer\web-view\web-view.js:177
dispatchEvent @ C:\Users\jgierer12\AppData\Local\Programs\Microsoft VS Code\resources\electron.asar\renderer\web-view\guest-view-internal.js:55
(anonymous) @ C:\Users\jgierer12\AppData\Local\Programs\Microsoft VS Code\resources\electron.asar\renderer\web-view\guest-view-internal.js:72
emitThree @ events.js:136
emit @ events.js:217
Environment details
  • Windows 10 Build 17134.345
  • Node 10.13.0
  • npm 6.4.1
  • VSCode 1.28.2
  • vscode-devtools 0.0.3

Chrome browser extensions seem to cause the webview to crash

If you try to attach to an instance of chrome that is using extensions (I was seeing it with ad block plus) then the embedded webview seems to crash and show a black window.

The workaround is to launch chrome with the --disable-extensions flag to turn them off

debug with Google Chrome not auto refresh

This the my launchconfig:

{
"version": "0.1.0",
"configurations": [

    {
        "name": "Chrome DevTools",
        "type": "devtools-for-chrome",
        "request": "launch",
        "url": "http://localhost:3000/"
    }
]

}

I can start debugging on chrome that I have installed on windows, and it opens the site locally on port 3000.
Up to here everything is OK.

problems:

  1. I don't see the debug buttons in vsc (play, stop etc)
  2. even if I view the site when I update the php file, the change is not reflected in chrome (I have to manually refresh the page) ..

how do i configure everything to work as it should ??

Settings from the devtools are not persisted

If you change something like the theme in the devtools themselves, the tools reload but don't change the theme.
Need to hook into the extension globalState to save and restore the preferences.

Adopt VS Code's 'asWebviewUri' API

Hi, I maintain VS Code's Webview API

Issue

Our telemetry suggests that your extension uses webviews and may be loading resources in these webviews using hardcoded vscode-resource: URIs. These URIs have some important limitations and don't work properly when VS Code is run in a browser. We are also making changes in the desktop version of VS Code that may cause these URIs to not work properly in future versions of VS Code.

While we are making our best effort to continue support existing webview extensions that use vscode-resource: URIs on desktop versions of VS Code, we will not able to fully support all uses cases.

Fix

To ensure that your extension continues to work in as many environments as possible—including on web and remotely—please:

These APIs shipped around 2 years ago so they should be available in all modern versions of VS Code. You can find additional information about the issue here: microsoft/vscode#97962

Let me know if you have any questions about this change

Crash when use console tab

Visual Studio Code
Version: 1.39.1
Date: 2019-10-10T23:35:11.314Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.7.0

Sreenshot 14-10-2019 17 19 21
Sreenshot 14-10-2019 17 21 15
Sreenshot 14-10-2019 17 21 22

Cannot Copy/Paste

Hello!

This is an absolutely fantastic extension for frontend development, it should be in the top 10 extensions.

The only problem I have with it is that I cannot copy/paste any text from within its devtools. If this would be supported for me it would be 100% perfect.

Is there a workaround for this?
Thanks!

Support other chromium browsers

At the moment both attaching a target and launching as debugger only work on chrome. If the command's running is chrome.exe --disable-extensions --remote-debugging-port=9222 like the docs state, would it be possible to point it to another chromium exe?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.