|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 'use strict'; |
|
5 |
|
6 Object.defineProperty(this, 'global', { value: this }); |
|
7 |
|
8 exports.testGlobals = function(assert) { |
|
9 // the only globals in module scope should be: |
|
10 // module, exports, require, dump, console |
|
11 assert.equal(typeof module, 'object', 'have "module", good'); |
|
12 assert.equal(typeof exports, 'object', 'have "exports", good'); |
|
13 assert.equal(typeof require, 'function', 'have "require", good'); |
|
14 assert.equal(typeof dump, 'function', 'have "dump", good'); |
|
15 assert.equal(typeof console, 'object', 'have "console", good'); |
|
16 |
|
17 // in particular, these old globals should no longer be present |
|
18 assert.ok(!('packaging' in global), "no 'packaging', good"); |
|
19 assert.ok(!('memory' in global), "no 'memory', good"); |
|
20 assert.ok(/test-globals\.js$/.test(module.uri), |
|
21 'should contain filename'); |
|
22 }; |
|
23 |
|
24 exports.testComponent = function (assert) { |
|
25 assert.throws(() => { |
|
26 Components; |
|
27 }, /`Components` is not available/, 'using `Components` throws'); |
|
28 }; |
|
29 |
|
30 require('test').run(exports); |