summaryrefslogtreecommitdiffstats
path: root/addon-sdk/source/test/addons/simple-prefs-regression/lib/main.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-09 06:46:43 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-09 06:46:43 -0500
commitac46df8daea09899ce30dc8fd70986e258c746bf (patch)
tree2750d3125fc253fd5b0671e4bd268eff1fd97296 /addon-sdk/source/test/addons/simple-prefs-regression/lib/main.js
parent8cecf8d5208f3945b35f879bba3015bb1a11bec6 (diff)
downloadUXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.gz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.lz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.tar.xz
UXP-ac46df8daea09899ce30dc8fd70986e258c746bf.zip
Move Add-on SDK source to toolkit/jetpack
Diffstat (limited to 'addon-sdk/source/test/addons/simple-prefs-regression/lib/main.js')
-rw-r--r--addon-sdk/source/test/addons/simple-prefs-regression/lib/main.js94
1 files changed, 0 insertions, 94 deletions
diff --git a/addon-sdk/source/test/addons/simple-prefs-regression/lib/main.js b/addon-sdk/source/test/addons/simple-prefs-regression/lib/main.js
deleted file mode 100644
index 757759dcb..000000000
--- a/addon-sdk/source/test/addons/simple-prefs-regression/lib/main.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-'use strict';
-
-const { Cu } = require('chrome');
-const sp = require('sdk/simple-prefs');
-const app = require('sdk/system/xul-app');
-const tabs = require('sdk/tabs');
-const { preferencesBranch, id } = require('sdk/self');
-const { getAddonByID } = require('sdk/addon/manager');
-const { AddonManager } = Cu.import('resource://gre/modules/AddonManager.jsm', {});
-
-exports.testRegression = (assert) => {
- assert.equal(preferencesBranch, id, 'preferencesBranch returns id here');
-}
-
-exports.testDefaultValues = (assert) => {
- assert.equal(sp.prefs.myHiddenInt, 5, 'myHiddenInt default is 5');
- assert.equal(sp.prefs.myInteger, 8, 'myInteger default is 8');
- assert.equal(sp.prefs.somePreference, 'TEST', 'somePreference default is correct');
-}
-
-exports.testOptionsType = function*(assert) {
- let addon = yield getAddonByID(id);
- assert.equal(addon.optionsType, AddonManager.OPTIONS_TYPE_INLINE, 'options type is inline');
-}
-
-if (app.is('Firefox')) {
- exports.testAOM = function(assert, done) {
- tabs.open({
- url: 'about:addons',
- onReady: function(tab) {
- tab.attach({
- contentScriptWhen: 'end',
- contentScript: 'function onLoad() {\n' +
- 'unsafeWindow.removeEventListener("load", onLoad, false);\n' +
- 'AddonManager.getAddonByID("' + id + '", function(aAddon) {\n' +
- 'unsafeWindow.gViewController.viewObjects.detail.node.addEventListener("ViewChanged", function whenViewChanges() {\n' +
- 'unsafeWindow.gViewController.viewObjects.detail.node.removeEventListener("ViewChanged", whenViewChanges, false);\n' +
- 'setTimeout(function() {\n' + // TODO: figure out why this is necessary..
- 'self.postMessage({\n' +
- 'somePreference: getAttributes(unsafeWindow.document.querySelector("setting[title=\'some-title\']")),\n' +
- 'myInteger: getAttributes(unsafeWindow.document.querySelector("setting[title=\'my-int\']")),\n' +
- 'myHiddenInt: getAttributes(unsafeWindow.document.querySelector("setting[title=\'hidden-int\']"))\n' +
- '});\n' +
- '}, 250);\n' +
- '}, false);\n' +
- 'unsafeWindow.gViewController.commands.cmd_showItemDetails.doCommand(aAddon, true);\n' +
- '});\n' +
- 'function getAttributes(ele) {\n' +
- 'if (!ele) return {};\n' +
- 'return {\n' +
- 'pref: ele.getAttribute("pref"),\n' +
- 'type: ele.getAttribute("type"),\n' +
- 'title: ele.getAttribute("title"),\n' +
- 'desc: ele.getAttribute("desc")\n' +
- '}\n' +
- '}\n' +
- '}\n' +
- // Wait for the load event ?
- 'if (document.readyState == "complete") {\n' +
- 'onLoad()\n' +
- '} else {\n' +
- 'unsafeWindow.addEventListener("load", onLoad, false);\n' +
- '}\n',
- onMessage: function(msg) {
- // test somePreference
- assert.equal(msg.somePreference.type, 'string', 'some pref is a string');
- assert.equal(msg.somePreference.pref, 'extensions.'+preferencesBranch+'.somePreference', 'somePreference path is correct');
- assert.equal(msg.somePreference.title, 'some-title', 'somePreference title is correct');
- assert.equal(msg.somePreference.desc, 'Some short description for the preference', 'somePreference description is correct');
-
- // test myInteger
- assert.equal(msg.myInteger.type, 'integer', 'myInteger is a int');
- assert.equal(msg.myInteger.pref, 'extensions.'+preferencesBranch+'.myInteger', 'extensions.test-simple-prefs.myInteger');
- assert.equal(msg.myInteger.title, 'my-int', 'myInteger title is correct');
- assert.equal(msg.myInteger.desc, 'How many of them we have.', 'myInteger desc is correct');
-
- // test myHiddenInt
- assert.equal(msg.myHiddenInt.type, undefined, 'myHiddenInt was not displayed');
- assert.equal(msg.myHiddenInt.pref, undefined, 'myHiddenInt was not displayed');
- assert.equal(msg.myHiddenInt.title, undefined, 'myHiddenInt was not displayed');
- assert.equal(msg.myHiddenInt.desc, undefined, 'myHiddenInt was not displayed');
-
- tab.close(done);
- }
- });
- }
- });
- }
-}
-
-require('sdk/test/runner').runTestsFromModule(module);