aboutsummaryrefslogtreecommitdiff
path: root/files/ru/tools/about_colon_debugging/index.html
blob: 2fce1108fe2acae7f61e3107ecf2adf6d06a3179 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---
title: 'about:debugging'
slug: 'Tools/about:debugging'
translation_of: 'Tools/about:debugging'
---
<div>{{ToolsSidebar}}</div><div style="padding-bottom: 30px;"><span class="s3gt_translate_tooltip_variant" id="s3gt_translate_tooltip_variant_to_id_0">Страница about: debugging предоставляет одно место, из которого вы можете прикрепить Firefox Developer Tools к ряду целей отладки.</span> <span class="s3gt_translate_tooltip_variant" id="s3gt_translate_tooltip_variant_to_id_1">В настоящий момент он поддерживает два основных типа целей: перезагружаемые надстройки и рабочие.</span></div>

<h2 id="Как_открыть_страницу_aboutdebugging">Как открыть страницу about:debugging?</h2>

<p>Есть несколько способов открыть страницу about:debugging:</p>

<ul>
 <li>Введите "about:debugging" в строке URL Firefox .</li>
 <li>Новое в Firefox 47: in the Tools &gt; Web Developer menu, click "Service Workers".</li>
 <li>Новое в Firefox 47: кликни по иконке гаечного ключа (<img alt="" src="https://mdn.mozillademos.org/files/12710/wrench-icon.png" style="height: 21px; width: 21px;">), который находится на главной панели инструментов  или под меню Hamburger (<img alt="" src="https://mdn.mozillademos.org/files/12712/hamburger.png" style="height: 20px; width: 22px;">), затем выбери "Service Workers".</li>
</ul>

<p>Когда about:debugging открывается, с левой стороны будет видна боковая панель , позволяющая переключаться между двумя основными видами : один вид для "add-ons" и второй для  "workers".</p>

<h2 id="Add-ons">Add-ons</h2>

<div class="note">
<p>The Add-ons section in about:debugging only supports restartless add-ons, including <a href="/en-US/Add-ons/Bootstrapped_extensions">basic bootstrapped extensions</a>, <a href="/en-US/Add-ons/SDK">Add-on SDK add-ons</a>, and <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions">WebExtensions</a>.</p>
</div>

<p>This page enables you to do two things:</p>

<ul>
 <li>Load an add-on temporarily from disk</li>
 <li>Connect the <a href="/en-US/Add-ons/Add-on_Debugger">Add-on Debugger</a> to any restartless add-ons</li>
</ul>

<p><img alt="" src="https://mdn.mozillademos.org/files/13134/about-debugging-addons.png" style="display: block; height: 535px; margin-left: auto; margin-right: auto; width: 784px;"></p>

<h3 id="Connecting_the_Add-on_Debugger">Connecting the Add-on Debugger</h3>

<div class="note">
<p>Note that at the moment, it's recommended that you use the Browser Toolbox, not the Add-on Debugger, for debugging WebExtensions. See <a href="/en-US/Add-ons/WebExtensions/Debugging">Debugging WebExtensions</a> for all the details.</p>
</div>

<p>The Add-ons page in about:debugging lists all restartless add-ons that are currently installed (note that this list may include add-ons that came preinstalled with your Firefox). Next to each entry is a button labeled "Debug".</p>

<p>If the "Debug" button is disabled, check the "Enable add-on debugging" box.</p>

<p>If you click "Debug", you'll see a dialog asking you to accept an incoming connection. Click "OK", and the <a href="/en-US/docs/Mozilla/Add-ons/Add-on_Debugger">Add-on Debugger</a> will start in a separate window. Note that sometimes the debugger window is hidden by the main Firefox window.</p>

<p>{{EmbedYouTube("tGGcA3bT3VA")}}</p>

<p>See the page on the <a href="/en-US/docs/Mozilla/Add-ons/Add-on_Debugger">Add-on Debugger</a> for all the things you can do with this tool.</p>

