diff --git a/lib/core.js b/lib/core.js index 9b28df75d..7734598d4 100644 --- a/lib/core.js +++ b/lib/core.js @@ -50,8 +50,13 @@ var DefaultChainable = getNewChainableClass('Chainable'); function getGlobal() { // Get global context by keyword here to avoid issues with libraries // that can potentially alter this script's context object. - return testGlobal(typeof global !== 'undefined' && global) || - testGlobal(typeof window !== 'undefined' && window); + var ret = testGlobal(typeof global !== 'undefined' && global) || + testGlobal(typeof window !== 'undefined' && window); + if (ret) return ret; + // Firefox / Thunderbird specific + if (typeof Cu != 'undefined' && typeof Cu.getGlobalForObject != 'undefined') + ret = testGlobal(Cu.getGlobalForObject(getGlobal)); + return ret; } function testGlobal(obj) {