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: 'use strict'; michael@0: michael@0: const { setTimeout } = require('sdk/timers'); michael@0: michael@0: let mainStarted = false; michael@0: michael@0: exports.main = function main(options, callbacks) { michael@0: mainStarted = true; michael@0: michael@0: let tests = {}; michael@0: michael@0: tests.testMainArguments = function(assert) { michael@0: assert.ok(!!options, 'options argument provided to main'); michael@0: assert.ok('loadReason' in options, 'loadReason is in options provided by main'); michael@0: assert.equal(typeof callbacks.print, 'function', 'callbacks.print is a function'); michael@0: assert.equal(typeof callbacks.quit, 'function', 'callbacks.quit is a function'); michael@0: assert.equal(options.loadReason, 'install', 'options.loadReason is install'); michael@0: } michael@0: michael@0: require('sdk/test/runner').runTestsFromModule({exports: tests}); michael@0: } michael@0: michael@0: // this causes a fail if main does not start michael@0: setTimeout(function() { michael@0: if (mainStarted) michael@0: return; michael@0: michael@0: // main didn't start, fail.. michael@0: require("sdk/test/runner").runTestsFromModule({exports: { michael@0: testFail: function(assert) assert.fail('Main did not start..') michael@0: }}); michael@0: }, 500);