summaryrefslogtreecommitdiff
path: root/ext/js/accessibility/accessibility-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/accessibility/accessibility-controller.js')
-rw-r--r--ext/js/accessibility/accessibility-controller.js37
1 files changed, 28 insertions, 9 deletions
diff --git a/ext/js/accessibility/accessibility-controller.js b/ext/js/accessibility/accessibility-controller.js
index 2b352948..4dced51b 100644
--- a/ext/js/accessibility/accessibility-controller.js
+++ b/ext/js/accessibility/accessibility-controller.js
@@ -86,14 +86,13 @@ export class AccessibilityController {
try {
if (forceGoogleDocsHtmlRenderingAny) {
if (await isContentScriptRegistered(id)) { return; }
- /** @type {import('script-manager').RegistrationDetails} */
- const details = {
- allFrames: true,
- matches: ['*://docs.google.com/*'],
- runAt: 'document_start',
- js: ['js/accessibility/google-docs.js']
- };
- await registerContentScript(id, details);
+ try {
+ await this._registerGoogleDocsContentScript(id, false);
+ } catch (e) {
+ // Firefox doesn't support `world` field and will throw an error.
+ // In this case, use the xray vision version.
+ await this._registerGoogleDocsContentScript(id, true);
+ }
} else {
await unregisterContentScript(id);
}
@@ -101,5 +100,25 @@ export class AccessibilityController {
log.error(e);
}
}
-}
+ /**
+ * @param {string} id
+ * @param {boolean} xray
+ * @returns {Promise<void>}
+ */
+ _registerGoogleDocsContentScript(id, xray) {
+ /** @type {import('script-manager').RegistrationDetails} */
+ const details = {
+ allFrames: true,
+ matches: ['*://docs.google.com/*'],
+ runAt: 'document_start',
+ js: [
+ xray ?
+ 'js/accessibility/google-docs-xray.js' :
+ 'js/accessibility/google-docs.js'
+ ]
+ };
+ if (!xray) { details.world = 'MAIN'; }
+ return registerContentScript(id, details);
+ }
+}