main.js 1.2 KB

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