From ebaa2e7f2465d5abf596f8d72d4c4eb8cc39d9a0 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 19 Jan 2015 22:34:54 -0800 Subject: [PATCH] Set jasmineGlobal correctly in GJS In GJS, jasmineGlobal was not getting set to the global object; when importing jasmine.js in GJS, "this" resolves to the jasmine.js module object, not the global object. Solve this specifically for GJS by assuming that `window.toString === '[object GjsGlobal]'` only in GJS; if this is the case, assign "window" to "jasmineGlobal". Adding a "var" to the declaration of "getJasmineRequireObj" is also necessary, or else "getJasmineRequireObj" won't be exported in the Jasmine module. See #751 --- src/core/requireCore.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/requireCore.js b/src/core/requireCore.js index 73bf3c24..384bc6eb 100644 --- a/src/core/requireCore.js +++ b/src/core/requireCore.js @@ -1,10 +1,13 @@ -getJasmineRequireObj = (function (jasmineGlobal) { +var getJasmineRequireObj = (function (jasmineGlobal) { var jasmineRequire; if (typeof module !== 'undefined' && module.exports) { jasmineGlobal = global; jasmineRequire = exports; } else { + if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') { + jasmineGlobal = window; + } jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {}; }