Index: ext/background.js |
=================================================================== |
--- a/ext/background.js |
+++ b/ext/background.js |
@@ -737,49 +737,38 @@ |
// 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/ |
- 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 && !win.incognito) |
- queryInfo.windowId = win.id; |
+ let optionsUrl = "options.html"; |
+ let fullOptionsUrl = ext.getURL("options.html"); |
- chrome.tabs.query(queryInfo, tabs => |
+ chrome.tabs.query({}, tabs => |
+ { |
+ // We find a tab ourselves because Edge has a bug when quering tabs |
+ // with extension URL protocol: |
+ // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8094141/ |
+ // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8604703/ |
+ let tab = tabs == null ? null : tabs.find(element => |
Sebastian Noack
2017/08/29 04:04:26
In which case is `tabs == null`? According to my u
Manish Jethani
2017/08/29 04:18:33
tabs was null on Firefox for Android when we were
|
{ |
- if (tabs && tabs.length > 0) |
- { |
- let tab = tabs[0]; |
- |
- if ("windows" in chrome) |
- chrome.windows.update(tab.windowId, {focused: true}); |
- |
- chrome.tabs.update(tab.id, {active: true}); |
+ return element.url == fullOptionsUrl; |
Sebastian Noack
2017/08/29 04:04:26
The braces + return statement is redundant for sin
|
+ }); |
- if (callback) |
- callback(new Page(tab)); |
- } |
- else |
- { |
- ext.pages.open(optionsUrl, callback); |
- } |
- }); |
- }; |
+ if (tab) |
+ { |
+ // 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. |
+ if ("windows" in chrome) |
+ chrome.windows.update(tab.windowId, {focused: true}); |
- 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(); |
- } |
+ chrome.tabs.update(tab.id, {active: true}); |
+ |
+ if (callback) |
+ callback(new Page(tab)); |
+ } |
+ else |
+ { |
+ ext.pages.open(optionsUrl, callback); |
+ } |
+ }); |
} |
}; |