From cd72bf1789cde7d6cb894b7c890caba2ec5985de Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Thu, 5 Sep 2024 15:29:08 +0100 Subject: [PATCH] Support OOPIF PDF viewer in Chrome Fix detection of document type in Chrome's built-in PDF viewer when the "OOPIF for PDF Viewer" feature ("pdf-oopif") is enabled. Fixes https://github.com/hypothesis/support/issues/145 --- src/background/detect-content-type.ts | 24 +++++++++++++++++++ tests/background/detect-content-type-test.js | 25 ++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/background/detect-content-type.ts b/src/background/detect-content-type.ts index 56975b27..edca0329 100644 --- a/src/background/detect-content-type.ts +++ b/src/background/detect-content-type.ts @@ -34,6 +34,30 @@ export function detectContentType( if (document_.querySelector('embed[type="application/pdf"]')) { return { type: 'PDF' }; } + + // Detect Chrome's PDF viewer when it is using out-of-process iframes + // ("OOPIF") instead of ``. + // + // In this case the DOM has a structure like: + // + // ``` + // + // # closed shadow root + // -