| OLD | NEW |
| 1 <div id="pageData-name" class="pageData">Tutorial: Debugging</div> | 1 <h1>Tutorial: Debugging</h1> |
| 2 <div id="pageData-showTOC" class="pageData">true</div> | 2 |
| 3 | 3 |
| 4 <p> | 4 <p> |
| 5 This tutorial introduces you to using | 5 This tutorial introduces you to using |
| 6 Google Chrome's built-in Developer Tools | 6 Google Chrome's built-in Developer Tools |
| 7 to interactively debug an extension. | 7 to interactively debug an extension. |
| 8 </p> | 8 </p> |
| 9 | 9 |
| 10 | 10 |
| 11 <h2 id="extension-info"> View extension information </h2> | 11 <h2 id="extension-info"> View extension information </h2> |
| 12 | 12 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 <li> | 74 <li> |
| 75 Right-click the Hello World icon | 75 Right-click the Hello World icon |
| 76 <img src="../examples/tutorials/getstarted/icon.png" | 76 <img src="../examples/tutorials/getstarted/icon.png" |
| 77 width="19" height="19" alt="" | 77 width="19" height="19" alt="" |
| 78 style="margin:0" /> | 78 style="margin:0" /> |
| 79 and choose the <b>Inspect popup</b> menu item. The popup appears, | 79 and choose the <b>Inspect popup</b> menu item. The popup appears, |
| 80 and a Developer Tools window like the following should display the code | 80 and a Developer Tools window like the following should display the code |
| 81 for <b>popup.html</b>. | 81 for <b>popup.html</b>. |
| 82 | 82 |
| 83 <p> | 83 <p> |
| 84 <img src="../images/devtools-1.gif" alt="" | 84 <img src="{{static}}/images/devtools-1.gif" alt="" |
| 85 width="500" height="294" /> | 85 width="500" height="294" /> |
| 86 </p> | 86 </p> |
| 87 The popup remains open as long as the Developer Tools window does. | 87 The popup remains open as long as the Developer Tools window does. |
| 88 </li> | 88 </li> |
| 89 <li> | 89 <li> |
| 90 If the <strong>Scripts</strong> button isn't already selected, | 90 If the <strong>Scripts</strong> button isn't already selected, |
| 91 click it. | 91 click it. |
| 92 <!-- [PENDING: can we omit this step?] --> | 92 |
| 93 </li> | 93 </li> |
| 94 <li> | 94 <li> |
| 95 Click the console button | 95 Click the console button |
| 96 <img src="../images/console-button.gif" | 96 <img src="{{static}}/images/console-button.gif" |
| 97 style="margin:0; padding:0" align="absmiddle" | 97 style="margin:0; padding:0" align="absmiddle" |
| 98 width="26" height="22" alt="" />(second | 98 width="26" height="22" alt="" />(second |
| 99 from left, | 99 from left, |
| 100 at the bottom of the Developer Tools window) | 100 at the bottom of the Developer Tools window) |
| 101 so that you can see both the code and the console. | 101 so that you can see both the code and the console. |
| 102 </li> | 102 </li> |
| 103 </ol> | 103 </ol> |
| 104 | 104 |
| 105 <h2 id="debug"> Use the debugger </h2> | 105 <h2 id="debug"> Use the debugger </h2> |
| 106 | 106 |
| 107 <p> | 107 <p> |
| 108 In this section, | 108 In this section, |
| 109 you'll follow the execution of the popup page | 109 you'll follow the execution of the popup page |
| 110 as it adds images to itself. | 110 as it adds images to itself. |
| 111 </p> | 111 </p> |
| 112 | 112 |
| 113 <ol> | 113 <ol> |
| 114 <li> | 114 <li> |
| 115 Set a breakpoint inside the image-adding loop | 115 Set a breakpoint inside the image-adding loop |
| 116 by searching for the string <b>img.src</b> | 116 by searching for the string <b>img.src</b> |
| 117 and clicking the number of the line where it occurs | 117 and clicking the number of the line where it occurs |
| 118 (for example, <strong>37</strong>): | 118 (for example, <strong>37</strong>): |
| 119 <p> | 119 <p> |
| 120 <img src="../images/devtools-2.gif" alt="" | 120 <img src="{{static}}/images/devtools-2.gif" alt="" |
| 121 width="500" height="294" /> | 121 width="500" height="294" /> |
| 122 </p> | 122 </p> |
| 123 </li> | 123 </li> |
| 124 | 124 |
| 125 <li> | 125 <li> |
| 126 Make sure you can see the <b>popup.html</b> tab. | 126 Make sure you can see the <b>popup.html</b> tab. |
| 127 It should show 20 "hello world" images. | 127 It should show 20 "hello world" images. |
| 128 </li> | 128 </li> |
| 129 | 129 |
| 130 <li> | 130 <li> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 146 you should see the local scope variables. | 146 you should see the local scope variables. |
| 147 This section shows the current values of all variables in the current scope. | 147 This section shows the current values of all variables in the current scope. |
| 148 For example, in the following screenshot | 148 For example, in the following screenshot |
| 149 the value of <code>i</code> is 0, and | 149 the value of <code>i</code> is 0, and |
| 150 <code>photos</code> is a node list | 150 <code>photos</code> is a node list |
| 151 that contains at least a few elements. | 151 that contains at least a few elements. |
| 152 (In fact, it contains 20 elements at indexes 0 through 19, | 152 (In fact, it contains 20 elements at indexes 0 through 19, |
| 153 each one representing a photo.) | 153 each one representing a photo.) |
| 154 | 154 |
| 155 <p> | 155 <p> |
| 156 <img src="../images/devtools-localvars.gif" alt="" | 156 <img src="{{static}}/images/devtools-localvars.gif" alt="" |
| 157 width="225" height="215" /> | 157 width="225" height="215" /> |
| 158 </p> | 158 </p> |
| 159 </li> | 159 </li> |
| 160 | 160 |
| 161 <li> | 161 <li> |
| 162 Click the play/pause button | 162 Click the play/pause button |
| 163 <img src="../images/play-button.gif" | 163 <img src="{{static}}/images/play-button.gif" |
| 164 style="margin:0; padding:0" align="absmiddle" | 164 style="margin:0; padding:0" align="absmiddle" |
| 165 width="22" height="20" alt="" />(near | 165 width="22" height="20" alt="" />(near |
| 166 the top right of the Developer Tools window) | 166 the top right of the Developer Tools window) |
| 167 to go through the image-processing loop a single time. | 167 to go through the image-processing loop a single time. |
| 168 Each time you click that button, | 168 Each time you click that button, |
| 169 the value of <code>i</code> increments and | 169 the value of <code>i</code> increments and |
| 170 another icon appears in the popup page. | 170 another icon appears in the popup page. |
| 171 For example, when <code>i</code> is 10, | 171 For example, when <code>i</code> is 10, |
| 172 the popup page looks something like this: | 172 the popup page looks something like this: |
| 173 </li> | 173 </li> |
| 174 | 174 |
| 175 <p> | 175 <p> |
| 176 <img src="../images/devtools-3.gif" | 176 <img src="{{static}}/images/devtools-3.gif" |
| 177 width="500" height="245" | 177 width="500" height="245" |
| 178 alt="the popup page with 10 images" /> | 178 alt="the popup page with 10 images" /> |
| 179 </p> | 179 </p> |
| 180 | 180 |
| 181 <li> | 181 <li> |
| 182 Use the buttons next to the play/pause button | 182 Use the buttons next to the play/pause button |
| 183 to step over, into, and out of function calls. | 183 to step over, into, and out of function calls. |
| 184 To let the page finish loading, | 184 To let the page finish loading, |
| 185 click line <b>37</b> to disable the breakpoint, | 185 click line <b>37</b> to disable the breakpoint, |
| 186 and then press play/pause | 186 and then press play/pause |
| 187 <img src="../images/play-button.gif" | 187 <img src="{{static}}/images/play-button.gif" |
| 188 style="margin:0; padding:0" align="absmiddle" | 188 style="margin:0; padding:0" align="absmiddle" |
| 189 width="22" height="20" alt="" />to | 189 width="22" height="20" alt="" />to |
| 190 continue execution. | 190 continue execution. |
| 191 </li> | 191 </li> |
| 192 | 192 |
| 193 </ol> | 193 </ol> |
| 194 | 194 |
| 195 | 195 |
| 196 <h2 id="summary">Summary</h2> | 196 <h2 id="summary">Summary</h2> |
| 197 | 197 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 Example: <code>console.log("Hello, world!")</code> | 246 Example: <code>console.log("Hello, world!")</code> |
| 247 </li> | 247 </li> |
| 248 <li> | 248 <li> |
| 249 Follow the <a href="http://www.chromium.org/devtools/google-chrome-developer
-tools-tutorial">Developer Tools tutorial</a>, | 249 Follow the <a href="http://www.chromium.org/devtools/google-chrome-developer
-tools-tutorial">Developer Tools tutorial</a>, |
| 250 explore the | 250 explore the |
| 251 <a href="http://www.chromium.org/devtools">Developer Tools site</a>, | 251 <a href="http://www.chromium.org/devtools">Developer Tools site</a>, |
| 252 and watch some video tutorials. | 252 and watch some video tutorials. |
| 253 </li> | 253 </li> |
| 254 </ul> | 254 </ul> |
| 255 | 255 |
| 256 <!-- [PENDING: do something to help people debug content scripts, which show up
in blue] --> | 256 |
| 257 | 257 |
| 258 <p> | 258 <p> |
| 259 For more ideas, | 259 For more ideas, |
| 260 see the <a href="getstarted.html#summary">Now what?</a> section | 260 see the <a href="getstarted.html#summary">Now what?</a> section |
| 261 of Getting Started. | 261 of Getting Started. |
| 262 </p> | 262 </p> |
| OLD | NEW |