A page can read our script's textContent in a same-origin iframe via DOMNodeRemoved event. * Directly preventing it would require redefining ~20 DOM methods in the parent. * Instead, we'll send the ids via a temporary handshakeId event, to which the web-bridge * will listen only during its
()
| 107 | * will listen only during its initial phase using vault-protected DOM methods. |
| 108 | * TODO: simplify this when strict_min_version >= 63 (attachShadow in FF) */ |
| 109 | function startHandshake() { |
| 110 | /* With `once` the listener is removed before DOMNodeInserted is dispatched by appendChild, |
| 111 | * otherwise a same-origin parent page could use it to spoof the handshake. */ |
| 112 | window::on(handshakeId, handshaker, { capture: true, once: true }); |
| 113 | inject({ |
| 114 | code: `(${VMInitInjection}(${IS_FIREFOX},'${handshakeId}','${vaultId}'))()` |
| 115 | + `\n//# sourceURL=${VM_UUID}sandbox/injected-web.js`, |
| 116 | }); |
| 117 | // Clean up in case CSP prevented the script from running |
| 118 | window::off(handshakeId, handshaker, true); |
| 119 | } |
| 120 | function handshaker(evt) { |
| 121 | pageInjectable = true; |
| 122 | evt::stopImmediatePropagation(); |
no test coverage detected