|
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 | + let target = ".request-list-item.websocket .requests-menu-method"; |
| 23 | + if (e.target.closest(target)) { |
| 24 | + navigateToWebSocketPanel(item.id); |
| 25 | + } |
| 26 | + }); |
| 27 | +} else { |
| 28 | + window.on(EVENTS.RECEIVED_REQUEST_HEADERS, (_, from) => { |
| 29 | + let item = NetMonitorView.RequestsMenu.getItemByValue(from); |
| 30 | + if (!isWsUpgradeRequest(item)) { |
| 31 | + return; |
| 32 | + } |
25 | 33 |
|
26 |
| - // Append WebSocket icon in the UI |
27 |
| - let hbox = item._target; |
| 34 | + // Append WebSocket icon in the UI |
| 35 | + let hbox = item._target; |
28 | 36 |
|
29 |
| - let method = hbox.querySelector(".requests-menu-method"); |
30 |
| - method.classList.add("websocket"); |
| 37 | + let method = hbox.querySelector(".requests-menu-method"); |
| 38 | + method.classList.add("websocket"); |
31 | 39 |
|
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); |
| 40 | + // Fx 45 changed the DOM layout in the network panel and also |
| 41 | + // the WS icon isn't overlapping the original status icon now. |
| 42 | + // But, we need a little indentation for pre Fx45. |
| 43 | + let statusIconNode = hbox.querySelector(".requests-menu-status-icon"); |
| 44 | + if (!statusIconNode) { |
| 45 | + // We are in pre Fx45 world, use a little indentation. |
| 46 | + method.classList.add("websocket-indent"); |
49 | 47 | }
|
50 |
| - }); |
51 | 48 |
|
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 |
| -}); |
| 49 | + // Register click handler and emit an event that is handled |
| 50 | + // in the 'WsmNetMonitorOverlay' overlay. |
| 51 | + // xxxHonza: this registers multiple listeners on the window |
| 52 | + // object that are all executed when the user clicks on the |
| 53 | + // WS icon. FIXME |
| 54 | + window.addEventListener("click", event => { |
| 55 | + if (event.target.classList.contains("websocket")) { |
| 56 | + navigateToWebSocketPanel(from); |
| 57 | + } |
| 58 | + }); |
| 59 | + |
| 60 | + // Do not open the Network panel side-bar if the user clicks |
| 61 | + // on the WS icon. |
| 62 | + window.addEventListener("mousedown", event => { |
| 63 | + if (event.target.classList.contains("websocket")) { |
| 64 | + event.stopPropagation(); |
| 65 | + event.preventDefault(); |
| 66 | + } |
| 67 | + }, true); |
| 68 | + }); |
| 69 | +} |
61 | 70 |
|
62 | 71 | /**
|
63 | 72 | * Handle Response body displayed event.
|
|
0 commit comments