Skip to content

Commit

Permalink
Release braintree-web 3.85.1 source
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Jan 13, 2022
1 parent 75c1c24 commit 9831fac
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

# 3.85.1

- Venmo
- Fix issue where iOS Chrome was reporting as a supported browser

# 3.85.0

- Client
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braintree-web",
"version": "3.85.0",
"version": "3.85.1",
"license": "MIT",
"main": "src/index.js",
"private": true,
Expand Down
11 changes: 11 additions & 0 deletions src/venmo/shared/browser-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ function isFacebookOwnedBrowserOnAndroid() {
return ua.indexOf('fb_iab') > -1 || ua.indexOf('instagram') > -1;
}

// iOS chrome used to work with Venmo, but now it does not
// we are unsure if something changed in the iOS Chrome app
// itself, or if something about iOS webviews has changed
// until we find out more info, we've created a helper to
// easilly turn off iOS Chrome as a supported browser in
// the isBrowserSupported helper function
function isIosChrome() {
return isIos() && isChrome();
}

module.exports = {
isAndroid: isAndroid,
isAndroidWebview: isAndroidWebview,
isChrome: isChrome,
isIos: isIos,
isIosChrome: isIosChrome,
isIosSafari: isIosSafari,
isIosWebview: isIosWebview,
isFacebookOwnedBrowserOnAndroid: isFacebookOwnedBrowserOnAndroid,
Expand Down
7 changes: 4 additions & 3 deletions src/venmo/shared/supports-venmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var browserDetection = require('./browser-detection');
function isBrowserSupported(options) {
var merchantAllowsReturningToNewBrowserTab, merchantAllowsWebviews, merchantAllowsDesktopBrowsers;
var isAndroid = browserDetection.isAndroid();
var isMobileDevice = isAndroid || browserDetection.isIos();
var isSupportedMobileDevice = isAndroid ||
(browserDetection.isIos() && !browserDetection.isIosChrome());
var isAndroidChrome = isAndroid && browserDetection.isChrome();
var isMobileDeviceThatSupportsReturnToSameTab = browserDetection.isIosSafari() || isAndroidChrome;

Expand All @@ -30,15 +31,15 @@ function isBrowserSupported(options) {
return true;
}

return merchantAllowsDesktopBrowsers && !isMobileDevice;
return merchantAllowsDesktopBrowsers && !isSupportedMobileDevice;
}

if (browserDetection.isFacebookOwnedBrowserOnAndroid()) {
return false;
}

if (!merchantAllowsDesktopBrowsers) {
return isMobileDevice;
return isSupportedMobileDevice;
}

return true;
Expand Down
21 changes: 21 additions & 0 deletions test/venmo/unit/browser-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ describe('browser detection', () => {
});
});

describe('isIosChrome', () => {
it('returns true when isIos and isChrome return true', () => {
isChrome.mockReturnValue(true);
isIos.mockReturnValue(true);

expect(browserDetection.isIosChrome()).toBe(true);
});

it('returns false when either isIos or isChrome do not return true', () => {
isChrome.mockReturnValue(false);
isIos.mockReturnValue(true);

expect(browserDetection.isIosChrome()).toBe(false);

isChrome.mockReturnValue(true);
isIos.mockReturnValue(false);

expect(browserDetection.isIosChrome()).toBe(false);
});
});

describe('isFacebookOwnedBrowserOnAndroid', () => {
let userAgentSpy;

Expand Down
8 changes: 5 additions & 3 deletions test/venmo/unit/is-browser-supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('isBrowserSupported', () => {
browserDetection.isIos.mockReturnValue(false);

browserDetection.isChrome.mockReturnValue(false);
browserDetection.isIosChrome.mockReturnValue(false);
browserDetection.isIosSafari.mockReturnValue(false);
browserDetection.isIosWebview.mockReturnValue(false);
browserDetection.isAndroidWebview.mockReturnValue(false);
Expand All @@ -33,11 +34,12 @@ describe('isBrowserSupported', () => {
expect(isBrowserSupported()).toBe(true);
});

it('returns true for iOS Chrome', () => {
it('returns false for iOS Chrome', () => {
// so that it would normally pass for being iOS
browserDetection.isIos.mockReturnValue(true);
browserDetection.isChrome.mockReturnValue(true);
browserDetection.isIosChrome.mockReturnValue(true);

expect(isBrowserSupported()).toBe(true);
expect(isBrowserSupported()).toBe(false);
});

it('returns true for Android Chrome', () => {
Expand Down

0 comments on commit 9831fac

Please sign in to comment.