summaryrefslogtreecommitdiffstats
path: root/addon-sdk/test
diff options
context:
space:
mode:
Diffstat (limited to 'addon-sdk/test')
-rw-r--r--addon-sdk/test/Math.jsm11
-rw-r--r--addon-sdk/test/browser.ini14
-rw-r--r--addon-sdk/test/browser_sdk_loader_chrome.js24
-rw-r--r--addon-sdk/test/browser_sdk_loader_chrome_in_sdk.js19
-rw-r--r--addon-sdk/test/browser_sdk_loader_js_modules.js33
-rw-r--r--addon-sdk/test/browser_sdk_loader_jsm_modules.js31
-rw-r--r--addon-sdk/test/browser_sdk_loader_json.js23
-rw-r--r--addon-sdk/test/browser_sdk_loader_sdk_gui_modules.js18
-rw-r--r--addon-sdk/test/browser_sdk_loader_sdk_modules.js22
-rw-r--r--addon-sdk/test/data.json6
-rw-r--r--addon-sdk/test/head.js79
-rw-r--r--addon-sdk/test/invalid.json1
-rw-r--r--addon-sdk/test/math.js7
13 files changed, 0 insertions, 288 deletions
diff --git a/addon-sdk/test/Math.jsm b/addon-sdk/test/Math.jsm
deleted file mode 100644
index 095f338e1..000000000
--- a/addon-sdk/test/Math.jsm
+++ /dev/null
@@ -1,11 +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";
-
-this.EXPORTED_SYMBOLS = ["Math"];
-
-this.Math = {
- square: function (x) { return x * x; }
-};
diff --git a/addon-sdk/test/browser.ini b/addon-sdk/test/browser.ini
deleted file mode 100644
index 213698bf8..000000000
--- a/addon-sdk/test/browser.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[DEFAULT]
-support-files =
- head.js
- Math.jsm
- math.js
- data.json
- invalid.json
-[browser_sdk_loader_sdk_modules.js]
-[browser_sdk_loader_sdk_gui_modules.js]
-[browser_sdk_loader_jsm_modules.js]
-[browser_sdk_loader_js_modules.js]
-[browser_sdk_loader_json.js]
-[browser_sdk_loader_chrome.js]
-[browser_sdk_loader_chrome_in_sdk.js]
diff --git a/addon-sdk/test/browser_sdk_loader_chrome.js b/addon-sdk/test/browser_sdk_loader_chrome.js
deleted file mode 100644
index d1794dbab..000000000
--- a/addon-sdk/test/browser_sdk_loader_chrome.js
+++ /dev/null
@@ -1,24 +0,0 @@
-function test () {
- let loader = makeLoader();
- let module = Module("./main", gTestPath);
- let require = Require(loader, module);
-
- const { Ci, Cc, Cu, components } = require("chrome");
-
- let { generateUUID } = Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator);
- ok(isUUID(generateUUID()), "chrome.Cc and chrome.Ci works");
-
- let { ID: parseUUID } = components;
- let uuidString = "00001111-2222-3333-4444-555566667777";
- let parsed = parseUUID(uuidString);
- is(parsed, "{" + uuidString + "}", "chrome.components works");
-
- const { defer } = Cu.import("resource://gre/modules/Promise.jsm").Promise;
- let { promise, resolve } = defer();
- resolve(5);
- promise.then(val => {
- is(val, 5, "chrome.Cu works");
- finish();
- });
-}
diff --git a/addon-sdk/test/browser_sdk_loader_chrome_in_sdk.js b/addon-sdk/test/browser_sdk_loader_chrome_in_sdk.js
deleted file mode 100644
index 02a8c5286..000000000
--- a/addon-sdk/test/browser_sdk_loader_chrome_in_sdk.js
+++ /dev/null
@@ -1,19 +0,0 @@
-function test () {
- let loader = makeLoader();
- let module = Module("./main", gTestPath);
- let require = Require(loader, module);
-
- // sdk/util/uuid uses Cc, Ci, components
- const { uuid } = require("sdk/util/uuid");
-
- ok(isUUID(uuid()), "chrome.Cc and chrome.Ci works in SDK includes");
-
- let uuidString = '00001111-2222-3333-4444-555566667777';
- let parsed = uuid(uuidString);
- is(parsed, '{' + uuidString + '}', "chrome.components works in SDK includes");
-
- // sdk/base64 uses Cu
- const { encode } = require("sdk/base64");
- is(encode("hello"), "aGVsbG8=", "chrome.Cu works in SDK includes");
- finish();
-}
diff --git a/addon-sdk/test/browser_sdk_loader_js_modules.js b/addon-sdk/test/browser_sdk_loader_js_modules.js
deleted file mode 100644
index 561695903..000000000
--- a/addon-sdk/test/browser_sdk_loader_js_modules.js
+++ /dev/null
@@ -1,33 +0,0 @@
-function test () {
- let loader = makeLoader();
- let module = Module("./main", gTestPath);
- let require = Require(loader, module);
-
- try {
- let Model = require("./cant-find-me");
- ok(false, "requiring a JS module that doesn't exist should throw");
- }
- catch (e) {
- ok(e, "requiring a JS module that doesn't exist should throw");
- }
-
-
- /*
- * Relative resource:// URI of JS
- */
-
- let { square } = require("./math");
- is(square(5), 25, "loads relative URI of JS");
-
- /*
- * Absolute resource:// URI of JS
- */
-
- let { has } = require("resource://gre/modules/commonjs/sdk/util/array");
- let testArray = ['rock', 'paper', 'scissors'];
-
- ok(has(testArray, 'rock'), "loads absolute resource:// URI of JS");
- ok(!has(testArray, 'dragon'), "loads absolute resource:// URI of JS");
-
- finish();
-}
diff --git a/addon-sdk/test/browser_sdk_loader_jsm_modules.js b/addon-sdk/test/browser_sdk_loader_jsm_modules.js
deleted file mode 100644
index 97dea9c11..000000000
--- a/addon-sdk/test/browser_sdk_loader_jsm_modules.js
+++ /dev/null
@@ -1,31 +0,0 @@
-function test () {
- let loader = makeLoader();
- let module = Module("./main", gTestPath);
- let require = Require(loader, module);
-
- try {
- let Model = require("resource://gre/modules/BlinkTag.jsm");
- ok(false, "requiring a JS module that doesn't exist should throw");
- }
- catch (e) {
- ok(e, "requiring a JS module that doesn't exist should throw");
- }
-
- /*
- * Relative resource:// URI of JSM
- */
-
- let { square } = require("./Math.jsm").Math;
- is(square(5), 25, "loads relative URI of JSM");
-
- /*
- * Absolute resource:// URI of JSM
- */
- let { defer } = require("resource://gre/modules/Promise.jsm").Promise;
- let { resolve, promise } = defer();
- resolve(5);
- promise.then(val => {
- is(val, 5, "loads absolute resource:// URI of JSM");
- }).then(finish);
-
-}
diff --git a/addon-sdk/test/browser_sdk_loader_json.js b/addon-sdk/test/browser_sdk_loader_json.js
deleted file mode 100644
index 19f92cecd..000000000
--- a/addon-sdk/test/browser_sdk_loader_json.js
+++ /dev/null
@@ -1,23 +0,0 @@
-function test () {
- let loader = makeLoader();
- let module = Module("./main", gTestPath);
- let require = Require(loader, module);
-
- /*
- * Relative resource:// URI of json
- */
-
- let data = require("./data.json");
- is(data.title, "jetpack mochitests", "loads relative JSON");
- is(data.dependencies.underscore, "1.0.0", "loads relative JSON");
-
- try {
- let data = require("./invalid.json");
- ok(false, "parsing an invalid JSON should throw");
- }
- catch (e) {
- ok(e, "parsing an invalid JSON should throw");
- }
-
- finish();
-}
diff --git a/addon-sdk/test/browser_sdk_loader_sdk_gui_modules.js b/addon-sdk/test/browser_sdk_loader_sdk_gui_modules.js
deleted file mode 100644
index 965dd81ee..000000000
--- a/addon-sdk/test/browser_sdk_loader_sdk_gui_modules.js
+++ /dev/null
@@ -1,18 +0,0 @@
-function test () {
- // Load `constructor` as global since tabs uses `traits`
- // that use this module
- let loader = makeLoader({ globals: constructor });
- let module = Module("./main", "scratchpad://");
- let require = Require(loader, module);
-
- let tabs = require("sdk/tabs");
-
- tabs.open({
- url: "about:blank",
- onReady: function (tab) {
- is(tab.url, "about:blank", "correct uri for tab");
- is(tabs.activeTab, tab, "correctly active tab");
- tab.close(finish);
- }
- });
-}
diff --git a/addon-sdk/test/browser_sdk_loader_sdk_modules.js b/addon-sdk/test/browser_sdk_loader_sdk_modules.js
deleted file mode 100644
index 420633235..000000000
--- a/addon-sdk/test/browser_sdk_loader_sdk_modules.js
+++ /dev/null
@@ -1,22 +0,0 @@
-function test () {
- let loader = makeLoader();
- let module = Module("./main", "scratchpad://");
- let require = Require(loader, module);
-
- let { has } = require("sdk/util/array");
- let { extend } = require("sdk/util/object");
- let testArray = [1, 'hello', 2, 'hi'];
-
- ok(has(testArray, 1), 'loader loading simple array utils');
- ok(has(testArray, 'hello'), 'loader loading simple array utils');
- ok(!has(testArray, 4), 'loader loading simple array utils');
-
- let testObj1 = { strings: 6, prop: [] };
- let testObj2 = { name: 'Tosin Abasi', strings: 8 };
- let extended = extend(testObj1, testObj2);
-
- is(extended.name, 'Tosin Abasi', 'loader loading simple object utils');
- is(extended.strings, 8, 'loader loading simple object utils');
- is(extended.prop, testObj1.prop, 'loader loading simple object utils');
- finish();
-}
diff --git a/addon-sdk/test/data.json b/addon-sdk/test/data.json
deleted file mode 100644
index cb2aade75..000000000
--- a/addon-sdk/test/data.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "title": "jetpack mochitests",
- "dependencies": {
- "underscore": "1.0.0"
- }
-}
diff --git a/addon-sdk/test/head.js b/addon-sdk/test/head.js
deleted file mode 100644
index 2afb673e7..000000000
--- a/addon-sdk/test/head.js
+++ /dev/null
@@ -1,79 +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/. */
-
-const { utils: Cu } = Components;
-const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
-const LoaderModule = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {}).Loader;
-const { console } = Cu.import("resource://gre/modules/Console.jsm", {});
-var {
- Loader, main, Module, Require, unload
-} = LoaderModule;
-
-var CURRENT_DIR = gTestPath.replace(/\/[^\/]*\.js$/,'/');
-var loaders = [];
-
-// All tests are asynchronous.
-waitForExplicitFinish();
-
-var gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
-Services.prefs.setBoolPref("devtools.debugger.log", true);
-
-registerCleanupFunction(() => {
- info("finish() was called, cleaning up...");
- loaders.forEach(unload);
- Services.prefs.setBoolPref("devtools.debugger.log", gEnableLogging);
-});
-
-function makePaths (root) {
- return {
- './': CURRENT_DIR,
- '': 'resource://gre/modules/commonjs/'
- };
-}
-
-function makeLoader (options) {
- let { paths, globals } = options || {};
-
- // We have to have `console` as a global, otherwise
- // many SDK modules will fail
- // bug 961252
- let globalDefaults = {
- console: console
- };
-
- let loader = Loader({
- paths: paths || makePaths(),
- globals: extend({}, globalDefaults, globals) || null,
- modules: {
- // Needed because sdk/ modules reference utilities in
- // `toolkit/loader`, until Bug 961194 is completed
- 'toolkit/loader': LoaderModule
- },
- // We need rootURI due to `sdk/self` (or are using native loader)
- // which overloads with pseudo modules
- // bug 961245
- rootURI: CURRENT_DIR,
- // We also need metadata dummy object
- // bug 961245
- metadata: {}
- });
-
- loaders.push(loader);
- return loader;
-}
-
-function isUUID (string) {
- return /^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$/.test(string);
-}
-
-function extend (...objs) {
- if (objs.length === 0 || objs.length === 1)
- return objs[0] || {};
-
- for (let i = objs.length; i > 1; i--) {
- for (var prop in objs[i - 1])
- objs[0][prop] = objs[i - 1][prop];
- }
- return objs[0];
-}
diff --git a/addon-sdk/test/invalid.json b/addon-sdk/test/invalid.json
deleted file mode 100644
index 9f2553815..000000000
--- a/addon-sdk/test/invalid.json
+++ /dev/null
@@ -1 +0,0 @@
-this isnt json
diff --git a/addon-sdk/test/math.js b/addon-sdk/test/math.js
deleted file mode 100644
index 1e89ad77e..000000000
--- a/addon-sdk/test/math.js
+++ /dev/null
@@ -1,7 +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";
-
-exports.square = function square (x) { return x * x; }