|
17 | 17 | * The icons serves also as a link to the 'Web Socket' |
18 | 18 | * panel. |
19 | 19 | */ |
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 | + } |
25 | 32 |
|
26 | | - // Append WebSocket icon in the UI |
27 | | - let hbox = item._target; |
| 33 | + // Append WebSocket icon in the UI |
| 34 | + let hbox = item._target; |
28 | 35 |
|
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"); |
31 | 38 |
|
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"); |
49 | 46 | } |
50 | | - }); |
51 | 47 |
|
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 | +} |
61 | 69 |
|
62 | 70 | /** |
63 | 71 | * Handle Response body displayed event. |
|
0 commit comments