7

Or can Chrome open debugger automatically when it opens a page which contains 'debugger' keyword in its source code?

2
  • 3
    @Cole Johnson: I disagree, the faq states questions about "software tools commonly used by programmers" are allowed. Commented Jun 10, 2012 at 13:49
  • @Cole Johnson: well, since I'm leaning Core Javascript and I have to debug it with Javascript embedded in a HTML page. I wrote a python script to put the JS file path to a html page's <script> tag's 'src' property, the load the page with chrome, so that I can run and debug my newly written JS script by just a command, but at its last step, opening Chrome debug console still need to be done by myself every time, I just want to make the whole process automatic. Commented Jun 10, 2012 at 16:41

3 Answers 3

1

Previously there was a command line flag --always-enable-devtools, doesn't look like there is anymore. However, there's a nifty trick you can use although if you're not on OSX you'll have to fiddle around a bit to reproduce what I'm doing.

I made two shell scripts, 'developer-chrome' and 'debugger-chrome'.

developer-chrome is the instance I want to always be observing, debugger-chrome will just sit in my second monitor so I can see console messages and poke developer-chrome when I want.

developer-chrome

#!/bin/bash

export PROFILE=$HOME/develop-chromium-profile
export DISK_CACHEDIR=/tmp/develop-chromium-profile-cache
export DISK_CACHESIZE=0
export MEDIA_CACHESIZE=0
/Applications/Chromium.app/Contents/MacOS/Chromium \
    --remote-debugging-port=4096 \
    --user-data-dir=${PROFILE} \
    --enable-experimental-webgl=yes \
    --window-position=3000,400 \
    --window-size=1200,1000 \
    --no-pings \
    --disk-cache-dir=${DISK_CACHEDIR} \
    --disk-cache-size=${DISK_CACHESIZE} \
    --media-cache-size=${MEDIA_CACHESIZE} \
    --disable-geolocation \
    --ash-immersive \
    --disable-application-cache \
    --pinned-tab-count=1 http://some_url_im_developing_on/

debugger-chrome

#!/bin/bash

export PROFILE=$HOME/debugger-chromium-profile
export DISK_CACHEDIR=/tmp/debugger-chromium-profile-cache
export DISK_CACHESIZE=0
export MEDIA_CACHESIZE=0
/Applications/Chromium.app/Contents/MacOS/Chromium \
    --user-data-dir=${PROFILE} \
    --enable-experimental-webgl=yes \
    --window-position=2400,400 \
    --window-size=1200,1000 \
    --no-pings \
    --disk-cache-dir=${DISK_CACHEDIR} \
    --disk-cache-size=${DISK_CACHESIZE} \
    --media-cache-size=${MEDIA_CACHESIZE} \
    --disable-geolocation \
    --ash-immersive \
    --disable-application-cache \
    --pinned-tab-count=1 http://localhost:4096/

Run developer-chrome first, then debugger-chrome. Both instances of chrome will be autonomous so you can stop/restart them if you wish. You may have to manually reattach to the debugger from the debugger-chrome if you get disconnected.. but. I dunno.

It really irks me that there's no way to get devtools to just come up automatically. That coupled with Chrome's 'did it or didn't it?' caching behavior with dynamic content has almost gotten me to consider Firefox.

Sign up to request clarification or add additional context in comments.

Comments

0

/When I've used the following in Chrome (on a Mac) debugger; it will not open the Console automatically and will only run if the Developer Tools are all ready active. When doing the same and running my page/script in Firefox (with Firebug installed) the JavaScript Console/Debugger is opened when the debugger; statement is hit.

Just my experience..

Comments

0

Yes.

The Google Chrome can open the debbuger since you use the flag debbuger. See example below:

<script>
  (yourcode here)
  debugger;
  (next code to debug)
</script>

The Sources panel of Developers Tools will automatically open for you in that specific line.

It also works for Internet Explorer 11.

Tested on version 43.x.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.