| Index: ext/background.js |
| =================================================================== |
| --- a/ext/background.js |
| +++ b/ext/background.js |
| @@ -512,21 +512,24 @@ |
| updateContextMenu(); |
| } |
| } |
| } |
| }; |
| chrome.tabs.onActivated.addListener(updateContextMenu); |
| - chrome.windows.onFocusChanged.addListener(windowId => |
| + if ("windows" in chrome) |
| { |
| - if (windowId != chrome.windows.WINDOW_ID_NONE) |
| - updateContextMenu(); |
| - }); |
| + chrome.windows.onFocusChanged.addListener(windowId => |
| + { |
| + if (windowId != chrome.windows.WINDOW_ID_NONE) |
| + updateContextMenu(); |
| + }); |
| + } |
| /* Web requests */ |
| let framesOfTabs = new Map(); |
| ext.getFrame = (tabId, frameId) => |
| { |
| @@ -729,45 +732,59 @@ |
| else |
| { |
| // Edge does not yet support runtime.openOptionsPage (tested version 38) |
| // nor does Firefox for Android, |
| // and so this workaround needs to stay for now. |
| // We are not using extension.getURL to get the absolute path here |
| // because of the Edge issue: |
| // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10276332/ |
| - chrome.windows.getLastFocused(win => |
| + let open = win => |
| { |
| let optionsUrl = "options.html"; |
| let queryInfo = {url: optionsUrl}; |
| // extension pages can't be accessed in incognito windows. In order to |
| // correctly mimic the way in which Chrome opens extension options, |
| // we have to focus the options page in any other window. |
| - if (!win.incognito) |
| + if (win && !win.incognito) |
| queryInfo.windowId = win.id; |
| chrome.tabs.query(queryInfo, tabs => |
| { |
| if (tabs && tabs.length > 0) |
| { |
| let tab = tabs[0]; |
| - chrome.windows.update(tab.windowId, {focused: true}); |
| + if ("windows" in chrome) |
| + chrome.windows.update(tab.windowId, {focused: true}); |
| + |
| chrome.tabs.update(tab.id, {active: true}); |
| if (callback) |
| callback(new Page(tab)); |
| } |
| else |
| { |
| ext.pages.open(optionsUrl, callback); |
| } |
| }); |
| - }); |
| + }; |
| + |
| + if ("windows" in chrome) |
| + { |
| + chrome.windows.getLastFocused(open); |
| + } |
| + else |
| + { |
| + // Firefox for Android does not support the windows API. Since there is |
| + // effectively only one window on the mobile browser, there's no need |
| + // to bring it into focus. |
| + open(); |
| + } |
| } |
| }; |
| /* Windows */ |
| ext.windows = { |
| create(createData, callback) |
| { |
| chrome.windows.create(createData, createdWindow => |