1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/test/test-globals.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,30 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +'use strict'; 1.8 + 1.9 +Object.defineProperty(this, 'global', { value: this }); 1.10 + 1.11 +exports.testGlobals = function(assert) { 1.12 + // the only globals in module scope should be: 1.13 + // module, exports, require, dump, console 1.14 + assert.equal(typeof module, 'object', 'have "module", good'); 1.15 + assert.equal(typeof exports, 'object', 'have "exports", good'); 1.16 + assert.equal(typeof require, 'function', 'have "require", good'); 1.17 + assert.equal(typeof dump, 'function', 'have "dump", good'); 1.18 + assert.equal(typeof console, 'object', 'have "console", good'); 1.19 + 1.20 + // in particular, these old globals should no longer be present 1.21 + assert.ok(!('packaging' in global), "no 'packaging', good"); 1.22 + assert.ok(!('memory' in global), "no 'memory', good"); 1.23 + assert.ok(/test-globals\.js$/.test(module.uri), 1.24 + 'should contain filename'); 1.25 +}; 1.26 + 1.27 +exports.testComponent = function (assert) { 1.28 + assert.throws(() => { 1.29 + Components; 1.30 + }, /`Components` is not available/, 'using `Components` throws'); 1.31 +}; 1.32 + 1.33 +require('test').run(exports);