(port: Port)
| 185 | } |
| 186 | |
| 187 | function on_disconnected(port: Port) { |
| 188 | |
| 189 | place_log(Place_Name.Background, 'Port disconnected', port) |
| 190 | |
| 191 | switch (port.name) { |
| 192 | case Connection_Name.Popup: { |
| 193 | popup = undefined |
| 194 | break |
| 195 | } |
| 196 | case Connection_Name.Content: { |
| 197 | let tab_id = get_assert_tab_id(port, Place_Name.Content) |
| 198 | |
| 199 | let content = script_content_map.get(tab_id)! |
| 200 | if (content.port !== port) { |
| 201 | // Sometimes new Content Script can load before the old disconnects |
| 202 | return |
| 203 | } |
| 204 | |
| 205 | script_content_map.delete(tab_id) |
| 206 | |
| 207 | if (popup) { |
| 208 | port_post_message(popup.port, 'Detected', null) |
| 209 | port_post_message(popup.port, 'Versions', null) |
| 210 | } |
| 211 | |
| 212 | let panel = script_panel_map.get(tab_id) |
| 213 | if (panel) { |
| 214 | port_post_message(panel.port, 'Versions', null) |
| 215 | port_post_message(panel.port, 'ResetPanel', undefined) |
| 216 | } |
| 217 | |
| 218 | let devtools = script_devtools_map.get(tab_id) |
| 219 | if (devtools) { |
| 220 | port_post_message(devtools.port, 'Versions', null) |
| 221 | } |
| 222 | |
| 223 | toggle_action_icon(tab_id) |
| 224 | |
| 225 | if (tab_id === active_tab_id) { |
| 226 | send_connection_status_to_popup(Place_Name.Content, false) |
| 227 | } |
| 228 | |
| 229 | break |
| 230 | } |
| 231 | case Connection_Name.Devtools: { |
| 232 | script_devtools_map.delete(active_tab_id) |
| 233 | |
| 234 | let content = script_content_map.get(active_tab_id) |
| 235 | if (content) { |
| 236 | port_post_message(content.port, 'DevtoolsOpened', false) |
| 237 | } |
| 238 | |
| 239 | send_connection_status_to_popup(Place_Name.Devtools, false) |
| 240 | |
| 241 | break |
| 242 | } |
| 243 | case Connection_Name.Panel: { |
| 244 | script_panel_map.delete(active_tab_id) |
no test coverage detected
searching dependent graphs…