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

Commit fb04e42

Browse files
Ed Clementgkalpak
Ed Clement
authored andcommitted
test(Angular): fix angularInit() tests on Safari v15+
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
1 parent 6a52c4f commit fb04e42

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/AngularSpec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,12 @@ describe('angular', function() {
17931793
} else if (/Chrome\//.test(userAgent)) {
17941794
protocol = 'chrome-extension:';
17951795
} else if (/Safari\//.test(userAgent)) {
1796-
protocol = 'safari-extension:';
1796+
// On iOS, Safari versions <15 recognize `safari-extension:`, while versions >=15 only
1797+
// recognize `chrome-extension:`.
1798+
// (On macOS, Safari v15 recognizes both protocols, so it is fine to use either.)
1799+
var majorVersionMatch = /Version\/(\d+)/.exec(userAgent);
1800+
var majorVersion = majorVersionMatch ? parseInt(majorVersionMatch[1], 10) : 0;
1801+
protocol = (majorVersion < 15) ? 'safari-extension:' : 'chrome-extension:';
17971802
} else {
17981803
protocol = 'browserext:'; // Upcoming standard scheme.
17991804
}

0 commit comments

Comments
 (0)