aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.5/packages/api-utils/tests/test-globals.js
blob: f8375eb9e2d9cc687e5f02a4097e31e4e6c7a33c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Object.defineProperty(this, "global", { value: this });

exports.testGlobals = function(test) {
  // the only globals in module scope should be:
  //   module, exports, require, dump, console
  test.assertObject(module, "have 'module', good");
  test.assertObject(exports, "have 'exports', good");
  test.assertFunction(require, "have 'require', good");
  test.assertFunction(dump, "have 'dump', good");
  test.assertObject(console, "have 'console', good");

  // in particular, these old globals should no longer be present
  test.assert(!('packaging' in global), "no 'packaging', good");
  // this will be fixed by bug 620559
  test.expectFail(function() {
    test.assert(!('memory' in global), "no 'memory', good");
  });

  test.assertMatches(module.uri, /test-globals\.js$/,
                     'should contain filename');
};