{"record":{"id":"93974b3fa243bd97","repo":"mozilla/pdf.js","slug":"app-viewertype-is-read-only","errorCode":null,"errorMessage":"app.viewerType is read-only","messagePattern":"app\\.viewerType is read-only","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/scripting_api/app.js","lineNumber":388,"sourceCode":"    /* has been deprecated and it's now equivalent to toolbar */\n    this.toolbar = value;\n  }\n\n  get toolbarVertical() {\n    return this.toolbar;\n  }\n\n  set toolbarVertical(value) {\n    /* has been deprecated and it's now equivalent to toolbar */\n    this.toolbar = value;\n  }\n\n  get viewerType() {\n    return VIEWER_TYPE;\n  }\n\n  set viewerType(_) {\n    throw new Error(\"app.viewerType is read-only\");\n  }\n\n  get viewerVariation() {\n    return VIEWER_VARIATION;\n  }\n\n  set viewerVariation(_) {\n    throw new Error(\"app.viewerVariation is read-only\");\n  }\n\n  get viewerVersion() {\n    return VIEWER_VERSION;\n  }\n\n  set viewerVersion(_) {\n    throw new Error(\"app.viewerVersion is read-only\");\n  }\n","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/scripting_api/app.js#L370-L406","documentation":"app.viewerType exposes the compiled VIEWER_TYPE constant (identifying PDF.js as the viewer). It is fixed per build and read-only; the setter throws. The throw prevents spoofing the viewer identity.","triggerScenarios":"Any assignment app.viewerType = 'Exchange-Pro' (or any value) in PDF JavaScript or caller code hits the throw at src/scripting_api/app.js:388.","commonSituations":"Scripts trying to impersonate Acrobat Professional to unlock menu actions; feature checks that mistakenly write instead of read.","solutions":["Read app.viewerType for viewer-specific branching (expect the PDF.js identifier).","Gate features on your own capability checks, not by rewriting viewerType.","If a different identifier is truly required, build PDF.js from source with a custom constant."],"exampleFix":"// before\napp.viewerType = 'Exchange-Pro';\n// after\nif (app.viewerType === VIEWER_TYPE) { /* pdf.js path */ }","handlingStrategy":"validation","validationCode":"// app.viewerType is a build constant; read only.\nconst isPdfJs = (app) => app.viewerType === VIEWER_TYPE;","typeGuard":"const isViewerTypeString = (v) => typeof v === 'string' && v.length > 0;","tryCatchPattern":"try { /* code that may assign app.viewerType */ }\ncatch (e) { if (!/viewerType is read-only/.test(e.message)) throw e; }","preventionTips":["Gate features on app.viewerType rather than spoofing it.","Rebuild PDF.js from source if a different identifier is truly required.","Document the expected viewerType for your integration."],"tags":["scripting-api","read-only","version","acrobat-js"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}