{"record":{"id":"186eb65ecc419989","repo":"mozilla/pdf.js","slug":"doc-outerappwindowrect-is-read-only","errorCode":null,"errorMessage":"doc.outerAppWindowRect is read-only","messagePattern":"doc\\.outerAppWindowRect is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/doc.js","lineNumber":550,"sourceCode":"\n  set numPages(_) {\n    throw new Error(\"doc.numPages is read-only\");\n  }\n\n  get numTemplates() {\n    return 0;\n  }\n\n  set numTemplates(_) {\n    throw new Error(\"doc.numTemplates is read-only\");\n  }\n\n  get outerAppWindowRect() {\n    return [0, 0, 0, 0];\n  }\n\n  set outerAppWindowRect(_) {\n    throw new Error(\"doc.outerAppWindowRect is read-only\");\n  }\n\n  get outerDocWindowRect() {\n    return [0, 0, 0, 0];\n  }\n\n  set outerDocWindowRect(_) {\n    throw new Error(\"doc.outerDocWindowRect is read-only\");\n  }\n\n  get pageNum() {\n    return this._pageNum;\n  }\n\n  set pageNum(value) {\n    if (!this._userActivation) {\n      return;\n    }","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/doc.js#L532-L568","documentation":"`Doc.outerAppWindowRect` returns `[left, top, right, bottom]` describing the outer bounds of the host application window. In a browser context there is no enclosing application window, so PDF.js returns `[0,0,0,0]`. The Acrobat spec marks it read-only; PDF.js's throwing setter enforces that and prevents scripts from pretending to resize a non-existent window.","triggerScenarios":"A script assigns to `doc.outerAppWindowRect` (e.g. `doc.outerAppWindowRect = [0,0,800,600];`), attempting to resize/reposition the application. The setter throws immediately.","commonSituations":"Scripts written for desktop Acrobat that reposition the app window on open; window-management code copied from an SDK sample; scripts run unchanged in the PDF.js viewer.","solutions":["Delete the assignment — there is no app window to size in the browser viewer.","Control viewer layout via the embedding page/iframe CSS instead of through the script.","Run legacy scripts under try/catch so the unsupported write is logged and skipped."],"exampleFix":"// before\ndoc.outerAppWindowRect = [0, 0, 1024, 768];\n\n// after\n// (remove) — not applicable in a browser viewer; returns [0,0,0,0]","handlingStrategy":"try-catch","validationCode":"const READ_ONLY_DOC_PROPS = new Set(['outerAppWindowRect','outerDocWindowRect' /* ... */]);\nfunction assertsNoReadOnlyWrite(scriptSrc) {\n  for (const p of READ_ONLY_DOC_PROPS) {\n    if (new RegExp(`\\\\bdoc\\\\.${p}\\\\s*=[^=]`).test(scriptSrc)) {\n      throw new Error(`Script writes read-only property doc.${p}`);\n    }\n  }\n}\nassertsNoReadOnlyWrite(myScript);","typeGuard":"function isReadOnlyDocProp(doc, prop) {\n  const desc = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(doc), prop)\n    || Object.getOwnPropertyDescriptor(doc, prop);\n  return !!desc && !!desc.get && !desc.set;\n}\nisReadOnlyDocProp(doc, 'outerAppWindowRect'); // true","tryCatchPattern":"try {\n  doc.outerAppWindowRect = [0,0,800,600];\n} catch (e) {\n  if (/outerAppWindowRect is read-only/.test(e.message)) console.warn(e.message);\n  else throw e;\n}","preventionTips":["There is no application window in the browser viewer; do not script window-rect properties.","Size the viewer from the embedding page, not from document scripts.","Run desktop-Acrobat scripts through try/catch to tolerate unsupported windowing writes."],"tags":["scripting","acrobat-js-api","doc-object","read-only","window","unsupported"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}