Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check for WebExtension in the atoms userAgent #6475

Merged
merged 2 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/atoms/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ bot.Device.shouldFollowHref_ = function(element) {
return false;
}

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

Expand Down
15 changes: 15 additions & 0 deletions javascript/atoms/userAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ bot.userAgent.FIREFOX_EXTENSION = (function() {
return true;
})();

/**
* Whether we are a WebExtension.
*
* @const
* @type {boolean}
*/
bot.userAgent.WEBEXTENSION = (function() {
// The content script global object is different than it's window
// Which requires accessing the chrome and browser objects through this
try {
return !!((chrome || browser).runtime);
} catch (e) {
return false;
}
})();

/**
* Whether we are on IOS.
Expand Down