Commit 5aef34c
authored
fix: prevent iframe leak in untainted prototype and avoid unnecessary iframe creation (#159)
## Summary
- Adopts upstream rrweb
[#1770](rrweb-io/rrweb#1770) and
[#1802](rrweb-io/rrweb#1802)
- **#1770**: Wraps untainted prototype iframe creation in `try/finally`
so the iframe is always removed, even on early return (when
`contentWindow` is null) or exception. Previously these iframes would
leak into the DOM.
- **#1802**: Moves `querySelector`/`querySelectorAll` from
`testableAccessors` to `testableMethods` and switches helpers from
`getUntaintedAccessor` to `getUntaintedMethod`. These are methods, not
property accessors, so the accessor check
(`getOwnPropertyDescriptor(...).get`) always failed, causing a throwaway
iframe to be created every time just to get the untainted prototype.
## Why
Both fixes are in `packages/utils/src/index.ts` and affect the same
`getUntaintedPrototype` code path. #1770 prevents DOM pollution from
leaked iframes. #1802 avoids unnecessary iframe creation on every
querySelector/querySelectorAll call, which is a hot path during
recording.
## Test plan
- [ ] Verify no regressions in recording on pages with patched DOM
prototypes (Angular apps)
- [ ] Inspect DOM during recording to confirm no orphaned iframes from
untainted prototype detection1 parent 1939c91 commit 5aef34c
1 file changed
+9
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | | - | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | 114 | | |
117 | 115 | | |
118 | 116 | | |
119 | 117 | | |
120 | 118 | | |
121 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
228 | | - | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
235 | | - | |
| 237 | + | |
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
| |||
0 commit comments