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 { id, preferencesBranch } = require('sdk/self');
  6. const simple = require('sdk/simple-prefs');
  7. const service = require('sdk/preferences/service');
  8. const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm');
  9. exports.testPreferencesBranch = function(assert) {
  10. assert.equal(preferencesBranch, 'human-readable', 'preferencesBranch is human-readable');
  11. assert.equal(simple.prefs.test42, true, 'test42 is true');
  12. simple.prefs.test43 = 'movie';
  13. assert.equal(service.get('extensions.human-readable.test43'), 'movie', 'test43 is a movie');
  14. }
  15. // from `/test/test-self.js`, adapted to `sdk/test/assert` API
  16. exports.testSelfID = function(assert, done) {
  17. assert.equal(typeof(id), 'string', 'self.id is a string');
  18. assert.ok(id.length > 0, 'self.id not empty');
  19. AddonManager.getAddonByID(id, function(addon) {
  20. assert.ok(addon, 'found addon with self.id');
  21. done();
  22. });
  23. }
  24. require('sdk/test/runner').runTestsFromModule(module);