(action)
| 209 | } |
| 210 | |
| 211 | waitForPersonaCard(action) { |
| 212 | return new Promise((resolve, reject) => { |
| 213 | // create observer to wait for persona popup |
| 214 | const observer = new MutationObserver(mutations => { |
| 215 | mutations.forEach(mutation => { |
| 216 | if (!mutation.addedNodes.length) { |
| 217 | return; |
| 218 | } |
| 219 | const addedNode = mutation.addedNodes.item(0); |
| 220 | observer.disconnect(); |
| 221 | // wait in interval for popup content to render |
| 222 | const searchInterval = setInterval(() => { |
| 223 | const personaCard = addedNode.querySelector('[data-log-name="Email"] button'); |
| 224 | if (personaCard && extractAddressFromText(personaCard.textContent)) { |
| 225 | clearInterval(searchInterval); |
| 226 | // still more time required to complete render |
| 227 | setTimeout(() => resolve({personaCard, addedNode}), 200); |
| 228 | } |
| 229 | }, 100); |
| 230 | setTimeout(() => clearInterval(searchInterval), 1500); |
| 231 | }); |
| 232 | }); |
| 233 | observer.observe(document.body, {childList: true}); |
| 234 | setTimeout(() => reject(observer.disconnect()), 1000); |
| 235 | action && action(); |
| 236 | }); |
| 237 | } |
| 238 | |
| 239 | extractPersona(pane) { |
| 240 | if (!pane) { |
no test coverage detected