hypothesis / client

The Hypothesis web-based annotation client.
Other
642 stars 197 forks source link

Ignore "fake" window unload events in PortRPC #6652

Closed robertknight closed 2 weeks ago

robertknight commented 2 weeks ago

In VitalSource custom/synthetic "unload" events are dispatched at the book's container frame when switching chapters. Make sure these don't trigger the code in the PortRPC class that is meant to be called when the window is unloaded.

These synthetic events were triggered after every chapter navigation. In Safari <= 15 the second and subsequent events would cause an error in the currentWindow.parent.postMessage call because the port had already been transferred after the first event was handled.

For context, see https://github.com/hypothesis/support/issues/161#issuecomment-2454560641.

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.42%. Comparing base (2522dc1) to head (8b2fd90). Report is 9 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6652 +/- ## ======================================= Coverage 99.42% 99.42% ======================================= Files 270 270 Lines 10172 10174 +2 Branches 2418 2419 +1 ======================================= + Hits 10114 10116 +2 Misses 58 58 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.