* Instrument added nodes if they are instrumentable iframes. * @param {!Window} win * @param {!Array<!Node>|NodeList<!Node>|NodeList<!Element>|null} addedNodes
(win, addedNodes)
| 96 | * @param {!Array<!Node>|NodeList<!Node>|NodeList<!Element>|null} addedNodes |
| 97 | */ |
| 98 | function maybeInstrumentsNodes(win, addedNodes) { |
| 99 | for (let n = 0; n < addedNodes.length; n++) { |
| 100 | const node = addedNodes[n]; |
| 101 | try { |
| 102 | if (node.tagName != 'IFRAME') { |
| 103 | continue; |
| 104 | } |
| 105 | const src = node.getAttribute('src'); |
| 106 | const srcdoc = node.getAttribute('srcdoc'); |
| 107 | if (src == null || /^(about:|javascript:)/i.test(src.trim()) || srcdoc) { |
| 108 | if (node.contentWindow) { |
| 109 | instrumentIframeWindow(node, win, node.contentWindow); |
| 110 | node.addEventListener('load', () => { |
| 111 | try { |
| 112 | instrumentIframeWindow(node, win, node.contentWindow); |
| 113 | } catch (e) { |
| 114 | console./*OK*/ error(e.message, e.stack); |
| 115 | } |
| 116 | }); |
| 117 | } else if (srcdoc) { |
| 118 | instrumentSrcdoc(parent, node); |
| 119 | } |
| 120 | } |
| 121 | } catch (e) { |
| 122 | console./*OK*/ error(e.message, e.stack); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Installs a mutation observer in a window to look for iframes. |
no test coverage detected