Skip to content

Commit

Permalink
[js] Remove Firefox Extension code handling
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Feb 22, 2021
1 parent d1e3a2c commit e0efe7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 73 deletions.
6 changes: 2 additions & 4 deletions javascript/atoms/device.js
Expand Up @@ -512,9 +512,7 @@ bot.Device.prototype.focusOnElement = function () {
* @private {boolean}
* @const
*/
bot.Device.ALWAYS_FOLLOWS_LINKS_ON_CLICK_ =
goog.userAgent.WEBKIT ||
(bot.userAgent.FIREFOX_EXTENSION && bot.userAgent.isProductVersion(3.6));
bot.Device.ALWAYS_FOLLOWS_LINKS_ON_CLICK_ = goog.userAgent.WEBKIT;


/**
Expand Down Expand Up @@ -558,7 +556,7 @@ bot.Device.shouldFollowHref_ = function (element) {
return false;
}

if (!(bot.userAgent.FIREFOX_EXTENSION || bot.userAgent.WEBEXTENSION)) {
if (!(bot.userAgent.WEBEXTENSION)) {
return true;
}

Expand Down
71 changes: 2 additions & 69 deletions javascript/atoms/userAgent.js
Expand Up @@ -42,9 +42,7 @@ goog.require('goog.userAgent.product.isVersion');
* than the given version.
*/
bot.userAgent.isEngineVersion = function (version) {
if (bot.userAgent.FIREFOX_EXTENSION) {
return bot.userAgent.FIREFOX_EXTENSION_IS_ENGINE_VERSION_(version);
} else if (goog.userAgent.IE) {
if (goog.userAgent.IE) {
return goog.string.compareVersions(
/** @type {number} */(goog.userAgent.DOCUMENT_MODE), version) >= 0;
} else {
Expand All @@ -68,9 +66,7 @@ bot.userAgent.isEngineVersion = function (version) {
* than the given version.
*/
bot.userAgent.isProductVersion = function (version) {
if (bot.userAgent.FIREFOX_EXTENSION) {
return bot.userAgent.FIREFOX_EXTENSION_IS_PRODUCT_VERSION_(version);
} else if (goog.userAgent.product.ANDROID) {
if (goog.userAgent.product.ANDROID) {
return goog.string.compareVersions(
bot.userAgent.ANDROID_VERSION_, version) >= 0;
} else {
Expand All @@ -79,69 +75,6 @@ bot.userAgent.isProductVersion = function (version) {
};


/**
* When we are in a Firefox extension, this is a function that accepts a version
* and returns whether the version of Gecko we are on is the same or higher
* than the given version. When we are not in a Firefox extension, this is null.
* @private {(undefined|function((string|number)): boolean)}
*/
bot.userAgent.FIREFOX_EXTENSION_IS_ENGINE_VERSION_;


/**
* When we are in a Firefox extension, this is a function that accepts a version
* and returns whether the version of Firefox we are on is the same or higher
* than the given version. When we are not in a Firefox extension, this is null.
* @private {(undefined|function((string|number)): boolean)}
*/
bot.userAgent.FIREFOX_EXTENSION_IS_PRODUCT_VERSION_;


/**
* Whether we are in a Firefox extension.
*
* @const
* @type {boolean}
*/
bot.userAgent.FIREFOX_EXTENSION = (function () {
// False if this browser is not a Gecko browser.
if (!goog.userAgent.GECKO) {
return false;
}

// False if this code isn't running in an extension.
var Components = goog.global.Components;
if (!Components) {
return false;
}
try {
if (!Components['classes']) {
return false;
}
} catch (e) {
return false;
}

// Populate the version checker functions.
var cc = Components['classes'];
var ci = Components['interfaces'];
var versionComparator = cc['@mozilla.org/xpcom/version-comparator;1'][
'getService'](ci['nsIVersionComparator']);
var appInfo = cc['@mozilla.org/xre/app-info;1']['getService'](
ci['nsIXULAppInfo']);
var geckoVersion = appInfo['platformVersion'];
var firefoxVersion = appInfo['version'];

bot.userAgent.FIREFOX_EXTENSION_IS_ENGINE_VERSION_ = function (version) {
return versionComparator.compare(geckoVersion, '' + version) >= 0;
};
bot.userAgent.FIREFOX_EXTENSION_IS_PRODUCT_VERSION_ = function (version) {
return versionComparator.compare(firefoxVersion, '' + version) >= 0;
};

return true;
})();

/**
* Whether we are a WebExtension.
*
Expand Down

0 comments on commit e0efe7e

Please sign in to comment.