diff --git a/manifest.json b/manifest.json index e50625a..ca9c59e 100644 --- a/manifest.json +++ b/manifest.json @@ -19,12 +19,14 @@ "content_scripts": [ { "matches": [ - "https://www.sec.gov/*" + "http://*/*", + "https://*/*" ], "js": [ + "src/content/plain-html-detection.js", "src/content/sec-comment.js" ], - "run_at": "document_start" + "run_at": "document_idle" }, { "matches": [ diff --git a/package.json b/package.json index a6de071..65a7522 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "check": "node scripts/check-extension.mjs", "test": "node scripts/test-suites.mjs all", "test:feature": "node scripts/test-suites.mjs", + "test:document": "node scripts/test-suites.mjs document", + "test:appearance": "node scripts/test-suites.mjs appearance", "test:selection": "node scripts/test-suites.mjs selection", "test:enhance": "node --test tests/enhance-failure.test.mjs tests/enhance-pdf.test.mjs tests/enhancer-setup.test.mjs", "test:footnotes": "node scripts/test-suites.mjs footnotes", diff --git a/scripts/check-extension.mjs b/scripts/check-extension.mjs index a80e66b..4171e99 100644 --- a/scripts/check-extension.mjs +++ b/scripts/check-extension.mjs @@ -68,8 +68,19 @@ async function validateManifest(path, expected) { } } for (const script of manifest.content_scripts || []) { - if (!script.matches?.every((pattern) => pattern.startsWith("https://"))) { - fail(path + ": content scripts must be HTTPS scoped"); + // Only the conservative HTML darkening integration may run on HTTP. + const plainHtmlScripts = [ + "content/plain-html-detection.js", + "content/sec-comment.js", + ]; + const scripts = (script.js || []).map((asset) => asset.replace(/^src\//, "")); + const isPlainHtmlIntegration = + JSON.stringify(scripts) === JSON.stringify(plainHtmlScripts) && + JSON.stringify(script.matches) === JSON.stringify(["http://*/*", "https://*/*"]) && + !script.css?.length; + if (!isPlainHtmlIntegration && + !script.matches?.every((pattern) => pattern.startsWith("https://"))) { + fail(path + ": only basic HTML darkening may use HTTP content-script matches"); } } diff --git a/scripts/test-suites.mjs b/scripts/test-suites.mjs index 6c4f27d..34eb2d9 100644 --- a/scripts/test-suites.mjs +++ b/scripts/test-suites.mjs @@ -80,11 +80,13 @@ export const suites = Object.freeze({ "document-title.test.mjs", "local-file-favicon.test.mjs", "metadata-date.test.mjs", - "metadata-doi.test.mjs" + "metadata-doi.test.mjs", + "raw-metadata.test.mjs" ], "appearance": [ "accent-color.test.mjs", "narrow-viewer-layout.test.mjs", + "plain-html-dark-mode.test.mjs", "scanned-page-images.test.mjs" ], "chatgpt": [ diff --git a/src/content/plain-html-detection.js b/src/content/plain-html-detection.js new file mode 100644 index 0000000..924f2a9 --- /dev/null +++ b/src/content/plain-html-detection.js @@ -0,0 +1,38 @@ +// Dark mode is limited to simple HTML documents; do not overwrite site design. +(() => { + function isPlainHtmlDocument(doc) { + if (!doc?.body || !doc.documentElement) return false; + if (doc.contentType?.toLowerCase() !== "text/html") return false; + if (!doc.body.textContent?.trim()) return false; + if (doc.querySelector( + 'link[rel~="stylesheet"], style, script, nav, header, footer, aside, form, ' + + 'iframe, canvas, video, audio, svg, button, input, select, textarea, ' + + '[role="application"], [contenteditable], #app, #root, [data-reactroot]' + )) return false; + if (doc.querySelectorAll('div, section, article').length > 12) return false; + if (doc.querySelectorAll('[style]').length > 16) return false; + if (doc.querySelectorAll('[class], [id]').length > 25) return false; + return true; + } + // EDGAR exhibits often use legacy inline CSS and markup even though + // they are ordinary documents, not application-like websites. + function isRawEdgarHtmlDocument(doc, href) { + if (!doc?.body || !doc.documentElement) return false; + if (doc.contentType?.toLowerCase() !== "text/html") return false; + if (!doc.body.textContent?.trim()) return false; + + let url; + try { + url = new URL(href); + } catch { + return false; + } + + return url.protocol === "https:" && + /^(?:www\.)?sec\.gov$/i.test(url.hostname) && + /^\/Archives\/edgar\/data\/\d+\/[^/]+\/[^/]+\.html?$/i.test(url.pathname); + } + + globalThis.pdfMagicIsRawEdgarHtmlDocument = isRawEdgarHtmlDocument; + globalThis.pdfMagicIsPlainHtmlDocument = isPlainHtmlDocument; +})(); diff --git a/src/content/sec-comment.js b/src/content/sec-comment.js index 38299f7..9d5cc25 100644 --- a/src/content/sec-comment.js +++ b/src/content/sec-comment.js @@ -11,7 +11,10 @@ ? "src/" : ""; const SWEETIE_BOT_PATH = sourcePrefix + "assets/sweetiebot.png"; - const isCommentPage = /^\/comments\/.+\.html?$/i.test(window.location.pathname); + const isSecHost = window.location.protocol === "https:" && /(^|\.)sec\.gov$/i.test(window.location.hostname); + const isCommentPage = isSecHost && /^\/comments\/.+\.html?$/i.test(window.location.pathname); + const isRawEdgarPage = globalThis.pdfMagicIsRawEdgarHtmlDocument?.(document, window.location.href) === true; + const isBasicHtml = isCommentPage || isRawEdgarPage || globalThis.pdfMagicIsPlainHtmlDocument?.(document); const selectionStyles = ` ::selection { @@ -32,9 +35,9 @@ (document.head || document.documentElement).append(style); } - applySelectionStyle(); + if (isSecHost) applySelectionStyle(); - if (!isCommentPage) { + if (!isBasicHtml) { return; } @@ -94,6 +97,22 @@ } `; + const rawEdgarDarkStyles = ` + /* Legacy EDGAR HTML often uses , bgcolor and inline white + backgrounds. Override only those colors, not table sizing or images. */ + body *:not(svg):not(svg *):not(canvas) { + color: inherit !important; + background-color: transparent !important; + } + + body a, + body a:link, + body a:visited, + body a * { + color: var(--pdf-viewer-sec-link) !important; + } + `; + function commentPrompt(commentUrl) { return [ "Display the SEC comment at the URL below with proper, faithful Markdown formatting.", @@ -236,7 +255,7 @@ const style = document.createElement("style"); style.id = STYLE_ID; - style.textContent = darkStyles; + style.textContent = darkStyles + (isRawEdgarPage ? rawEdgarDarkStyles : ""); (document.head || document.documentElement).append(style); } @@ -249,7 +268,8 @@ const enabled = stored[SEC_COMMENT_DARK_MODE_KEY] !== false; const darkModeActive = enabled && theme === "dark"; applyDarkMode(darkModeActive); - setCommentActionVisible(darkModeActive); + // SEC-specific ChatGPT formatting is not offered on unrelated websites. + setCommentActionVisible(darkModeActive && isCommentPage); } chrome.storage.onChanged.addListener((changes, areaName) => { diff --git a/src/viewer.html b/src/viewer.html index a61fea2..74b33e8 100644 --- a/src/viewer.html +++ b/src/viewer.html @@ -132,6 +132,7 @@ +
diff --git a/src/viewer/raw-metadata.js b/src/viewer/raw-metadata.js new file mode 100644 index 0000000..4fd42f6 --- /dev/null +++ b/src/viewer/raw-metadata.js @@ -0,0 +1,66 @@ +// Source metadata is shown separately from the viewer's formatted Sections. +const DERIVED_KEYS = new Set([ + "PDFFormatVersion", "Language", "EncryptFilterName", "IsLinearized", + "IsAcroFormPresent", "IsXFAPresent", "IsCollectionPresent", "IsSignaturesPresent" +]); +function serialize(value) { + const seen = new WeakSet(); + return JSON.stringify(value, (_key, v) => { + if (typeof v === "bigint") return String(v); + if (v && typeof v === "object") { + if (seen.has(v)) return "[Circular]"; + seen.add(v); + } + return v; + }, 2); +} +export function rawMetadataSections(payload) { + if (!payload) return []; + const info = payload.info && typeof payload.info === "object" ? payload.info : {}; + let parsed, xml; + try { parsed = payload.metadata?.getAll?.(); } catch { /* unreadable XMP */ } + try { xml = payload.metadata?.getRaw?.(); } catch { /* unreadable XMP */ } + const hasActualInfo = Object.entries(info).some(([key,v]) => + !DERIVED_KEYS.has(key) && v !== null && v !== undefined && v !== ""); + const hasXmp = Boolean((parsed && Object.keys(parsed).length) || (typeof xml === "string" && xml.length)); + if (!hasActualInfo && !hasXmp) return []; + const sections = []; + if (Object.keys(info).length) sections.push({ title: "PDF Info dictionary", text: serialize(info) }); + if (parsed && Object.keys(parsed).length) sections.push({ title: "XMP parsed fields", text: serialize(parsed) }); + if (typeof xml === "string" && xml.length) sections.push({ title: "Raw XMP XML", text: xml }); + const response = {}; + if (payload.contentDispositionFilename != null) response.contentDispositionFilename = payload.contentDispositionFilename; + if (payload.contentLength != null) response.contentLength = payload.contentLength; + if (Object.keys(response).length) sections.push({ title: "PDF response metadata", text: serialize(response) }); + return sections; +} +export async function installRawMetadataViewer(pdfDocument, closeToolsMenu) { + const button = document.querySelector("#view-raw-metadata"); + const dialog = document.querySelector("#raw-metadata-dialog"); + const content = document.querySelector("#raw-metadata-content"); + const close = document.querySelector("#raw-metadata-close"); + if (!button || !dialog || !content || !close) return; + button.hidden = true; + let sections; + try { sections = rawMetadataSections(await pdfDocument.getMetadata()); } catch { return; } + if (!sections.length) return; + button.hidden = false; + button.addEventListener("click", () => { + closeToolsMenu(); + const fragment = document.createDocumentFragment(); + for (const { title, text } of sections) { + const section = document.createElement("section"); + section.className = "raw-metadata-section"; + const heading = document.createElement("h3"); + heading.textContent = title; + const pre = document.createElement("pre"); + pre.textContent = text; // Embedded metadata is never treated as HTML. + section.append(heading, pre); + fragment.append(section); + } + content.replaceChildren(fragment); + dialog.showModal(); + }); + close.addEventListener("click", () => dialog.close()); + dialog.addEventListener("click", (event) => { if (event.target === dialog) dialog.close(); }); +} diff --git a/src/viewer/viewer-settings.js b/src/viewer/viewer-settings.js index 2ed542f..4cb39f6 100644 --- a/src/viewer/viewer-settings.js +++ b/src/viewer/viewer-settings.js @@ -53,10 +53,10 @@ async function addSecCommentSetting() { const label = document.createElement("label"); label.className = "tool-button tool-toggle"; - label.title = "Darken SEC HTML comments when the viewer uses dark mode"; + label.title = "Darken basic plaintext-style HTML pages (including SEC comments) when the viewer uses dark mode"; const text = document.createElement("span"); - text.textContent = "Darken SEC HTML comments"; + text.textContent = "Darken basic HTML pages"; const input = document.createElement("input"); input.id = "sec-comment-dark-mode"; diff --git a/src/viewer/viewer.css b/src/viewer/viewer.css index 5b85006..c738859 100644 --- a/src/viewer/viewer.css +++ b/src/viewer/viewer.css @@ -1346,3 +1346,30 @@ input { font-size: 25px; cursor: pointer; } + +/* Raw source-level PDF metadata, kept independent of Sections. */ +#view-raw-metadata[hidden] { display: none; } +.raw-metadata-dialog { + width: min(800px, calc(100vw - 28px)); + max-height: 86dvh; padding: 0; + border: 1px solid var(--border); border-radius: 12px; + background: var(--toolbar-bg); color: var(--text); + box-shadow: 0 18px 60px rgb(0 0 0 / 40%); +} +.raw-metadata-dialog::backdrop { background: rgb(0 0 0 / 60%); } +.raw-metadata-card { padding: 18px; } +.raw-metadata-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; } +.raw-metadata-header h2 { margin: 0; font-size: 19px; } +#raw-metadata-close { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 26px; } +.raw-metadata-card > p { color: var(--muted); font-size: 13px; } +.raw-metadata-content { overflow: auto; max-height: 65dvh; } +.raw-metadata-section { margin: 16px 0; } +.raw-metadata-section h3 { margin: 0 0 7px; font-size: 13px; } +.raw-metadata-section pre { + margin: 0; max-height: 40dvh; overflow: auto; + white-space: pre-wrap; overflow-wrap: anywhere; + font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + border: 1px solid var(--border); border-radius: 7px; + padding: 12px; background: var(--control-bg); color: var(--text); + user-select: text; +} diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 0725f36..eeddb41 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -4,6 +4,7 @@ import { abandonPdfDocumentSession, publishPdfDocument } from "./pdf-document-se import { referenceUrlFromPdfMetadata, resolveDocumentReferenceUrl } from "./document-reference-url.js"; import { pdfTextFragmentFromUrl, pdfTextFragmentUrl } from "./sharing/text-fragment.js"; import { metadataField, pdfMetadataTitle } from "./pdf-metadata-title.js"; +import { installRawMetadataViewer } from "./raw-metadata.js"; import { doiFromPdfMetadata, doiResolverUrl } from "./metadata-doi.js"; import { resolvePdfSource } from "./pdf-source.js"; import { readResumedPage, saveResumedPage } from "./page-resume.js"; @@ -1445,6 +1446,7 @@ function bindControls() { rotateLeftButton.addEventListener("click", () => void rotatePages(-90)); rotateRightButton.addEventListener("click", () => void rotatePages(90)); + void installRawMetadataViewer(pdfDocument, () => setToolsMenuOpen(false)); printButton.addEventListener("click", () => void printPdf()); downloadButton.addEventListener("click", () => void downloadPdf()); diff --git a/tests/extension-contract.test.mjs b/tests/extension-contract.test.mjs index 77d6b34..5ff315c 100644 --- a/tests/extension-contract.test.mjs +++ b/tests/extension-contract.test.mjs @@ -25,12 +25,17 @@ test("extension pages reject remote, inline and unsafe-eval executable code", () } }); -test("page integrations execute only on declared HTTPS sites", () => { +test("only basic HTML darkening has broad HTTP and HTTPS content-script coverage", () => { assert.deepEqual(manifest.content_scripts.map((script) => script.matches), [ - ["https://www.sec.gov/*"], ["https://chatgpt.com/*"], + ["http://*/*", "https://*/*"], ["https://chatgpt.com/*"], ]); + assert.deepEqual(manifest.content_scripts.map((script) => script.js), [ + ["src/content/plain-html-detection.js", "src/content/sec-comment.js"], + ["src/content/chatgpt-summary.js"], + ]); + assert.equal(manifest.content_scripts[0].run_at, "document_idle"); + assert.ok(!manifest.content_scripts[0].css?.length); for (const script of manifest.content_scripts) { - for (const pattern of script.matches) assert.match(pattern, /^https:\/\//); for (const path of [...(script.js || []), ...(script.css || [])]) { assert.doesNotThrow(() => readFileSync(new URL("../" + path, import.meta.url))); } diff --git a/tests/plain-html-dark-mode.test.mjs b/tests/plain-html-dark-mode.test.mjs new file mode 100644 index 0000000..1d7698c --- /dev/null +++ b/tests/plain-html-dark-mode.test.mjs @@ -0,0 +1,105 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; +import vm from "node:vm"; + +const detector = readFileSync(new URL("../src/content/plain-html-detection.js", import.meta.url), "utf8"); +const handler = readFileSync(new URL("../src/content/sec-comment.js", import.meta.url), "utf8"); +const settings = readFileSync(new URL("../src/viewer/viewer-settings.js", import.meta.url), "utf8"); +const manifest = JSON.parse(readFileSync(new URL("../manifest.json", import.meta.url), "utf8")); +const ctx=vm.createContext({ URL }); +vm.runInContext(detector,ctx); +function page({text="plain HTML text", type="text/html", complex=false, divs=0, styled=0, named=0}={}) { + return { contentType:type, documentElement:{}, body:{textContent:text}, + querySelector:()=>complex ? {} : null, + querySelectorAll:(selector)=>Array( + selector==="div, section, article" ? divs : selector==="[style]" ? styled : selector==="[class], [id]" ? named : 0 + ).fill({}) }; +} +test("plain HTML is eligible, but empty text and non-HTML are not",()=>{ + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(page()),true); + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(page({text:" "})),false); + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(page({type:"application/pdf"})),false); +}); +test("modern website structure is excluded",()=>{ + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(page({complex:true})),false); + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(page({divs:13})),false); + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(page({styled:17})),false); + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(page({named:26})),false); +}); +test("coverage and old preference survive, SEC ChatGPT stays SEC-only",()=>{ + assert.deepEqual(manifest.content_scripts[0].matches,["http://*/*","https://*/*"]); + assert.deepEqual(manifest.content_scripts[0].js,["src/content/plain-html-detection.js","src/content/sec-comment.js"]); + assert.match(handler,/setCommentActionVisible\(darkModeActive && isCommentPage\)/); + assert.match(settings,/Darken basic HTML pages/); + assert.match(settings,/pdf-viewer-sec-comment-dark-mode/); +}); + +test("raw SEC EDGAR HTML qualifies despite extensive legacy styling", () => { + const filing = "https://www.sec.gov/Archives/edgar/data/1761325/000119312522184158/filename1.htm"; + const legacy = page({complex:true, divs:100, styled:200, named:200}); + assert.equal(ctx.pdfMagicIsPlainHtmlDocument(legacy), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(legacy, filing), true); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(legacy, filing.replace(".htm", ".html")), true); +}); + +test("raw SEC EDGAR detection rejects lookalikes, other sites, and non-HTML", () => { + const filing = "https://www.sec.gov/Archives/edgar/data/1761325/000119312522184158/filename1.htm"; + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page(), filing), true); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page(), filing.replace("www.sec.gov", "sec.gov.evil.example")), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page(), filing.replace("https:", "http:")), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page(), filing.replace(".htm", ".pdf")), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page(), "https://www.sec.gov/Archives/edgar/data/1761325/"), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page(), "https://www.sec.gov/ixviewer/doc.html"), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page({type:"application/pdf"}), filing), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page({text:" "}), filing), false); + assert.equal(ctx.pdfMagicIsRawEdgarHtmlDocument(page(), "not-a-url"), false); +}); + +test("raw EDGAR filing colors follow the saved viewer theme and opt-out", async () => { + const filing = "https://www.sec.gov/Archives/edgar/data/1761325/000119312522184158/filename1.htm"; + const doc = page({complex:true, styled:200, named:200}); + const nodes = new Map(); + const listeners = []; + const stored = {"pdf-viewer-theme":"dark", "pdf-viewer-sec-comment-dark-mode":true}; + doc.head = {append(node) {nodes.set(node.id, node);}}; + doc.createElement = () => ({ + id:"", textContent:"", + remove() {nodes.delete(this.id);} + }); + doc.getElementById = (id) => nodes.get(id) || null; + const chrome = { + runtime:{getManifest:()=>({background:{service_worker:"src/background.js"}})}, + storage:{ + local:{get:async()=>({...stored})}, + onChanged:{addListener:(callback)=>listeners.push(callback)} + } + }; + const context = vm.createContext({URL, document:doc, window:{location:new URL(filing)}, chrome}); + vm.runInContext(detector, context); + vm.runInContext(handler, context); + const flush = () => new Promise(resolve => setImmediate(resolve)); + await flush(); + + const darkId = "pdf-viewer-sec-comment-dark-style"; + assert.ok(nodes.has(darkId)); + assert.match(nodes.get(darkId).textContent, /body \*:not\(svg\):not\(svg \*\):not\(canvas\)/); + assert.match(nodes.get(darkId).textContent, /body a:visited/); + assert.equal(nodes.has("pdf-viewer-sec-chatgpt"), false); + + stored["pdf-viewer-theme"] = "light"; + listeners[0]({"pdf-viewer-theme":{newValue:"light"}}, "local"); + await flush(); + assert.equal(nodes.has(darkId), false); + + stored["pdf-viewer-theme"] = "dark"; + stored["pdf-viewer-sec-comment-dark-mode"] = false; + listeners[0]({"pdf-viewer-theme":{newValue:"dark"}}, "local"); + await flush(); + assert.equal(nodes.has(darkId), false); + + stored["pdf-viewer-sec-comment-dark-mode"] = true; + listeners[0]({"pdf-viewer-sec-comment-dark-mode":{newValue:true}}, "local"); + await flush(); + assert.equal(nodes.has(darkId), true); +}); diff --git a/tests/raw-metadata.test.mjs b/tests/raw-metadata.test.mjs new file mode 100644 index 0000000..7647abd --- /dev/null +++ b/tests/raw-metadata.test.mjs @@ -0,0 +1,35 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; +import { rawMetadataSections } from "../src/viewer/raw-metadata.js"; + +const html = readFileSync(new URL("../src/viewer.html", import.meta.url), "utf8"); +const viewer = readFileSync(new URL("../src/viewer/viewer.js", import.meta.url), "utf8"); +test("raw metadata follows Rotate right in the ⋯ menu, independent of Sections", () => { + const menu = html.slice(html.indexOf('id="tools-menu"'), html.indexOf('id="print-pdf"')); + assert.ok(menu.indexOf('id="view-raw-metadata"') > menu.indexOf('id="rotate-right"')); + assert.ok(menu.indexOf('id="view-raw-metadata"') < menu.indexOf('class="menu-separator"')); + assert.match(html, /id="raw-metadata-dialog"/); + assert.match(viewer, /installRawMetadataViewer\(pdfDocument/); +}); +test("raw view preserves Info values, custom XMP, original XMP XML", () => { + const xml = "RAW"; + const value = rawMetadataSections({ + info: { Title: " Raw ", CreationDate: "D:20090101000000Z", Custom: 42 }, + metadata: { getAll: () => ({ "dc:title": "XMP", "custom:field": "value" }), getRaw: () => xml }, + contentLength: 22, + }); + assert.deepEqual(value.map(x => x.title), ["PDF Info dictionary", "XMP parsed fields", "Raw XMP XML", "PDF response metadata"]); + assert.match(value[0].text, /"Title": " Raw "/); + assert.match(value[1].text, /"custom:field"/); + assert.equal(value[2].text, xml); +}); +test("metadata action is absent when there are only PDF.js derived properties", () => { + assert.deepEqual(rawMetadataSections({ info: { PDFFormatVersion: "1.7", IsLinearized: false }, contentLength: 10 }), []); + assert.deepEqual(rawMetadataSections(null), []); +}); +test("malformed XMP cannot conceal useful PDF Info", () => { + const result=rawMetadataSections({ info: { Author: "Legacy" }, metadata: { getAll() { throw Error(); }, getRaw() { throw Error(); } } }); + assert.equal(result.length, 1); + assert.match(result[0].text, /Legacy/); +});