<div class="note">
<p><a id="Enabling_add-on_debugging" name="Enabling_add-on_debugging">The "Enable add-on debugging" button</a> works by turning on the <code>devtools.chrome.enabled</code> and <code>devtools.debugger.remote-enabled</code> preferences. Both preferences must be true to enable add-on debugging. Checking the box sets both preferences to <code>true</code>, and unchecking it sets them both to <code>false</code>.</p>

<p>You can also modify the preferences directly in about:config, or by checking "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" in the <a href="/en-US/docs/Tools/Tools_Toolbox#Settings">Developer Tools Settings</a>.</p>
</div>

<h3 id="Loading_a_temporary_add-on">Loading a temporary add-on</h3>

<p>With the "Load Temporary Add-on" button you can load any sort of restartless add-on temporarily, from a directory on disk. Just click the button, navigate to the directory containing the add-on's file, and select any file in that directory.</p>

<p>You don't have to package or sign the add-on. The add-on will stay installed until you restart Firefox.</p>

<p>{{EmbedYouTube("sAM78GU4P34")}}</p>

<p>The big advantages of this method, compared with installing an add-on from an XPI, are:</p>

<ul>
 <li>you don't have to rebuild an XPI and reinstall when you change the add-on's code</li>
 <li>you can load an add-on without signing it and without needing to disable signing.</li>
</ul>

<h3 id="Updating_a_temporary_add-on">Updating a temporary add-on</h3>

<p>If you install the add-on in this way, what happens when you update the add-on's files?</p>

<h4 id="Before_Firefox_48">Before Firefox 48</h4>

<ul>
 <li>If you change files that are loaded on demand, like <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts</a> or <a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Browser_actions_2">popups</a>, then changes you make are picked up automatically, and you'll see them the next time the content script is loaded or the popup is shown.</li>
 <li>If you change files that stay loaded the whole time, like <a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">background scripts</a>, then you can pick up changes you've made by disabling and then re-enabling the add-on in the about:addons page.</li>
 <li>If you change files that are only parsed at install time, like the <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json">manifest.json</a> file, you'll need to restart Firefox, then load the add-on again.</li>
</ul>

<div class="note">
<p>Note that before Firefox 48, loading the add-on again by pressing "Load Temporary Add-on" without restarting Firefox <em>does not work</em>.</p>
</div>

<h4 id="Firefox_48_onwards">Firefox 48 onwards</h4>

<ul>
</ul>

<p>From Firefox 48 onwards:</p>

<ul>
 <li>as before: if you change files that are loaded on demand, like <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts</a> or <a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Browser_actions_2">popups</a>, then changes you make are picked up automatically, and you'll see them the next time the content script is loaded or the popup is shown.</li>
 <li>there's a better way to handle the other cases: click the "Reload" button next to the "Debug" button. This does what it says:
  <ul>
   <li>reloading any persistent scripts, such as <a href="/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">background scripts</a></li>
   <li>parsing the manifest.json file again, so changes to <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permissions</a></code>, <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts">content_scripts</a></code>, <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_action">browser_action</a></code> or any other keys will take effect.</li>
  </ul>
 </li>
</ul>

<div class="note">
<p>Note that in Firefox 49 onwards, the Reload button is only enabled for temporary add-ons. It will be disabled for all other add-ons.</p>
</div>

<h2 id="Tabs">Tabs</h2>

<p>In Firefox 49 onwards, a Tabs page is available in <code>about:debugging</code> — this provides a complete list of all the debuggable tabs open in the current Firefox instance.</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/13617/about-debugging-tabs.png" style="display: block; height: 628px; margin: 0px auto; width: 900px;"></p>

<p>Each tab entry has a <em>Debug</em> button next to it — when clicked, this will open up a toolbox specific to that tab, allowing you to debug that tab's contents.</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/13619/about-debugging-tabs-toolbox.png" style="display: block; height: 628px; margin: 0px auto; width: 900px;"></p>

