Add three unit tests to check `_removeFrame` callback
`_removeFrame` must be called in these three scenarios: - `enable-annotation` attribute is removed from iframe - `src` attribute is modified in the iframe - iframe is deleted When the iframe is deleted there are two possible paths for the execution of the `_removeFrame`: 1. First and faster execution of `_removeFrame`: `iframe.remove()` triggers the `unload` event which calls the `_removeFrame` 2. Second and delayed execution of `_removeFrame`: `iframe.remove()` triggers the `MutationObserver` (debounced by 40 ms). This could cause the `_removeFrame` to be fired if the first path would not remove the iframe from the list of `_handledFrames`. I moved the addition and deletion of the iframes to `_handledFrames` as earlier as possible in the `_addFrame` and `_removeFrame` methods to avoid racing conditions. A consequence of this is that the `_addFrame` is executed only once per iframe. If it fails (for example, because the iframe is from a different origin) it is not constantly retried.
Showing
Please register or sign in to comment