michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: module.metadata = { michael@0: "stability": "unstable" michael@0: }; michael@0: michael@0: let { Cc, Ci, CC } = require('chrome'); michael@0: let { PlainTextConsole } = require('../console/plain-text'); michael@0: let { stdout } = require('../system'); michael@0: let ScriptError = CC('@mozilla.org/scripterror;1', 'nsIScriptError'); michael@0: let consoleService = Cc['@mozilla.org/consoleservice;1'].getService(). michael@0: QueryInterface(Ci.nsIConsoleService); michael@0: michael@0: // On windows dump does not writes into stdout so cfx can't read thous dumps. michael@0: // To workaround this issue we write to a special file from which cfx will michael@0: // read and print to the console. michael@0: // For more details see: bug-673383 michael@0: exports.dump = stdout.write; michael@0: michael@0: exports.console = new PlainTextConsole(); michael@0: michael@0: // Provide CommonJS `define` to allow authoring modules in a format that can be michael@0: // loaded both into jetpack and into browser via AMD loaders. michael@0: Object.defineProperty(exports, 'define', { michael@0: // `define` is provided as a lazy getter that binds below defined `define` michael@0: // function to the module scope, so that require, exports and module michael@0: // variables remain accessible. michael@0: configurable: true, michael@0: get: function() { michael@0: let sandbox = this; michael@0: return function define(factory) { michael@0: factory = Array.slice(arguments).pop(); michael@0: factory.call(sandbox, sandbox.require, sandbox.exports, sandbox.module); michael@0: } michael@0: } michael@0: });