Skip to content
This repository was archived by the owner on Aug 13, 2018. It is now read-only.

Commit 0dace67

Browse files
jsnajdresphen
authored andcommitted
Adapt to new Netmonitor panel architecture (#67)
Relates to bug 1316834 https://bugzilla.mozilla.org/show_bug.cgi?id=1316834
1 parent 140c956 commit 0dace67

File tree

2 files changed

+47
-38
lines changed

2 files changed

+47
-38
lines changed

chrome/content/network-content-script.js

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,55 @@
1717
* The icons serves also as a link to the 'Web Socket'
1818
* panel.
1919
*/
20-
window.on(EVENTS.RECEIVED_REQUEST_HEADERS, (_, from) => {
21-
let item = NetMonitorView.RequestsMenu.getItemByValue(from);
22-
if (!isWsUpgradeRequest(item)) {
23-
return;
24-
}
20+
if (EVENTS.REQUEST_ITEM_CLICKED) {
21+
window.on(EVENTS.REQUEST_ITEM_CLICKED, (_, e, item) => {
22+
if (e.target.closest(".request-list-item.websocket .requests-menu-method")) {
23+
navigateToWebSocketPanel(item.id);
24+
}
25+
});
26+
} else {
27+
window.on(EVENTS.RECEIVED_REQUEST_HEADERS, (_, from) => {
28+
let item = NetMonitorView.RequestsMenu.getItemByValue(from);
29+
if (!isWsUpgradeRequest(item)) {
30+
return;
31+
}
2532

26-
// Append WebSocket icon in the UI
27-
let hbox = item._target;
33+
// Append WebSocket icon in the UI
34+
let hbox = item._target;
2835

29-
let method = hbox.querySelector(".requests-menu-method");
30-
method.classList.add("websocket");
36+
let method = hbox.querySelector(".requests-menu-method");
37+
method.classList.add("websocket");
3138

32-
// Fx 45 changed the DOM layout in the network panel and also
33-
// the WS icon isn't overlapping the original status icon now.
34-
// But, we need a little indentation for pre Fx45.
35-
let statusIconNode = hbox.querySelector(".requests-menu-status-icon");
36-
if (!statusIconNode) {
37-
// We are in pre Fx45 world, use a little indentation.
38-
method.classList.add("websocket-indent");
39-
}
40-
41-
// Register click handler and emit an event that is handled
42-
// in the 'WsmNetMonitorOverlay' overlay.
43-
// xxxHonza: this registers multiple listeners on the window
44-
// object that are all executed when the user clicks on the
45-
// WS icon. FIXME
46-
window.addEventListener("click", event => {
47-
if (event.target.classList.contains("websocket")) {
48-
navigateToWebSocketPanel(from);
39+
// Fx 45 changed the DOM layout in the network panel and also
40+
// the WS icon isn't overlapping the original status icon now.
41+
// But, we need a little indentation for pre Fx45.
42+
let statusIconNode = hbox.querySelector(".requests-menu-status-icon");
43+
if (!statusIconNode) {
44+
// We are in pre Fx45 world, use a little indentation.
45+
method.classList.add("websocket-indent");
4946
}
50-
});
5147

52-
// Do not open the Network panel side-bar if the user clicks
53-
// on the WS icon.
54-
window.addEventListener("mousedown", event => {
55-
if (event.target.classList.contains("websocket")) {
56-
event.stopPropagation();
57-
event.preventDefault();
58-
}
59-
}, true);
60-
});
48+
// Register click handler and emit an event that is handled
49+
// in the 'WsmNetMonitorOverlay' overlay.
50+
// xxxHonza: this registers multiple listeners on the window
51+
// object that are all executed when the user clicks on the
52+
// WS icon. FIXME
53+
window.addEventListener("click", event => {
54+
if (event.target.classList.contains("websocket")) {
55+
navigateToWebSocketPanel(from);
56+
}
57+
});
58+
59+
// Do not open the Network panel side-bar if the user clicks
60+
// on the WS icon.
61+
window.addEventListener("mousedown", event => {
62+
if (event.target.classList.contains("websocket")) {
63+
event.stopPropagation();
64+
event.preventDefault();
65+
}
66+
}, true);
67+
});
68+
}
6169

6270
/**
6371
* Handle Response body displayed event.

chrome/skin/classic/netmonitor.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
/* Network Panel */
55

66
/* Web Socket Icon */
7-
.requests-menu-method.websocket {
7+
.requests-menu-method.websocket,
8+
.request-list-item.websocket .requests-menu-method {
89
background-image: url("./tool-websockets.svg");
910
background-repeat: no-repeat;
10-
background-position: 0 1px;
11+
background-position: left center;
1112
}
1213

1314
/* Make sure the icon works in all themes */

0 commit comments

Comments
 (0)