test-globals.js 1.2 KB

123456789101112131415161718192021222324252627282930
  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. Object.defineProperty(this, 'global', { value: this });
  6. exports.testGlobals = function(assert) {
  7. // the only globals in module scope should be:
  8. // module, exports, require, dump, console
  9. assert.equal(typeof module, 'object', 'have "module", good');
  10. assert.equal(typeof exports, 'object', 'have "exports", good');
  11. assert.equal(typeof require, 'function', 'have "require", good');
  12. assert.equal(typeof dump, 'function', 'have "dump", good');
  13. assert.equal(typeof console, 'object', 'have "console", good');
  14. // in particular, these old globals should no longer be present
  15. assert.ok(!('packaging' in global), "no 'packaging', good");
  16. assert.ok(!('memory' in global), "no 'memory', good");
  17. assert.ok(/test-globals\.js$/.test(module.uri),
  18. 'should contain filename');
  19. };
  20. exports.testComponent = function (assert) {
  21. assert.throws(() => {
  22. Components;
  23. }, /`Components` is not available/, 'using `Components` throws');
  24. };
  25. require('test').run(exports);