Skip to content

Commit 7d71fc0

Browse files
committed
Prefer Node.js StackClearer implementation on GJS
`setTimeout()` on GJS wraps the callback in another JS function.
1 parent 75fc5e1 commit 7d71fc0

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/jasmine-core/jasmine.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10883,9 +10883,13 @@ getJasmineRequireObj().StackClearer = function(j$, private$) {
1088310883
global.navigator.userAgent
1088410884
);
1088510885

10886-
if (NODE_JS) {
10886+
const GJS = global.toString() === '[object GjsGlobal]';
10887+
10888+
if (NODE_JS || GJS) {
1088710889
// Unlike browsers, Node doesn't require us to do a periodic setTimeout
1088810890
// so we avoid the overhead.
10891+
// GJS implementation of setTimeout wraps the callback in another JS
10892+
// function, which will be visible in stack. So avoid setTimeout.
1088910893
return nodeQueueMicrotaskImpl(global);
1089010894
} else if (SAFARI_OR_WIN_WEBKIT || !global.MessageChannel) {
1089110895
// queueMicrotask is dramatically faster than MessageChannel in Safari

src/core/StackClearer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,13 @@ getJasmineRequireObj().StackClearer = function(j$, private$) {
151151
global.navigator.userAgent
152152
);
153153

154-
if (NODE_JS) {
154+
const GJS = global.toString() === '[object GjsGlobal]';
155+
156+
if (NODE_JS || GJS) {
155157
// Unlike browsers, Node doesn't require us to do a periodic setTimeout
156158
// so we avoid the overhead.
159+
// GJS implementation of setTimeout wraps the callback in another JS
160+
// function, which will be visible in stack. So avoid setTimeout.
157161
return nodeQueueMicrotaskImpl(global);
158162
} else if (SAFARI_OR_WIN_WEBKIT || !global.MessageChannel) {
159163
// queueMicrotask is dramatically faster than MessageChannel in Safari

0 commit comments

Comments
 (0)