Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
test(Angular): fix angularInit() tests on Safari v15+
Browse files Browse the repository at this point in the history
Previously, the `angularInit()` tests assumed that the Safari browser
uses the `safari-extension:` protocol for browser extension URLs. This
is true for versions <15. However, since v15, Safari on iOS only
recognizes the `chrome-extension:` protocol, which causes the tests to
fail ([example failure][1]).

This commit updates the tests to use the correct protocol according to
the version of Safari used.

NOTE:
On macOS, Safari v15+ recognizes both `safari-extension:` and
`chrome-extension:`, so it is OK to always use the later with Safari
v15+ (regardless of the platform).

[1]: https://circleci.com/gh/angular/angular.js/3527

Co-authored-by: George Kalpakas <[email protected]>

Closes #17166
  • Loading branch information
Ed Clement authored and gkalpak committed Dec 9, 2021
1 parent 6a52c4f commit fb04e42
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,12 @@ describe('angular', function() {
} else if (/Chrome\//.test(userAgent)) {
protocol = 'chrome-extension:';
} else if (/Safari\//.test(userAgent)) {
protocol = 'safari-extension:';
// On iOS, Safari versions <15 recognize `safari-extension:`, while versions >=15 only
// recognize `chrome-extension:`.
// (On macOS, Safari v15 recognizes both protocols, so it is fine to use either.)
var majorVersionMatch = /Version\/(\d+)/.exec(userAgent);
var majorVersion = majorVersionMatch ? parseInt(majorVersionMatch[1], 10) : 0;
protocol = (majorVersion < 15) ? 'safari-extension:' : 'chrome-extension:';
} else {
protocol = 'browserext:'; // Upcoming standard scheme.
}
Expand Down

0 comments on commit fb04e42

Please sign in to comment.