/
remote-console-2.diff
2665 lines (2544 loc) · 83 KB
/
remote-console-2.diff
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# HG changeset patch
# User Mihai Sucan <mihai.sucan@gmail.com>
# Date 1346877118 -10800
# Node ID 5948a892ed36ed0541d703c408c980e9a73f5b24
# Parent 9dddae4f717c043d84bc55102b45085420e1756d
Bug 768096 - Web Console remote debugging protocol support - Part 3: network logging
diff --git a/browser/devtools/webconsole/HUDService-content.js b/browser/devtools/webconsole/HUDService-content.js
--- a/browser/devtools/webconsole/HUDService-content.js
+++ b/browser/devtools/webconsole/HUDService-content.js
@@ -13,17 +13,17 @@ let Ci = Components.interfaces;
let Cu = Components.utils;
const STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
let tempScope = {};
Cu.import("resource://gre/modules/XPCOMUtils.jsm", tempScope);
Cu.import("resource://gre/modules/Services.jsm", tempScope);
Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", tempScope);
Cu.import("resource://gre/modules/devtools/WebConsoleUtils.jsm", tempScope);
-Cu.import("resource:///modules/NetworkHelper.jsm", tempScope);
+Cu.import("resource://gre/modules/devtools/NetworkHelper.jsm", tempScope);
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
let XPCOMUtils = tempScope.XPCOMUtils;
let Services = tempScope.Services;
let gConsoleStorage = tempScope.ConsoleAPIStorage;
let WebConsoleUtils = tempScope.WebConsoleUtils;
let l10n = new WebConsoleUtils.l10n(STRINGS_URI);
let JSPropertyProvider = tempScope.JSPropertyProvider;
diff --git a/browser/devtools/webconsole/HUDService.jsm b/browser/devtools/webconsole/HUDService.jsm
--- a/browser/devtools/webconsole/HUDService.jsm
+++ b/browser/devtools/webconsole/HUDService.jsm
@@ -525,38 +525,22 @@ WebConsole.prototype = {
* the content process.
*
* @private
* @type object
*/
_asyncRequests: null,
/**
- * Message names that the HUD listens for. These messages come from the remote
- * Web Console content script.
- *
- * @private
- * @type array
- */
- _messageListeners: ["WebConsole:Initialized", "WebConsole:NetworkActivity",
- "WebConsole:FileActivity", "WebConsole:LocationChange"],
-
- /**
* The xul:panel that holds the Web Console when it is positioned as a window.
* @type nsIDOMElement
*/
consolePanel: null,
/**
- * The current tab location.
- * @type string
- */
- contentLocation: "",
-
- /**
* Getter for the xul:popupset that holds any popups we open.
* @type nsIDOMElement
*/
get mainPopupSet()
{
return this.chromeDocument.getElementById("mainPopupSet");
},
@@ -616,17 +600,16 @@ WebConsole.prototype = {
_onIframeLoad: function WC__onIframeLoad()
{
this.iframe.removeEventListener("load", this._onIframeLoad, true);
let position = Services.prefs.getCharPref("devtools.webconsole.position");
this.iframeWindow = this.iframe.contentWindow.wrappedJSObject;
this.ui = new this.iframeWindow.WebConsoleFrame(this, position);
- this._setupMessageManager();
},
/**
* Create a panel to open the web console if it should float above
* the content in its own window.
* @private
*/
_createOwnWindowPanel: function WC__createOwnWindowPanel()
@@ -761,18 +744,18 @@ WebConsole.prototype = {
/**
* Retrieve the Web Console panel title.
*
* @return string
* The Web Console panel title.
*/
getPanelTitle: function WC_getPanelTitle()
{
- return l10n.getFormatStr("webConsoleWindowTitleAndURL",
- [this.contentLocation]);
+ let url = this.ui ? this.ui.contentLocation : "";
+ return l10n.getFormatStr("webConsoleWindowTitleAndURL", [url]);
},
positions: {
above: 0, // the childNode index
below: 2,
window: null
},
@@ -987,26 +970,26 @@ WebConsole.prototype = {
message: aMessage,
callback: aCallback,
};
}
this.messageManager.sendAsyncMessage(aName, aMessage);
},
/**
- * Handler for the "WebConsole:LocationChange" message. If the Web Console is
+ * Handler for page location changes. If the Web Console is
* opened in a panel the panel title is updated.
*
- * @param object aMessage
- * The message received from the content script. It needs to hold two
- * properties: location and title.
+ * @param string aURI
+ * New page location.
+ * @param string aTitle
+ * New page title.
*/
- onLocationChange: function WC_onLocationChange(aMessage)
+ onLocationChange: function WC_onLocationChange(aURI, aTitle)
{
- this.contentLocation = aMessage.location;
if (this.consolePanel) {
this.consolePanel.label = this.getPanelTitle();
}
},
/**
* Alias for the WebConsoleFrame.setFilterState() method.
* @see webconsole.js::WebConsoleFrame.setFilterState()
@@ -1028,22 +1011,16 @@ WebConsole.prototype = {
},
/**
* Destroy the object. Call this method to avoid memory leaks when the Web
* Console is closed.
*/
destroy: function WC_destroy()
{
- this.sendMessageToContent("WebConsole:Destroy", {});
-
- this._messageListeners.forEach(function(aName) {
- this.messageManager.removeMessageListener(aName, this.ui);
- }, this);
-
// Make sure that the console panel does not try to call
// deactivateHUDForContext() again.
this.consoleWindowUnregisterOnHide = false;
let popupset = this.mainPopupSet;
let panels = popupset.querySelectorAll("panel[hudId=" + this.hudId + "]");
for (let panel of panels) {
if (panel != this.consolePanel) {
diff --git a/browser/devtools/webconsole/Makefile.in b/browser/devtools/webconsole/Makefile.in
--- a/browser/devtools/webconsole/Makefile.in
+++ b/browser/devtools/webconsole/Makefile.in
@@ -8,16 +8,15 @@ topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
EXTRA_JS_MODULES = \
HUDService.jsm \
PropertyPanel.jsm \
- NetworkHelper.jsm \
NetworkPanel.jsm \
AutocompletePopup.jsm \
$(NULL)
TEST_DIRS = test
include $(topsrcdir)/config/rules.mk
diff --git a/browser/devtools/webconsole/NetworkPanel.jsm b/browser/devtools/webconsole/NetworkPanel.jsm
--- a/browser/devtools/webconsole/NetworkPanel.jsm
+++ b/browser/devtools/webconsole/NetworkPanel.jsm
@@ -11,17 +11,17 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "mimeService", "@mozilla.org/mime;1",
"nsIMIMEService");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkHelper",
- "resource:///modules/NetworkHelper.jsm");
+ "resource://gre/modules/devtools/NetworkHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
const STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_600183_charset.js b/browser/devtools/webconsole/test/browser_webconsole_bug_600183_charset.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_600183_charset.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_600183_charset.js
@@ -24,25 +24,30 @@ function performTest(lastFinishedRequest
HUDService.lastFinishedRequestCallback = null;
executeSoon(finishTest);
}
function test()
{
addTab("data:text/html;charset=utf-8,Web Console - bug 600183 test");
- let initialLoad = true;
+ browser.addEventListener("load", function onLoad() {
+ browser.removeEventListener("load", onLoad, true);
- browser.addEventListener("load", function onLoad() {
- if (initialLoad) {
- openConsole(null, function(hud) {
+ openConsole(null, function(hud) {
+ hud.ui.saveRequestAndResponseBodies = true;
- hud.ui.saveRequestAndResponseBodies = true;
- HUDService.lastFinishedRequestCallback = performTest;
-
- content.location = TEST_URI;
+ waitForSuccess({
+ name: "saveRequestAndResponseBodies update",
+ validatorFn: function()
+ {
+ return hud.ui.saveRequestAndResponseBodies;
+ },
+ successFn: function()
+ {
+ HUDService.lastFinishedRequestCallback = performTest;
+ content.location = TEST_URI;
+ },
+ failureFn: finishTest,
});
- initialLoad = false;
- } else {
- browser.removeEventListener("load", onLoad, true);
- }
+ });
}, true);
}
diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_602572_log_bodies_checkbox.js b/browser/devtools/webconsole/test/browser_webconsole_bug_602572_log_bodies_checkbox.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_602572_log_bodies_checkbox.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_602572_log_bodies_checkbox.js
@@ -76,18 +76,27 @@ function onpopupshown2(aEvent)
// Reopen the context menu.
menupopups[1].addEventListener("popupshown", onpopupshown2b, false);
executeSoon(function() {
menupopups[1].openPopup();
});
}, false);
- executeSoon(function() {
- menupopups[1].hidePopup();
+ waitForSuccess({
+ name: "saveRequestAndResponseBodies update",
+ validatorFn: function()
+ {
+ return huds[1].ui.saveRequestAndResponseBodies;
+ },
+ successFn: function()
+ {
+ menupopups[1].hidePopup();
+ },
+ failureFn: finishTest,
});
}
function onpopupshown2b(aEvent)
{
menupopups[1].removeEventListener(aEvent.type, onpopupshown2b, false);
is(menuitems[1].getAttribute("checked"), "true", "menuitems[1] is checked");
@@ -137,18 +146,27 @@ function onpopupshown1(aEvent)
gBrowser.selectedTab = tabs[1];
waitForFocus(function() {
// Reopen the context menu from tab 2.
menupopups[1].addEventListener("popupshown", onpopupshown2c, false);
menupopups[1].openPopup();
}, tabs[1].linkedBrowser.contentWindow);
}, false);
- executeSoon(function() {
- menupopups[0].hidePopup();
+ waitForSuccess({
+ name: "saveRequestAndResponseBodies update",
+ validatorFn: function()
+ {
+ return huds[0].ui.saveRequestAndResponseBodies;
+ },
+ successFn: function()
+ {
+ menupopups[0].hidePopup();
+ },
+ failureFn: finishTest,
});
}
function onpopupshown2c(aEvent)
{
menupopups[1].removeEventListener(aEvent.type, onpopupshown2c, false);
is(menuitems[1].getAttribute("checked"), "true", "menuitems[1] is checked");
diff --git a/browser/devtools/webconsole/test/browser_webconsole_bug_630733_response_redirect_headers.js b/browser/devtools/webconsole/test/browser_webconsole_bug_630733_response_redirect_headers.js
--- a/browser/devtools/webconsole/test/browser_webconsole_bug_630733_response_redirect_headers.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_bug_630733_response_redirect_headers.js
@@ -12,17 +12,48 @@ const TEST_URI = "http://example.com/bro
let lastFinishedRequests = {};
function requestDoneCallback(aHttpRequest)
{
let status = aHttpRequest.log.entries[0].response.status;
lastFinishedRequests[status] = aHttpRequest;
}
-function performTest(aEvent)
+function consoleOpened(hud)
+{
+ hud.ui.saveRequestAndResponseBodies = true;
+
+ waitForSuccess({
+ name: "saveRequestAndResponseBodies update",
+ validatorFn: function()
+ {
+ return hud.ui.saveRequestAndResponseBodies;
+ },
+ successFn: function()
+ {
+ HUDService.lastFinishedRequestCallback = requestDoneCallback;
+ waitForSuccess(waitForResponses);
+ content.location = TEST_URI;
+ },
+ failureFn: finishTest,
+ });
+
+ let waitForResponses = {
+ name: "301 and 404 responses",
+ validatorFn: function()
+ {
+ return "301" in lastFinishedRequests &&
+ "404" in lastFinishedRequests;
+ },
+ successFn: performTest,
+ failureFn: finishTest,
+ };
+}
+
+function performTest()
{
HUDService.lastFinishedRequestCallback = null;
ok("301" in lastFinishedRequests, "request 1: 301 Moved Permanently");
ok("404" in lastFinishedRequests, "request 2: 404 Not found");
function readHeader(aName)
{
@@ -56,24 +87,13 @@ function performTest(aEvent)
lastFinishedRequests = null;
executeSoon(finishTest);
}
function test()
{
addTab("data:text/html;charset=utf-8,<p>Web Console test for bug 630733");
- browser.addEventListener("load", function onLoad1(aEvent) {
- browser.removeEventListener(aEvent.type, onLoad1, true);
-
- openConsole(null, function(hud) {
- hud.ui.saveRequestAndResponseBodies = true;
- HUDService.lastFinishedRequestCallback = requestDoneCallback;
-
- browser.addEventListener("load", function onLoad2(aEvent) {
- browser.removeEventListener(aEvent.type, onLoad2, true);
- executeSoon(performTest);
- }, true);
-
- content.location = TEST_URI;
- });
+ browser.addEventListener("load", function onLoad(aEvent) {
+ browser.removeEventListener(aEvent.type, onLoad, true);
+ openConsole(null, consoleOpened);
}, true);
}
diff --git a/browser/devtools/webconsole/test/browser_webconsole_netlogging.js b/browser/devtools/webconsole/test/browser_webconsole_netlogging.js
--- a/browser/devtools/webconsole/test/browser_webconsole_netlogging.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_netlogging.js
@@ -63,21 +63,35 @@ function testPageLoad()
executeSoon(testPageLoadBody);
};
content.location = TEST_NETWORK_REQUEST_URI;
}
function testPageLoadBody()
{
+ // Turn on logging of request bodies and check again.
+ hud.ui.saveRequestAndResponseBodies = true;
+
+ waitForSuccess({
+ name: "saveRequestAndResponseBodies update",
+ validatorFn: function()
+ {
+ return hud.ui.saveRequestAndResponseBodies;
+ },
+ successFn: testPageLoadBodyAfterSettingUpdate,
+ failureFn: finishTest,
+ });
+}
+
+function testPageLoadBodyAfterSettingUpdate()
+{
let loaded = false;
let requestCallbackInvoked = false;
- // Turn on logging of request bodies and check again.
- hud.ui.saveRequestAndResponseBodies = true;
requestCallback = function() {
ok(lastRequest, "Page load was logged again");
is(lastRequest.response.content.text.indexOf("<!DOCTYPE HTML>"), 0,
"Response body's beginning is okay");
lastRequest = null;
requestCallback = null;
requestCallbackInvoked = true;
diff --git a/browser/devtools/webconsole/webconsole.js b/browser/devtools/webconsole/webconsole.js
--- a/browser/devtools/webconsole/webconsole.js
+++ b/browser/devtools/webconsole/webconsole.js
@@ -214,23 +214,16 @@ WebConsoleFrame.prototype = {
* the remote server, using the remote debugging protocol.
*
* @see WebConsoleConnectionProxy
* @type object
*/
proxy: null,
/**
- * Tells if the Web Console initialization via message manager completed.
- * @private
- * @type boolean
- */
- _messageManagerInitComplete: false,
-
- /**
* Getter for the xul:popupset that holds any popups we open.
* @type nsIDOMElement
*/
get popupset() this.owner.mainPopupSet,
/**
* Holds the network requests currently displayed by the Web Console. Each key
* represents the connection ID and the value is network request information.
@@ -288,16 +281,22 @@ WebConsoleFrame.prototype = {
filterPrefs: null,
/**
* The nesting depth of the currently active console group.
*/
groupDepth: 0,
/**
+ * The current tab location.
+ * @type string
+ */
+ contentLocation: "",
+
+ /**
* The JSTerm object that manage the console's input.
* @see JSTerm
* @type object
*/
jsterm: null,
/**
* The element that holds all of the messages we display.
@@ -335,40 +334,39 @@ WebConsoleFrame.prototype = {
/**
* Setter for saving of network request and response bodies.
*
* @param boolean aValue
* The new value you want to set.
*/
set saveRequestAndResponseBodies(aValue) {
- this._saveRequestAndResponseBodies = aValue;
-
- let message = {
- preferences: {
- "NetworkMonitor.saveRequestAndResponseBodies":
- this._saveRequestAndResponseBodies,
- },
+ let newValue = !!aValue;
+ let preferences = {
+ "NetworkMonitor.saveRequestAndResponseBodies": newValue,
};
- this.owner.sendMessageToContent("WebConsole:SetPreferences", message);
+ this.webConsoleClient.setPreferences(preferences, function(aResponse) {
+ if (!aResponse.error) {
+ this._saveRequestAndResponseBodies = newValue;
+ }
+ }.bind(this));
},
/**
* Connect to the server using the remote debugging protocol.
* @private
*/
_initConnection: function WCF__initConnection()
{
this.proxy = new WebConsoleConnectionProxy(this);
this.proxy.initServer();
this.proxy.connect(function() {
- if (this._messageManagerInitComplete) {
- this._onInitComplete();
- }
+ this.saveRequestAndResponseBodies = this._saveRequestAndResponseBodies;
+ this._onInitComplete();
}.bind(this));
},
/**
* Find the Web Console UI elements and setup event listeners as needed.
* @private
*/
_initUI: function WCF__initUI()
@@ -639,60 +637,16 @@ WebConsoleFrame.prototype = {
this.completeNode.style.fontSize = "";
this.inputNode.style.fontSize = "";
this.outputNode.style.fontSize = "";
Services.prefs.clearUserPref("devtools.webconsole.fontSize");
}
},
/**
- * Handler for all of the messages coming from the Web Console content script.
- *
- * @private
- * @param object aMessage
- * A MessageManager object that holds the remote message.
- */
- receiveMessage: function WCF_receiveMessage(aMessage)
- {
- if (!aMessage.json || aMessage.json.hudId != this.hudId) {
- return;
- }
-
- switch (aMessage.name) {
- case "WebConsole:Initialized":
- this._onMessageManagerInitComplete();
- break;
- case "WebConsole:NetworkActivity":
- this.handleNetworkActivity(aMessage.json);
- break;
- case "WebConsole:FileActivity":
- this.outputMessage(CATEGORY_NETWORK, this.logFileActivity,
- [aMessage.json.uri]);
- break;
- case "WebConsole:LocationChange":
- this.owner.onLocationChange(aMessage.json);
- break;
- }
- },
-
- /**
- * Callback method used to track the Web Console initialization via message
- * manager.
- *
- * @private
- */
- _onMessageManagerInitComplete: function WCF__onMessageManagerInitComplete()
- {
- this._messageManagerInitComplete = true;
- if (this.proxy.connected) {
- this._onInitComplete();
- }
- },
-
- /**
* The event handler that is called whenever a user switches a filter on or
* off.
*
* @private
* @param nsIDOMEvent aEvent
* The event that triggered the filter change.
*/
_toggleFilter: function WCF__toggleFilter(aEvent)
@@ -1327,17 +1281,17 @@ WebConsoleFrame.prototype = {
urlNode.classList.add("hud-clickable");
urlNode.classList.add("webconsole-msg-body-piece");
urlNode.classList.add("webconsole-msg-url");
linkNode.appendChild(urlNode);
let severity = SEVERITY_LOG;
let mixedRequest =
WebConsoleUtils.isMixedHTTPSRequest(request.url,
- this.owner.contentLocation);
+ this.contentLocation);
if (mixedRequest) {
urlNode.classList.add("webconsole-mixed-content");
this.makeMixedContentNode(linkNode);
// If we define a SEVERITY_SECURITY in the future, switch this to
// SEVERITY_SECURITY.
severity = SEVERITY_WARNING;
}
@@ -1420,73 +1374,87 @@ WebConsoleFrame.prototype = {
let viewSourceUtils = this.owner.gViewSourceUtils;
viewSourceUtils.viewSource(aFileURI, null, this.document);
}.bind(this));
return outputNode;
},
/**
+ * Handle the file activity messages coming from the remote Web Console.
+ *
+ * @param string aFileURI
+ * The file URI that was requested.
+ */
+ handleFileActivity: function WCF_handleFileActivity(aFileURI)
+ {
+ this.outputMessage(CATEGORY_NETWORK, this.logFileActivity, [aFileURI]);
+ },
+
+ /**
* Inform user that the Web Console API has been replaced by a script
* in a content page.
*/
logWarningAboutReplacedAPI: function WCF_logWarningAboutReplacedAPI()
{
let node = this.createMessageNode(CATEGORY_JS, SEVERITY_WARNING,
l10n.getStr("ConsoleAPIDisabled"));
this.outputMessage(CATEGORY_JS, node);
},
/**
- * Handle the "WebConsole:NetworkActivity" message coming from the remote Web
+ * Handle the network activity messages coming from the remote Web
* Console.
*
- * @param object aMessage
- * The HTTP activity object. This object needs to hold two properties:
- * - meta - some metadata about the request log:
+ * @param object aLog
+ * The request and response information. This is a HAR-like
+ * object. See NetworkMonitor.createActivityObject().
+ * @param object aMeta
+ * Additional data about the request log:
* - stages - the stages the network request went through.
* - discardRequestBody and discardResponseBody - booleans that tell
* if the network request/response body was discarded or not.
- * - log - the request and response information. This is a HAR-like
- * object. See HUDService-content.js
- * NetworkMonitor.createActivityObject().
*/
- handleNetworkActivity: function WCF_handleNetworkActivity(aMessage)
+ handleNetworkActivity: function WCF_handleNetworkActivity(aLog, aMeta)
{
- let stage = aMessage.meta.stages[aMessage.meta.stages.length - 1];
- let entry = aMessage.log.entries[0];
+ let stage = aMeta.stages[aMeta.stages.length - 1];
+ let entry = aLog.entries[0];
if (stage == "REQUEST_HEADER") {
let networkInfo = {
node: null,
- httpActivity: aMessage,
+ httpActivity: {
+ log: aLog,
+ meta: aMeta,
+ },
};
this._networkRequests[entry.connection] = networkInfo;
this.outputMessage(CATEGORY_NETWORK, this.logNetActivity,
[entry.connection]);
return;
}
else if (!(entry.connection in this._networkRequests)) {
return;
}
let networkInfo = this._networkRequests[entry.connection];
- networkInfo.httpActivity = aMessage;
+ networkInfo.httpActivity.meta = aMeta;
+ networkInfo.httpActivity.log = aLog;
if (networkInfo.node) {
this._updateNetMessage(entry.connection);
}
// For unit tests we pass the HTTP activity object to the test callback,
// once requests complete.
if (this.owner.lastFinishedRequestCallback &&
- aMessage.meta.stages.indexOf("REQUEST_STOP") > -1 &&
- aMessage.meta.stages.indexOf("TRANSACTION_CLOSE") > -1) {
- this.owner.lastFinishedRequestCallback(aMessage);
+ aMeta.stages.indexOf("REQUEST_STOP") > -1 &&
+ aMeta.stages.indexOf("TRANSACTION_CLOSE") > -1) {
+ this.owner.lastFinishedRequestCallback(networkInfo.httpActivity);
}
},
/**
* Update an output message to reflect the latest state of a network request,
* given a network connection ID.
*
* @private
@@ -1552,31 +1520,45 @@ WebConsoleFrame.prototype = {
{
let netPanel = new NetworkPanel(this.popupset, aHttpActivity);
netPanel.linkNode = aNode;
aNode._netPanel = netPanel;
let panel = netPanel.panel;
panel.openPopup(aNode, "after_pointer", 0, 0, false, false);
panel.sizeTo(450, 500);
- panel.setAttribute("hudId", aHttpActivity.hudId);
+ panel.setAttribute("hudId", this.hudId);
panel.addEventListener("popuphiding", function WCF_netPanel_onHide() {
panel.removeEventListener("popuphiding", WCF_netPanel_onHide);
aNode._panelOpen = false;
aNode._netPanel = null;
});
aNode._panelOpen = true;
return netPanel;
},
/**
+ * Handler for page location changes.
+ *
+ * @param string aURI
+ * New page location.
+ * @param string aTitle
+ * New page title.
+ */
+ onLocationChange: function WCF_onLocationChange(aURI, aTitle)
+ {
+ this.contentLocation = aURI;
+ this.owner.onLocationChange(aURI, aTitle);
+ },
+
+ /**
* Output a message node. This filters a node appropriately, then sends it to
* the output, regrouping and pruning output as necessary.
*
* Note: this call is async - the given message node may not be displayed when
* you call this method.
*
* @param integer aCategory
* The category of the message you want to output. See the CATEGORY_*
@@ -3675,16 +3657,19 @@ CommandController.prototype = {
* The Web Console instance that owns this connection proxy.
*/
function WebConsoleConnectionProxy(aWebConsole)
{
this.owner = aWebConsole;
this._onPageError = this._onPageError.bind(this);
this._onConsoleAPICall = this._onConsoleAPICall.bind(this);
+ this._onNetworkActivity = this._onNetworkActivity.bind(this);
+ this._onFileActivity = this._onFileActivity.bind(this);
+ this._onLocationChange = this._onLocationChange.bind(this);
}
WebConsoleConnectionProxy.prototype = {
/**
* The owning Web Console instance.
*
* @see WebConsoleFrame
* @type object
@@ -3733,23 +3718,29 @@ WebConsoleConnectionProxy.prototype = {
*/
connect: function WCCP_connect(aCallback)
{
let transport = DebuggerServer.connectPipe();
let client = this.client = new DebuggerClient(transport);
client.addListener("pageError", this._onPageError);
client.addListener("consoleAPICall", this._onConsoleAPICall);
+ client.addListener("networkActivity", this._onNetworkActivity);
+ client.addListener("fileActivity", this._onFileActivity);
+ client.addListener("locationChange", this._onLocationChange);
let listeners = [WebConsoleClient.prototype.LISTENERS.PageError,
- WebConsoleClient.prototype.LISTENERS.ConsoleAPI];
+ WebConsoleClient.prototype.LISTENERS.ConsoleAPI,
+ WebConsoleClient.prototype.LISTENERS.NetworkActivity,
+ WebConsoleClient.prototype.LISTENERS.FileActivity];
client.connect(function(aType, aTraits) {
client.listTabs(function(aResponse) {
let tab = aResponse.tabs[aResponse.selected];
+ this.owner.onLocationChange(tab.url, tab.title);
client.attachConsole(tab.consoleActor, listeners,
this._onAttachConsole.bind(this, aCallback));
}.bind(this));
}.bind(this));
},
/**
* The "attachConsole" response handler.
@@ -3835,16 +3826,61 @@ WebConsoleConnectionProxy.prototype = {
* The message received from the server.
*/
_onConsoleAPICall: function WCCP__onConsoleAPICall(aType, aPacket)
{
this.owner.handleConsoleAPICall(aPacket.message);
},
/**
+ * The "networkActivity" message type handler. We redirect any message to
+ * the UI for displaying.
+ *
+ * @private
+ * @param string aType
+ * Message type.
+ * @param object aPacket
+ * The message received from the server.
+ */
+ _onNetworkActivity: function WCCP__onNetworkActivity(aType, aPacket)
+ {
+ this.owner.handleNetworkActivity(aPacket.log, aPacket.meta);
+ },
+
+ /**
+ * The "fileActivity" message type handler. We redirect any message to
+ * the UI for displaying.
+ *
+ * @private
+ * @param string aType
+ * Message type.
+ * @param object aPacket
+ * The message received from the server.
+ */
+ _onFileActivity: function WCCP__onFileActivity(aType, aPacket)
+ {
+ this.owner.handleFileActivity(aPacket.uri);
+ },
+
+ /**
+ * The "locationChange" message type handler. We redirect any message to
+ * the UI for displaying.
+ *
+ * @private
+ * @param string aType
+ * Message type.
+ * @param object aPacket
+ * The message received from the server.
+ */
+ _onLocationChange: function WCCP__onLocationChange(aType, aPacket)
+ {
+ this.owner.onLocationChange(aPacket.uri, aPacket.title);
+ },
+
+ /**
* Release an object actor.
*
* @param string aActor
* The actor ID to send the request to.
*/
releaseActor: function WCCP_releaseActor(aActor)
{
if (this.client) {
@@ -3858,16 +3894,19 @@ WebConsoleConnectionProxy.prototype = {
disconnect: function WCCP_disconnect()
{
if (!this.client) {
return;
}
this.client.removeListener("pageError", this._onPageError);
this.client.removeListener("consoleAPICall", this._onConsoleAPICall);
+ this.client.removeListener("networkActivity", this._onNetworkActivity);
+ this.client.removeListener("fileActivity", this._onFileActivity);
+ this.client.removeListener("locationChange", this._onLocationChange);
this.client.close();
this.client = null;
this.webConsoleClient = null;
this.connected = false;
},
};
diff --git a/toolkit/devtools/debugger/dbg-client.jsm b/toolkit/devtools/debugger/dbg-client.jsm
--- a/toolkit/devtools/debugger/dbg-client.jsm
+++ b/toolkit/devtools/debugger/dbg-client.jsm
@@ -161,16 +161,19 @@ const ThreadStateTypes = {
};
/**
* Set of protocol messages that are sent by the server without a prior request
* by the client.
*/
const UnsolicitedNotifications = {
"consoleAPICall": "consoleAPICall",
+ "fileActivity": "fileActivity",
+ "locationChange": "locationChange",
+ "networkActivity": "networkActivity",
"newScript": "newScript",
"pageError": "pageError",
"tabDetached": "tabDetached",
"tabNavigated": "tabNavigated"
};
/**
* Set of pause types that are sent by the server and not as an immediate
@@ -552,16 +555,18 @@ function WebConsoleClient(aDebuggerClien
this._actor = aActor;
this._client = aDebuggerClient;
}
WebConsoleClient.prototype = {
LISTENERS: {
PageError: "PageError",
ConsoleAPI: "ConsoleAPI",
+ NetworkActivity: "NetworkActivity",
+ FileActivity: "FileActivity",
},
CACHED_MESSAGES: {
PageError: "PageError",
ConsoleAPI: "ConsoleAPI",
},
/**
@@ -652,16 +657,50 @@ WebConsoleClient.prototype = {
let packet = {
to: this._actor,
type: "clearMessagesCache",
};
this._client.request(packet);
},
/**
+ * Set Web Console-related preferences on the server.
+ *
+ * @param object aPreferences
+ * An object with the preferences you want to change.
+ * @param function [aOnResponse]
+ * Optional function to invoke when the response is received.
+ */
+ setPreferences: function WCC_setPreferences(aPreferences, aOnResponse) {
+ let packet = {
+ to: this._actor,
+ type: "setPreferences",
+ preferences: aPreferences,
+ };
+ this._client.request(packet, aOnResponse);
+ },
+
+ /**
+ * Get Web Console-related preferences from the server.
+ *
+ * @param array aPreferences
+ * An array with the preferences you want to retrieve.
+ * @param function aOnResponse
+ * Function to invoke when the response is received.
+ */
+ getPreferences: function WCC_getPreferences(aPreferences, aOnResponse) {
+ let packet = {
+ to: this._actor,
+ type: "getPreferences",
+ preferences: aPreferences,
+ };
+ this._client.request(packet, aOnResponse);
+ },
+
+ /**
* Start the given Web Console listeners.
*
* @see this.LISTENERS
* @param array aListeners
* Array of listeners you want to start. See this.LISTENERS for
* known listeners.
* @param function aOnResponse
* Function to invoke when the server response is received.
diff --git a/toolkit/devtools/debugger/server/dbg-webconsole-actors.js b/toolkit/devtools/debugger/server/dbg-webconsole-actors.js
--- a/toolkit/devtools/debugger/server/dbg-webconsole-actors.js
+++ b/toolkit/devtools/debugger/server/dbg-webconsole-actors.js
@@ -19,28 +19,36 @@ XPCOMUtils.defineLazyModuleGetter(this,