Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/background.js

Issue 29532730: Noissue - Rebase current master tip to edge bookmark (Closed)
Patch Set: Created Aug. 31, 2017, 2:55 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ensure_dependencies.py ('k') | ext/content.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/background.js
===================================================================
--- a/ext/background.js
+++ b/ext/background.js
@@ -699,11 +699,14 @@
ext.showOptions = callback =>
{
+ let info = require("info");
+
if ("openOptionsPage" in chrome.runtime &&
- // Firefox for Android does have a runtime.openOptionsPage but it
- // doesn't do anything.
+ // Some versions of Firefox for Android before version 57 do have a
+ // runtime.openOptionsPage but it doesn't do anything.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1364945
- require("info").application != "fennec")
+ (info.application != "fennec" ||
+ parseInt(info.applicationVersion, 10) >= 57))
{
if (!callback)
{
@@ -729,57 +732,44 @@
});
}
}
- else
+ else if ("windows" in chrome)
{
// 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/
- 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(optionsUrl);
- 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.find(element => element.url == fullOptionsUrl);
+ if (tab)
{
- 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});
+ 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();
- }
+ if (callback)
+ callback(new Page(tab));
+ }
+ else
+ {
+ ext.pages.open(optionsUrl, callback);
+ }
+ });
+ }
+ else
+ {
+ // Firefox for Android before version 57 does not support
+ // runtime.openOptionsPage, nor does it support the windows API. Since
+ // there is effectively only one window on the mobile browser, there's no
+ // need to bring it into focus.
+ ext.pages.open("options.html", callback);
}
};
« no previous file with comments | « ensure_dependencies.py ('k') | ext/content.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld