Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 76ad89c

Browse files
eduard13jeff-matthews
authored andcommitted
JS debugging by using DevTools (#4392)
* Adding another way of JS debugging by using the DevTools * Adjusting content based on suggestions * Adding the editorial suggestions
1 parent a9cf96b commit 76ad89c

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed
33.1 KB
Loading
46.7 KB
Loading
111 KB
Loading

guides/v2.1/ui_comp_guide/troubleshoot/ui_comp_troubleshoot_js.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,47 @@ var fieldName = ko.contextFor($0).$data;
6464
console.log(fieldName.name); // product_form.product_form.product-details.container_name.name
6565
```
6666

67+
## Debugging using Chrome DevTools
68+
69+
All modern browsers support “debugging” – a special UI in developer tools that makes finding and fixing errors much easier.
70+
71+
### Sources panel UI
72+
73+
[DevTools] provides a lot of different tools for different tasks, but the **Sources** panel is where you debug JavaScript.
74+
75+
1. Open the required page in Chrome.
76+
2. Turn on developer tools with F12 (Windows, Linux) or Cmd+Opt+I (Mac).
77+
3. Click the `Sources` tab.
78+
79+
![Sources Panel]({{ site.baseurl }}/common/images/debugging-sources-pane.png)
80+
81+
In the previous image, we can see three zones:
82+
83+
1. The `Resources` zone lists all the files as HTML, JavaScript, CSS.
84+
2. The `Source` zone shows the source code of any selected file.
85+
3. The `Information and control` zone is for debugging.
86+
87+
### Breakpoints
88+
89+
A **breakpoint** is a line of code where the debugger will automatically pause the JavaScript execution process.
90+
To set a breakpoint, right click on the code line number (as shown in the next image).
91+
92+
![Breakpoints]({{ site.baseurl }}/common/images/debugging-breakpoints.png)
93+
94+
You can always find a list of breakpoints in the right panel, which is useful when you have many breakpoints in various files.
95+
96+
{: .bs-callout .bs-callout-info }
97+
Right-clicking on the line number allows you to create a conditional breakpoint, which triggers only when the given expression is truthy. That’s helpful when you need to stop only for certain function parameters.
98+
99+
### Execution trace
100+
101+
After setting the breakpoint, refresh the page. Now, let's explore the script tracing. As you can see in the next image, the script execution paused on the given breakpoint.
102+
103+
![Execution Trace]({{ site.baseurl }}/common/images/debugging-execution-trace.png)
104+
105+
As result, you can see the input parameter values and what the function returns. Moreover, we're also able to change the function's values on the fly.
106+
67107
## See also
68108

69109
[Debug using uiRegistry]({{ page.baseurl }}/ui_comp_guide/concepts/ui_comp_uiregistry.html#debug_uiregistry)
110+
[DevTools]: https://developers.google.com/web/tools/chrome-devtools/javascript/

guides/v2.2/ui_comp_guide/troubleshoot/ui_comp_troubleshoot_js.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,47 @@ var fieldName = ko.contextFor($0).$data;
6161
console.log(fieldName.name); // product_form.product_form.product-details.container_name.name
6262
```
6363

64+
## Debugging using Chrome DevTools
65+
66+
All modern browsers support “debugging” – a special UI in developer tools that makes finding and fixing errors much easier.
67+
68+
### Sources panel UI
69+
70+
[DevTools] provides a lot of different tools for different tasks, but the **Sources** panel is where you debug JavaScript.
71+
72+
1. Open the required page in Chrome.
73+
2. Turn on developer tools with F12 (Windows, Linux) or Cmd+Opt+I (Mac).
74+
3. Click the `Sources` tab.
75+
76+
![Sources Panel]({{ site.baseurl }}/common/images/debugging-sources-pane.png)
77+
78+
In the previous image, we can see three zones:
79+
80+
1. The `Resources` zone lists all the files as HTML, JavaScript, CSS.
81+
2. The `Source` zone shows the source code of any selected file.
82+
3. The `Information and control` zone is for debugging.
83+
84+
### Breakpoints
85+
86+
A **breakpoint** is a line of code where the debugger will automatically pause the JavaScript execution process.
87+
To set a breakpoint, right click on the code line number (as shown in the next image).
88+
89+
![Breakpoints]({{ site.baseurl }}/common/images/debugging-breakpoints.png)
90+
91+
You can always find a list of breakpoints in the right panel, which is useful when you have many breakpoints in various files.
92+
93+
{: .bs-callout .bs-callout-info }
94+
Right-clicking on the line number allows you to create a conditional breakpoint, which triggers only when the given expression is truthy. That’s helpful when you need to stop only for certain function parameters.
95+
96+
### Execution trace
97+
98+
After setting the breakpoint, refresh the page. Now, let's explore the script tracing. As you can see in the next image, the script execution paused on the given breakpoint.
99+
100+
![Execution Trace]({{ site.baseurl }}/common/images/debugging-execution-trace.png)
101+
102+
As result, you can see the input parameter values and what the function returns. Moreover, we're also able to change the function's values on the fly.
103+
64104
## See also
65105

66106
[Debug using uiRegistry]({{ page.baseurl }}/ui_comp_guide/concepts/ui_comp_uiregistry.html#debug_uiregistry)
107+
[DevTools]: https://developers.google.com/web/tools/chrome-devtools/javascript/

0 commit comments

Comments
 (0)