• Eduardo Sanz García's avatar
    Add three unit tests to check `_removeFrame` callback · be1c6910
    Eduardo Sanz García authored
    `_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.
    be1c6910
Name
Last commit
Last update
..
annotator Loading commit data...
boot Loading commit data...
images/icons Loading commit data...
shared Loading commit data...
sidebar Loading commit data...
styles Loading commit data...
test-util Loading commit data...
types Loading commit data...
.eslintrc Loading commit data...
karma.config.js Loading commit data...
tsconfig.json Loading commit data...