<div class="note">
<p>Note that this feature isn't that immediately useful to debugging desktop tabs — you can open up a toolbox to debug a tab easily enough already — but this will become far more useful when <code>about:debugging</code> starts to support remote debugging, and this page can begin to list tabs available for debugging on mobile device browsers, simulators, etc. See {{bug(1212802)}} for the latest on this work.</p>
</div>

<h2 id="Workers">Workers</h2>

<p>The Workers page shows your workers, categorised as follows:</p>

<ul>
 <li>All registered <a href="/en-US/docs/Web/API/Service_Worker_API">Service Workers</a></li>
 <li>All registered <a href="/en-US/docs/Web/API/SharedWorker">Shared Workers</a></li>
 <li>Other workers, including <a href="/en-US/docs/Web/API/ChromeWorker">Chrome Workers</a> and <a href="/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Dedicated_workers">Dedicated Workers</a></li>
</ul>

<p>You can connect the developer tools to each worker, and send push notifications to service workers.</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/13058/about-debugging-workers.png" style="display: block; height: 642px; margin-left: auto; margin-right: auto; width: 784px;"></p>

<div class="note">
<p>This section uses a simple ServiceWorker demo, hosted at <a href="https://serviceworke.rs/push-simple/">https://serviceworke.rs/push-simple/</a>.</p>
</div>

<h3 id="Debugging_workers">Debugging workers</h3>

<p>For a service worker, if it is already running, you'll see two buttons next to it, labeled "Debug" and "Push". If it's not already running, you'll see one button, labeled "Start": click this to start the service worker.</p>

<p>Clicking "Debug" connects the JavaScript Debugger and Console to this worker. You can set breakpoints, step through code, watch variables, evaluate code, and so on:</p>

<p>{{EmbedYouTube("Z8ax79sHWDU")}}</p>

<h3 id="Registering_workers">Registering workers</h3>

<p>At first, you won't see any workers listed under <em>Service Workers</em> or <em>Shared Workers</em>. As soon as a worker is registered, the listing is updated:</p>

<p>{{EmbedYouTube("wy4kyWFhFF4")}}</p>

<div class="note">
<p>Before Firefox 47, service workers were only shown when they were actually running.</p>
</div>

<h3 id="Unregistering_service_workers">Unregistering service workers</h3>

<div class="geckoVersionNote">
<p>New in Firefox 48.</p>
</div>

<p>Starting in Firefox 48, you'll see a link named "unregister" next to each registered service worker:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/13056/unregister-sw.png" style="display: block; margin-left: auto; margin-right: auto; width: 700px;"></p>

<p>Click the link to unregister the service worker.</p>

<h3 id="Sending_push_events_to_service_workers">Sending push events to service workers</h3>

<div class="note">
<p>Sending push events in about:debugging is new in Firefox 47.</p>
</div>

<p>To debug push notifications, you can set a breakpoint in the <a href="/en-US/docs/Web/API/PushEvent">push event</a> listener. However, you can also debug push notifications locally, without needing the server. Just click the "Push" button to send a push event to the service worker:</p>

<p>{{EmbedYouTube("62SkLyA-Zno")}}</p>

<h3 id="Service_workers_not_compatible">Service workers not compatible</h3>

<div>
<p>In Firefox 49+, a warning message will be displayed in the Service Workers section of the Workers page if service workers are incompatible with the current browser configuration, and therefore cannot be used or debugged.</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/13613/sw-not-compatible.png" style="display: block; height: 705px; margin: 0px auto; width: 1011px;"></p>
</div>

<p>Service workers can be unavailable for several reasons:</p>

<ul>
 <li>If you are using a Private Browsing window.</li>
 <li>If your History preference is set to "Never Remember History" or "Always use private browsing mode".</li>
 <li>If the <code>dom.serviceWorkers.enable</code> preference is set to false in <code>about:config</code>.</li>
</ul>