Various firefox fixes (#1306)

* Fix for chrome.commands not being present on Firefox's embedded float.html

* Fix _getSearchContext mishandling _optionsContextOverride
This commit is contained in:
toasted-nutbread 2021-01-24 14:20:17 -05:00 committed by GitHub
parent 4b6bb52952
commit a0657e1bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -637,14 +637,14 @@ class Frontend {
}
async _getOptionsContext() {
return (await this._getSearchContext()).optionsContext;
let optionsContext = this._optionsContextOverride;
if (optionsContext === null) {
optionsContext = (await this._getSearchContext()).optionsContext;
}
return optionsContext;
}
async _getSearchContext() {
if (this._optionsContextOverride !== null) {
return this._optionsContextOverride;
}
let url = window.location.href;
let documentTitle = document.title;
if (this._useProxyPopup) {
@ -655,9 +655,13 @@ class Frontend {
}
}
const depth = this._depth;
let optionsContext = this._optionsContextOverride;
if (optionsContext === null) {
optionsContext = {depth: this._depth, url};
}
return {
optionsContext: {depth, url},
optionsContext,
detail: {documentTitle}
};
}

View File

@ -83,6 +83,11 @@ class HotkeyHelpController {
async _setupGlobalCommands(commandMap) {
const commands = await new Promise((resolve, reject) => {
if (!(isObject(chrome.commands) && typeof chrome.commands.getAll === 'function')) {
resolve([]);
return;
}
chrome.commands.getAll((result) => {
const e = chrome.runtime.lastError;
if (e) {