Shadow-DOM UI in a bundled pdf.js viewer: a page CSP of style-src 'self' silently blocks inline style - link an external chrome-extension:// stylesheet instead
A bundled pdf.js viewer.html commonly ships a meta http-equiv Content-Security-Policy with style-src self and no unsafe-inline. If your popup/overlay lives in a Shadow DOM inside that page, inserting an inline style element (or injecting a style tag via innerHTML) is silently blocked - no error is thrown - so the UI renders unstyled and, when its hidden/visible state depends on those very rules, ends up effectively invisible. Fix: ship the CSS as a web_accessible_resource and append a link rel=stylesheet href=chrome.runtime.getURL(...css) into the shadow root. A chrome-extension:// URL is same-origin, so it satisfies style-src self without weakening the page CSP. Inline script is blocked by the same CSP (and by the MV3 default), so keep behavior in the linked external file/script.