()
| 149 | // This function should have reasonable performance since it sends |
| 150 | // messages only to popups and not regular windows. |
| 151 | async function getExtensionPageTabMV3(): Promise<chrome.tabs.Tab | null> { |
| 152 | return new Promise((resolve) => { |
| 153 | chrome.windows.getAll({ |
| 154 | populate: true, |
| 155 | windowTypes: ['popup'], |
| 156 | }, (w) => { |
| 157 | const responses: Array<Promise<string>> = []; |
| 158 | let found = false; |
| 159 | for (const window of w) { |
| 160 | const response = chrome.tabs.sendMessage<string, 'getExtensionPageTabMV3_pong'>(window.tabs![0]!.id!, 'getExtensionPageTabMV3_ping', {frameId: 0}); |
| 161 | response.then((response) => { |
| 162 | if (response === 'getExtensionPageTabMV3_pong') { |
| 163 | found = true; |
| 164 | resolve(window.tabs![0]); |
| 165 | } |
| 166 | }); |
| 167 | responses.push(response); |
| 168 | } |
| 169 | Promise.all(responses).then(() => !found && resolve(null)); |
| 170 | }); |
| 171 | }); |
| 172 | } |
| 173 | |
| 174 | async function getExtensionPageTab(url: string): Promise<chrome.tabs.Tab | null> { |
| 175 | if (__CHROMIUM_MV3__) { |
no test coverage detected