Chrome DevTools - The Sources Panel PDF
Chrome DevTools - The Sources Panel PDF
- When a file is
correctly
connected in a
workspace, a green
dot will appear to
the left of the
file
See a file has changed in a workspace
- Three options
- Node removal: triggered when selected element (node) removed
- Example: closing a modal that was dynamically added to page
- Attributes modifications: triggered when attribute added or removed
on selected element or when an attribute value changes
- Examples of HTML attributes: id, class, style, or title
- Example: an element that toggles a class styled to
`display: none`
- Subtree modifications: triggered when child of selected element
removed, added, or moved; not triggered on child node attribute
changes or on changes to selected parent node
- The next slide is an example of a subtree modification when an
image is added to page
DOM breakpoints example
DOM breakpoints example
- XMLHttpRequest (XHR) is
an application
programming interface
(API) in the form of an
object whose methods
transfer data between a
web browser and a web
server
- XHR objects can be seen
in the Network panel
Add XHR breakpoints
- Enter the value that you want to look for in the URL and
hit enter
- You can also set up a XHR breakpoint to look for any XHR
or fetch that happens
- Just add a XHR breakpoint and don’t enter a value for the
URL
XHR breakpoints example
XHR breakpoints example
- This is what the XHR object will look like in the Network
panel
- To see this, click on the XHR request to open the right
pane that has more information on the request
- Click on the Headers tab to see the request URL
Event breakpoints
- Icon:
- Exceptions, also called runtime errors, occur during
execution of a script
- Here, we are trying to log an undefined variable and get
an exception
Breakpoint Navigation
Breakpoint navigation
- Icon:
- Execute code until the next
breakpoint
- Example
- Breakpoints are on lines 7 and 14
- Code execution is stopped on line 7
- Resume script execution is chosen
- Execution will stop on the next
breakpoint on line 14
Resume script execution
Step over
- Icon:
- Execute a function without
stepping into it
- Example
- The only breakpoint is on line 2
- Code execution is stopped on line 2
- Step over is chosen
- functionA is called on line 2
- functionA on line 6 will run but will
not be paused on or within
- Execution will stop on next line
after the function it stepped over,
which is line 3
Step over
Step into
- Icon:
- Investigate the contents of a
function and go line by line
- Example
- The only breakpoint is on line 2
- Step into is chosen
- functionA is called on line 2
- functionA on line 6 will start
running
- Execution will stop on line 7
Step into
Step out of
- Icon:
- Execute the rest of a function
and stop on next breakpoint
- Example
- The only breakpoint is on line 7
- Code execution is stopped on line 7
- Step out of is chosen
- The rest of functionA will run, but
not pause on lines 8-13
- Execution will stop at next line
after the function that was stepped
out of
Step out of
Step?
- Icon:
- Seems to behave like stepping into a function (going
line by line)
Turn Off
Breakpoints
Turn off breakpoints options
- Remove breakpoint
- Removes the one breakpoint right clicked on
- Remove all breakpoints
- Removes all breakpoints (be careful with this and the next option!)
- Remove other breakpoints
- Removes all breakpoints except the one that was right clicked on
Disable and deactivate all breakpoints
- Mac: Cmd + P
- Windows/Linux: Ctrl + P
Go to line
- Mac: Cmd + G
- Windows/Linux: Ctrl + G
Search source code
- Mac:
Cmd + Opt + F
- Windows/Linux:
Ctrl + Shift + F
- Works for regular
expressions
(searching for a
pattern or sequence
of characters) and
quotes
Multi select
- Mac:
Cmd + click where to
enter text
- Windows/Linux:
Ctrl + click where to
enter text
Select occurrences and multi edit
- Various tips
- https://tutorialzine.com/2015/03/15-must-know-chrome-devtools-tips-tr
icks
- Breakpoints
- https://developers.google.com/web/tools/chrome-devtools/javascript/br
eakpoints
- Workspaces
- https://developers.google.com/web/tools/chrome-devtools/workspaces/
- How to use Chrome DevTools in Visual Studio Code
- https://www.sencha.com/blog/debugging-ext-js-applications-using-visua
l-studio-code-and-google-chrome/
Resources
- Scope
- https://medium.com/dailyjs/i-never-understood-javascript-closures-966
3703368e8
- Chrome DevTools on Twitter
- https://twitter.com/ChromeDevTools
Questions?
Thank you
and happy debugging!
Slides:
http://bit.ly/chromedevtoolssourcespanel
LinkedIn:
http://bit.ly/lisafrenchlinkedin
Twitter:
@lisafrench