|
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 |
|
6 const { setTimeout } = require('sdk/timers'); |
|
7 |
|
8 let mainStarted = false; |
|
9 |
|
10 exports.main = function main(options, callbacks) { |
|
11 mainStarted = true; |
|
12 |
|
13 let tests = {}; |
|
14 |
|
15 tests.testMainArguments = function(assert) { |
|
16 assert.ok(!!options, 'options argument provided to main'); |
|
17 assert.ok('loadReason' in options, 'loadReason is in options provided by main'); |
|
18 assert.equal(typeof callbacks.print, 'function', 'callbacks.print is a function'); |
|
19 assert.equal(typeof callbacks.quit, 'function', 'callbacks.quit is a function'); |
|
20 assert.equal(options.loadReason, 'install', 'options.loadReason is install'); |
|
21 } |
|
22 |
|
23 require('sdk/test/runner').runTestsFromModule({exports: tests}); |
|
24 } |
|
25 |
|
26 // this causes a fail if main does not start |
|
27 setTimeout(function() { |
|
28 if (mainStarted) |
|
29 return; |
|
30 |
|
31 // main didn't start, fail.. |
|
32 require("sdk/test/runner").runTestsFromModule({exports: { |
|
33 testFail: function(assert) assert.fail('Main did not start..') |
|
34 }}); |
|
35 }, 500); |