diff --git a/src/annotator/index.js b/src/annotator/index.js index 5417902109c..23e932a3e66 100644 --- a/src/annotator/index.js +++ b/src/annotator/index.js @@ -69,7 +69,7 @@ function init() { // Expose sidebar window reference for use by same-origin guest frames. window_.__hypothesis.sidebarWindow = sidebar.ready.then( - () => sidebar.iframe.contentWindow + () => [sidebar.iframe.contentWindow] ); } @@ -93,7 +93,7 @@ function init() { if (sidebarWindow) { const sidebarOrigin = new URL(sidebarLinkElement.href).origin; - sidebarWindow.then(frame => + sidebarWindow.then(([frame]) => guest.crossframe.connectToSidebar(frame, sidebarOrigin) ); } else { diff --git a/src/types/annotator.js b/src/types/annotator.js index cbb9374647d..f9383acd1dd 100644 --- a/src/types/annotator.js +++ b/src/types/annotator.js @@ -143,9 +143,14 @@ * @prop {import('./pdfjs').PDFViewerApplication} [PDFViewerApplication] - * PDF.js entry point. If set, triggers loading of PDF rather than HTML integration. * @prop {object} [__hypothesis] - Internal data related to supporting guests in iframes - * @prop {Promise} [__hypothesis.sidebarWindow] - + * @prop {Promise<[Window]>} [__hypothesis.sidebarWindow] - * The sidebar window that is active in this frame. This resolves once the sidebar * application has started and is ready to connect to guests. + * + * The `Window` object is wrapped in an array to avoid issues with + * combining promises with cross-origin objects in old browsers + * (eg. Safari 11, Chrome <= 63) which trigger an exception when trying to + * test if the object has a `then` method. See https://github.com/whatwg/dom/issues/536. */ /**