addon-sdk/source/lib/sdk/system/globals.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:46c8b1013969
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
5 "use strict";
6
7 module.metadata = {
8 "stability": "unstable"
9 };
10
11 let { Cc, Ci, CC } = require('chrome');
12 let { PlainTextConsole } = require('../console/plain-text');
13 let { stdout } = require('../system');
14 let ScriptError = CC('@mozilla.org/scripterror;1', 'nsIScriptError');
15 let consoleService = Cc['@mozilla.org/consoleservice;1'].getService().
16 QueryInterface(Ci.nsIConsoleService);
17
18 // On windows dump does not writes into stdout so cfx can't read thous dumps.
19 // To workaround this issue we write to a special file from which cfx will
20 // read and print to the console.
21 // For more details see: bug-673383
22 exports.dump = stdout.write;
23
24 exports.console = new PlainTextConsole();
25
26 // Provide CommonJS `define` to allow authoring modules in a format that can be
27 // loaded both into jetpack and into browser via AMD loaders.
28 Object.defineProperty(exports, 'define', {
29 // `define` is provided as a lazy getter that binds below defined `define`
30 // function to the module scope, so that require, exports and module
31 // variables remain accessible.
32 configurable: true,
33 get: function() {
34 let sandbox = this;
35 return function define(factory) {
36 factory = Array.slice(arguments).pop();
37 factory.call(sandbox, sandbox.require, sandbox.exports, sandbox.module);
38 }
39 }
40 });

mercurial