• 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
..
anchoring Loading commit data...
components Loading commit data...
config Loading commit data...
integrations Loading commit data...
test Loading commit data...
util Loading commit data...
.eslintrc.js Loading commit data...
adder.js Loading commit data...
annotation-counts.js Loading commit data...
annotation-sync.js Loading commit data...
bucket-bar.js Loading commit data...
cross-frame.js Loading commit data...
features.js Loading commit data...
frame-observer.js Loading commit data...
guest.js Loading commit data...
highlighter.js Loading commit data...
hypothesis-injector.js Loading commit data...
icons.js Loading commit data...
index.js Loading commit data...
notebook.js Loading commit data...
range-util.js Loading commit data...
selection-observer.js Loading commit data...
sidebar-trigger.js Loading commit data...
sidebar.js Loading commit data...
toolbar.js Loading commit data...