1. 28 Sep, 2023 9 commits
  2. 27 Sep, 2023 4 commits
  3. 25 Sep, 2023 11 commits
  4. 19 Sep, 2023 3 commits
    • Robert Knight's avatar
      Support error responses to requests for a message channel · b1c25bca
      Robert Knight authored
      Allow the host frame to explicitly reject a request for a message channel by
      setting the `Message.error` property. Previously other frames could only wait
      for requests to time out. This allows the sidebar to display an error much
      sooner if it gets reloaded and cannot reconnect to the host frame.
      
      Part of https://github.com/hypothesis/client/issues/4095
      b1c25bca
    • Robert Knight's avatar
      Remove strict checks on source/target frame roles · d58567d0
      Robert Knight authored
      These checks had not been updated for the addition of the "profile" application.
      Also at a conceptual level the responsibility for deciding which types of frames
      are allowed to connect to each other belongs to the `PortProvider` in the host
      frame, not the `PortFinder` in other frames.
      d58567d0
    • Robert Knight's avatar
      Handle sidebar iframe reloads more gracefully · fcf87072
      Robert Knight authored
      If the `<hypothesis-sidebar>` element is moved around in the DOM, this can cause
      the sidebar to reload. There may also be other causes of the sidebar reloading
      (eg. process crash for out-of-process iframe?). If the sidebar loads a second
      time, it will fail to connect to the host frame since `PortProvider` will try to
      re-use the `MessageChannel` it has already allocated, but sending that channels
      ports will fail since they have already been transferred.
      
      Recovering from this scenario fully involves a lot of changes since all the
      places that have a connection to the sidebar would need to support replacing
      that channel. Also various state in host/guest frames (eg. currently loaded
      annotations) will be out of sync and need resetting.
      
      What this commit does is just to handle the situation more gracefully, by
      logging a meaningful error in the console and, after a delay, showing an error
      message in the sidebar telling the user to reload the page. This also avoids
      spamming Sentry [1] with errors about a situation that is out of our control. We
      get a lot of error reports about this each month, mainly from certain
      high-traffic pages that embed the client, but so far no actual complaints from
      users about Hypothesis not working. Therefore it doesn't yet seem valuable
      enough to do all the work to recover from a sidebar frame reload automatically.
      
      [1] https://hypothesis.sentry.io/issues/2975780063/
      fcf87072
  5. 18 Sep, 2023 10 commits
  6. 15 Sep, 2023 3 commits
    • Robert Knight's avatar
      Cleanup and abort if annotator finds existing `<hypothesis-sidebar>` · a7239d05
      Robert Knight authored
      Fix an issue where multiple Hypothesis sidebar (and possibly notebook, profile
      etc.) iframes could get created when saving a local snapshot of a web page where
      Hypothesis was loaded. This would lead to one of the sidebars not functioning
      because the host frame only allows one sidebar to connect.
      
      Aside from there being multiple sidebars, there are other problems in such an
      environment, such as the URL not matching the original page URL.  Hence this
      commit handles this scenario by detecting it when the annotator bundle loads,
      removing the existing `<hypothesis-sidebar>` element and then aborting startup.
      
      The end result for the user is that if they save a snapshot of a page with
      Hypothesis loaded and later reload it, the visible highlights will still appear
      in the page but other Hypothesis UI elements will not be visible.
      
      The scenario described here applies in Chrome when saving a snapshot with the
      "Web Page, Complete" file type. If the user instead selects "Web Page, HTML
      only" or "Web Page, single file" they will get different results, but those
      were already not problematic because no JS was executed.
      
      Fixes https://github.com/hypothesis/client/issues/5827
      a7239d05
    • Robert Knight's avatar
      Ignore coverage for edge-case early exit · 5c3cdd5f
      Robert Knight authored
      This is only relevant in the edge case that `document.documentElement` is null.
      5c3cdd5f
    • Robert Knight's avatar
      Handle `document.documentElement` being null when installing shortcut · b3e062dc
      Robert Knight authored
      `documentElement` is never null in "normal" circumstances, but it can be `null`
      if something explicitly removes the root element from the document, and this
      situation has apparently occurred in the wild on some ChromeOS devices [1].
      
      [1] https://hypothesis.sentry.io/issues/3987992034
      b3e062dc