Add test, update rexex pattern and constant name

This commit is contained in:
Mert Akinc
2024-07-26 17:45:23 -05:00
parent a9889ddb31
commit 97b6f33cc2
2 changed files with 18 additions and 3 deletions

View File

@@ -22,6 +22,19 @@ describe('ClearStack', function() {
});
});
describe('in WebKit (Playwright\'s build for Windows)', function() {
usesQueueMicrotaskWithSetTimeout(function() {
return {
navigator: {
userAgent:
'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/605.1.15 (KHTML, like Gecko)'
},
// queueMicrotask should be used even though MessageChannel is present
MessageChannel: fakeMessageChannel
};
});
});
describe('in browsers other than Safari', function() {
usesMessageChannel(function() {
return {

View File

@@ -68,9 +68,11 @@ getJasmineRequireObj().clearStack = function(j$) {
global.process.versions &&
typeof global.process.versions.node === 'string';
const SAFARI =
// Windows builds of WebKit have a fairly generic user agent string when no application name is provided.
// See: https://github.com/WebKit/WebKit/blob/d898a3cffd9c992980016cb1fbdba272cb0c992d/Source/WebCore/platform/win/UserAgentWin.cpp#L37
const SAFARI_OR_WIN_WEBKIT =
global.navigator &&
/(^((?!chrome|android).)*safari)|(^((?!chrome|android|firefox).)+$)/i.test(
/(^((?!chrome|android).)*safari)|(Win64; x64\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)$)/i.test(
global.navigator.userAgent
);
@@ -79,7 +81,7 @@ getJasmineRequireObj().clearStack = function(j$) {
// so we avoid the overhead.
return nodeQueueMicrotaskImpl(global);
} else if (
SAFARI ||
SAFARI_OR_WIN_WEBKIT ||
j$.util.isUndefined(global.MessageChannel) /* tests */
) {
// queueMicrotask is dramatically faster than MessageChannel in Safari,