{"record":{"id":"51fc05da1a256456","repo":"mozilla/pdf.js","slug":"doc-permstatusready-is-read-only","errorCode":null,"errorMessage":"doc.permStatusReady is read-only","messagePattern":"doc\\.permStatusReady is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/doc.js","lineNumber":599,"sourceCode":"\n  set pageWindowRect(_) {\n    throw new Error(\"doc.pageWindowRect is read-only\");\n  }\n\n  get path() {\n    return \"\";\n  }\n\n  set path(_) {\n    throw new Error(\"doc.path is read-only\");\n  }\n\n  get permStatusReady() {\n    return true;\n  }\n\n  set permStatusReady(_) {\n    throw new Error(\"doc.permStatusReady is read-only\");\n  }\n\n  get producer() {\n    return this._producer;\n  }\n\n  set producer(_) {\n    throw new Error(\"doc.producer is read-only\");\n  }\n\n  get requiresFullSave() {\n    return false;\n  }\n\n  set requiresFullSave(_) {\n    throw new Error(\"doc.requiresFullSave is read-only\");\n  }\n","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/doc.js#L581-L617","documentation":"`Doc.permStatusReady` indicates whether the document's permission status (rights/usage-rights) has finished loading; PDF.js returns `true` because it does not perform asynchronous usage-rights resolution. It is read-only by the Acrobat spec — a script observes the state, it cannot change it. The throwing setter keeps that contract.","triggerScenarios":"A script writes `doc.permStatusReady = true/false;`, attempting to force or reset the permissions-ready flag. The setter throws.","commonSituations":"Rights-management scripts from LiveCycle/Acrobat; scripts that toggle flags before reading `doc.dynamicXFAForm` or related; legacy enterprise form logic.","solutions":["Remove the assignment — observe the value (`var ready = doc.permStatusReady;`, always true in PDF.js).","Handle permissions/rights at the document-loading layer, not in-document.","Guard legacy scripts with try/catch."],"exampleFix":"// before\ndoc.permStatusReady = true;\n\n// after\nif (doc.permStatusReady) { /* always true in PDF.js */ }","handlingStrategy":"try-catch","validationCode":"const READ_ONLY_DOC_PROPS = new Set(['permStatusReady','requiresFullSave' /* ... */]);\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, 'permStatusReady'); // true","tryCatchPattern":"try {\n  doc.permStatusReady = true;\n} catch (e) {\n  if (/permStatusReady is read-only/.test(e.message)) console.warn(e.message);\n  else throw e;\n}","preventionTips":["Permission/usage-rights flags are read-only; handle them at load time, not in-script.","Lint scripts for assignments to rights/save-state properties.","Wrap legacy rights-management scripts in try/catch."],"tags":["scripting","acrobat-js-api","doc-object","read-only","permissions"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}