diff --git a/addon-sdk/moz.build b/addon-sdk/moz.build
index 2186e00d258..d83cb209c4f 100644
--- a/addon-sdk/moz.build
+++ b/addon-sdk/moz.build
@@ -29,7 +29,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != "gonk":
EXTRA_JS_MODULES.commonjs.sdk.deprecated += [
'source/lib/sdk/deprecated/api-utils.js',
- 'source/lib/sdk/deprecated/memory.js',
'source/lib/sdk/deprecated/sync-worker.js',
'source/lib/sdk/deprecated/unit-test-finder.js',
'source/lib/sdk/deprecated/unit-test.js',
@@ -258,6 +257,10 @@ EXTRA_JS_MODULES.commonjs.sdk.content += [
'source/lib/sdk/content/worker.js',
]
+EXTRA_JS_MODULES.commonjs.sdk.content.sandbox += [
+ 'source/lib/sdk/content/sandbox/events.js',
+]
+
EXTRA_JS_MODULES.commonjs.sdk['context-menu'] += [
'source/lib/sdk/context-menu/context.js',
'source/lib/sdk/context-menu/core.js',
@@ -307,7 +310,6 @@ EXTRA_JS_MODULES.commonjs.sdk.input += [
EXTRA_JS_MODULES.commonjs.sdk.io += [
'source/lib/sdk/io/buffer.js',
'source/lib/sdk/io/byte-streams.js',
- 'source/lib/sdk/io/data.js',
'source/lib/sdk/io/file.js',
'source/lib/sdk/io/fs.js',
'source/lib/sdk/io/stream.js',
@@ -453,7 +455,6 @@ EXTRA_JS_MODULES.commonjs.sdk.url += [
EXTRA_JS_MODULES.commonjs.sdk.util += [
'source/lib/sdk/util/array.js',
- 'source/lib/sdk/util/bond.js',
'source/lib/sdk/util/collection.js',
'source/lib/sdk/util/contract.js',
'source/lib/sdk/util/deprecate.js',
diff --git a/addon-sdk/source/.travis.yml b/addon-sdk/source/.travis.yml
index d74bec24014..287b62a4f8b 100644
--- a/addon-sdk/source/.travis.yml
+++ b/addon-sdk/source/.travis.yml
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- - "0.10"
+ - "0.12"
env:
- JPM_FX_DEBUG=0
diff --git a/addon-sdk/source/bin/jpm-test.js b/addon-sdk/source/bin/jpm-test.js
index cc06e8c3217..f22a552ea7b 100644
--- a/addon-sdk/source/bin/jpm-test.js
+++ b/addon-sdk/source/bin/jpm-test.js
@@ -17,12 +17,13 @@ exports.run = function(type) {
return new Promise(function(resolve) {
type = type || "";
[
- (!isDebug && /^(modules)?$/.test(type)) && require.resolve("../bin/node-scripts/test.modules"),
- (!isDebug && /^(addons)?$/.test(type)) && require.resolve("../bin/node-scripts/test.addons"),
- (/^(examples)?$/.test(type)) && require.resolve("../bin/node-scripts/test.examples"),
+ (!isDebug && /^(firefox-bin)?$/.test(type)) && require.resolve("../bin/node-scripts/test.firefox-bin"),
(!isDebug && /^(docs)?$/.test(type)) && require.resolve("../bin/node-scripts/test.docs"),
(!isDebug && /^(ini)?$/.test(type)) && require.resolve("../bin/node-scripts/test.ini"),
- ].sort().forEach(function(filepath) {
+ (/^(examples)?$/.test(type)) && require.resolve("../bin/node-scripts/test.examples"),
+ (!isDebug && /^(addons)?$/.test(type)) && require.resolve("../bin/node-scripts/test.addons"),
+ (!isDebug && /^(modules)?$/.test(type)) && require.resolve("../bin/node-scripts/test.modules"),
+ ].forEach(function(filepath) {
filepath && mocha.addFile(filepath);
})
diff --git a/addon-sdk/source/bin/node-scripts/test.firefox-bin.js b/addon-sdk/source/bin/node-scripts/test.firefox-bin.js
new file mode 100644
index 00000000000..2570dae20f8
--- /dev/null
+++ b/addon-sdk/source/bin/node-scripts/test.firefox-bin.js
@@ -0,0 +1,37 @@
+/* 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";
+
+var fs = require("fs");
+var Promise = require("promise");
+var chai = require("chai");
+var expect = chai.expect;
+var normalizeBinary = require("fx-runner/lib/utils").normalizeBinary;
+
+//var firefox_binary = process.env["JPM_FIREFOX_BINARY"] || normalizeBinary("nightly");
+
+describe("Checking Firefox binary", function () {
+
+ it("using matching fx-runner version with jpm", function () {
+ var sdkPackageJSON = require("../../package.json");
+ var jpmPackageINI = require("jpm/package.json");
+ expect(sdkPackageJSON.devDependencies["fx-runner"]).to.be.equal(jpmPackageINI.dependencies["fx-runner"]);
+ });
+
+ it("exists", function (done) {
+ var useEnvVar = new Promise(function(resolve) {
+ resolve(process.env["JPM_FIREFOX_BINARY"]);
+ });
+
+ var firefox_binary = process.env["JPM_FIREFOX_BINARY"] ? useEnvVar : normalizeBinary("nightly");
+ firefox_binary.then(function(path) {
+ expect(path).to.be.ok;
+ fs.exists(path, function (exists) {
+ expect(exists).to.be.ok;
+ done();
+ });
+ })
+ });
+
+});
diff --git a/addon-sdk/source/bin/node-scripts/test.ini.js b/addon-sdk/source/bin/node-scripts/test.ini.js
index 5b8f76e7af8..07bd15d1fde 100644
--- a/addon-sdk/source/bin/node-scripts/test.ini.js
+++ b/addon-sdk/source/bin/node-scripts/test.ini.js
@@ -11,6 +11,7 @@ var expect = chai.expect;
var ini = require("./update-ini");
var addonINI = path.resolve("./test/addons/jetpack-addon.ini");
+var packageINI = path.resolve("./test/jetpack-package.ini");
describe("Checking ini files", function () {
@@ -20,7 +21,10 @@ describe("Checking ini files", function () {
if (err) {
throw err;
}
- var text = data.toString();
+ // filter comments
+ var text = data.toString().split("\n").filter(function(line) {
+ return !/^\s*#/.test(line);
+ }).join("\n");
var expected = "";
ini.makeAddonIniContent()
@@ -28,7 +32,32 @@ describe("Checking ini files", function () {
expected = contents;
setTimeout(function end() {
- expect(expected.trim()).to.be.equal(text.trim());
+ expect(text.trim()).to.be.equal(expected.trim());
+ done();
+ });
+ });
+ });
+
+ });
+
+ it("Check test/jetpack-package.ini", function (done) {
+
+ fs.readFile(packageINI, function (err, data) {
+ if (err) {
+ throw err;
+ }
+ // filter comments
+ var text = data.toString().split("\n").filter(function(line) {
+ return !/^\s*#/.test(line);
+ }).join("\n");
+ var expected = "";
+
+ ini.makePackageIniContent()
+ .then(function(contents) {
+ expected = contents;
+
+ setTimeout(function end() {
+ expect(text.trim()).to.be.equal(expected.trim());
done();
});
});
diff --git a/addon-sdk/source/bin/node-scripts/update-ini.js b/addon-sdk/source/bin/node-scripts/update-ini.js
index 250d7da01dd..634cbc1de72 100644
--- a/addon-sdk/source/bin/node-scripts/update-ini.js
+++ b/addon-sdk/source/bin/node-scripts/update-ini.js
@@ -11,6 +11,14 @@ var parser = require("ini-parser");
var addonINI = path.resolve("./test/addons/jetpack-addon.ini");
var addonsDir = path.resolve("./test/addons/");
+var packageINI = path.resolve("./test/jetpack-package.ini");
+var packageDir = path.resolve("./test/");
+var packageIgnorables = [ "addons", "preferences" ];
+var packageSupportFiles = [
+ "fixtures.js",
+ "test-context-menu.html",
+ "util.js"
+]
function updateAddonINI() {
return new Promise(function(resolve) {
@@ -32,16 +40,18 @@ function makeAddonIniContent() {
var result = {};
fs.readdir(addonsDir, function(err, files) {
+ // get a list of folders
var folders = files.filter(function(file) {
return fs.statSync(path.resolve(addonsDir, file)).isDirectory();
}).sort();
+ // copy any related data from the existing ini
folders.forEach(function(folder) {
var oldData = data[folder + ".xpi"];
result[folder] = oldData ? oldData : {};
});
- // build ini file
+ // build a new ini file
var contents = [];
Object.keys(result).sort().forEach(function(key) {
contents.push("[" + key + ".xpi]");
@@ -56,3 +66,76 @@ function makeAddonIniContent() {
});
}
exports.makeAddonIniContent = makeAddonIniContent;
+
+function makePackageIniContent() {
+ return new Promise(function(resolve) {
+ var data = parser.parse(fs.readFileSync(packageINI, { encoding: "utf8" }).toString());
+ var result = {};
+
+ fs.readdir(packageDir, function(err, files) {
+ // get a list of folders
+ var folders = files.filter(function(file) {
+ var ignore = (packageIgnorables.indexOf(file) >= 0);
+ var isDir = fs.statSync(path.resolve(packageDir, file)).isDirectory();
+ return (isDir && !ignore);
+ }).sort();
+
+ // get a list of "test-"" files
+ var files = files.filter(function(file) {
+ var ignore = !/^test\-.*\.js$/i.test(file);
+ var isDir = fs.statSync(path.resolve(packageDir, file)).isDirectory();
+ return (!isDir && !ignore);
+ }).sort();
+
+ // get a list of the support files
+ var support_files = packageSupportFiles.map(function(file) {
+ return " " + file;
+ });
+ folders.forEach(function(folder) {
+ support_files.push(" " + folder + "/**");
+ });
+ support_files = support_files.sort();
+
+ // copy any related data from the existing ini
+ files.forEach(function(file) {
+ var oldData = data[file];
+ result[file] = oldData ? oldData : {};
+ });
+
+ // build a new ini file
+ var contents = [
+ "[DEFAULT]",
+ "support-files ="
+ ];
+ support_files.forEach(function(support_file) {
+ contents.push(support_file);
+ });
+ contents.push("");
+
+ Object.keys(result).sort().forEach(function(key) {
+ contents.push("[" + key + "]");
+ Object.keys(result[key]).forEach(function(dataKey) {
+ contents.push(dataKey + " = " + result[key][dataKey]);
+ });
+ });
+ contents = contents.join("\n") + "\n";
+
+ return resolve(contents);
+ });
+ });
+}
+exports.makePackageIniContent = makePackageIniContent;
+
+function updatePackageINI() {
+ return new Promise(function(resolve) {
+ console.log("Start updating " + packageINI);
+
+ makeAddonIniContent().
+ then(function(contents) {
+ fs.writeFileSync(packageINI, contents, { encoding: "utf8" });
+ console.log("Done updating " + packageINI);
+ resolve();
+ });
+ })
+}
+exports.updatePackageINI = updatePackageINI;
diff --git a/addon-sdk/source/bin/node-scripts/utils.js b/addon-sdk/source/bin/node-scripts/utils.js
index 9cb47d04e23..1d7f94474cf 100644
--- a/addon-sdk/source/bin/node-scripts/utils.js
+++ b/addon-sdk/source/bin/node-scripts/utils.js
@@ -65,6 +65,9 @@ function run (cmd, options, p) {
if (p) {
proc.stdout.pipe(p.stdout);
}
+ else if (!isDebug) {
+ proc.stdout.pipe(DEFAULT_PROCESS.stdout);
+ }
else {
proc.stdout.on("data", function (data) {
data = (data || "") + "";
diff --git a/addon-sdk/source/gulpfile.js b/addon-sdk/source/gulpfile.js
index 362ef11c362..4020dd9d49e 100644
--- a/addon-sdk/source/gulpfile.js
+++ b/addon-sdk/source/gulpfile.js
@@ -28,7 +28,11 @@ gulp.task('test:modules', function(done) {
});
gulp.task('test:ini', function(done) {
- test("ini").catch(console.error).then(done);
+ require("./bin/jpm-test").run("ini").catch(console.error).then(done);
+});
+
+gulp.task('test:firefox-bin', function(done) {
+ require("./bin/jpm-test").run("firefox-bin").catch(console.error).then(done);
});
gulp.task('patch:clean', function(done) {
@@ -38,7 +42,3 @@ gulp.task('patch:clean', function(done) {
gulp.task('patch:apply', function(done) {
patch.apply().catch(console.error).then(done);
});
-
-gulp.task('update:ini', function(done) {
- ini.updateAddonINI().catch(console.error).then(done);
-});
diff --git a/addon-sdk/source/lib/sdk/console/traceback.js b/addon-sdk/source/lib/sdk/console/traceback.js
index 93e387b2585..be0fb7b94ff 100644
--- a/addon-sdk/source/lib/sdk/console/traceback.js
+++ b/addon-sdk/source/lib/sdk/console/traceback.js
@@ -1,19 +1,16 @@
/* 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";
module.metadata = {
"stability": "experimental"
};
-const { Cc, Ci, components } = require("chrome");
+const { Ci, components } = require("chrome");
const { parseStack, sourceURI } = require("toolkit/loader");
const { readURISync } = require("../net/url");
-exports.sourceURI = sourceURI
-
function safeGetFileLine(path, line) {
try {
var scheme = require("../url").URL(path).scheme;
diff --git a/addon-sdk/source/lib/sdk/content/sandbox.js b/addon-sdk/source/lib/sdk/content/sandbox.js
index 503c48c67c1..4a66eab53b9 100644
--- a/addon-sdk/source/lib/sdk/content/sandbox.js
+++ b/addon-sdk/source/lib/sdk/content/sandbox.js
@@ -10,6 +10,7 @@ module.metadata = {
const { Class } = require('../core/heritage');
const { EventTarget } = require('../event/target');
const { on, off, emit } = require('../event/core');
+const { events } = require('./sandbox/events');
const { requiresAddonGlobal } = require('./utils');
const { delay: async } = require('../lang/functional');
const { Ci, Cu, Cc } = require('chrome');
@@ -20,8 +21,7 @@ const { merge } = require('../util/object');
const { getTabForContentWindow } = require('../tabs/utils');
const { getInnerId } = require('../window/utils');
const { PlainTextConsole } = require('../console/plain-text');
-const { data } = require('../self');
-const { isChildLoader } = require('../remote/core');
+const { data } = require('../self');const { isChildLoader } = require('../remote/core');
// WeakMap of sandboxes so we can access private values
const sandboxes = new WeakMap();
@@ -166,6 +166,7 @@ const WorkerSandbox = Class({
get top() top,
get parent() parent
});
+
// Use the Greasemonkey naming convention to provide access to the
// unwrapped window object so the content script can access document
// JavaScript values.
@@ -261,6 +262,11 @@ const WorkerSandbox = Class({
win.console = con;
};
+ emit(events, "content-script-before-inserted", {
+ window: window,
+ worker: worker
+ });
+
// The order of `contentScriptFile` and `contentScript` evaluation is
// intentional, so programs can load libraries like jQuery from script URLs
// and use them in scripts.
@@ -273,6 +279,7 @@ const WorkerSandbox = Class({
if (contentScriptFile)
importScripts.apply(null, [this].concat(contentScriptFile));
+
if (contentScript) {
evaluateIn(
this,
diff --git a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/tests/test-minimal.js b/addon-sdk/source/lib/sdk/content/sandbox/events.js
similarity index 65%
rename from addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/tests/test-minimal.js
rename to addon-sdk/source/lib/sdk/content/sandbox/events.js
index 533cd34e6fb..d6f7eb00406 100644
--- a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/tests/test-minimal.js
+++ b/addon-sdk/source/lib/sdk/content/sandbox/events.js
@@ -2,6 +2,11 @@
* 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/. */
-exports.minimalTest = function(test) {
- test.assert(true);
+"use strict";
+
+module.metadata = {
+ "stability": "experimental"
};
+
+const events = {};
+exports.events = events;
diff --git a/addon-sdk/source/lib/sdk/deprecated/memory.js b/addon-sdk/source/lib/sdk/deprecated/memory.js
deleted file mode 100644
index b2aa48e888e..00000000000
--- a/addon-sdk/source/lib/sdk/deprecated/memory.js
+++ /dev/null
@@ -1,129 +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";
-
-module.metadata = {
- "stability": "deprecated"
-};
-
-const { Cc, Ci, Cu, components } = require("chrome");
-const { when: unload } = require("../system/unload")
-
-var trackedObjects = {};
-const Compacter = {
- notify: function() {
- var newTrackedObjects = {};
-
- for (let name in trackedObjects) {
- let oldBin = trackedObjects[name];
- let newBin = [];
- let strongRefs = [];
-
- for (let i = 0, l = oldBin.length; i < l; i++) {
- let strongRef = oldBin[i].weakref.get();
-
- if (strongRef && strongRefs.indexOf(strongRef) == -1) {
- strongRefs.push(strongRef);
- newBin.push(oldBin[i]);
- }
- }
-
- if (newBin.length)
- newTrackedObjects[name] = newBin;
- }
-
- trackedObjects = newTrackedObjects;
- }
-};
-
-var timer = Cc["@mozilla.org/timer;1"]
- .createInstance(Ci.nsITimer);
-timer.initWithCallback(Compacter,
- 5000,
- Ci.nsITimer.TYPE_REPEATING_SLACK);
-
-function track(object, bin, stackFrameNumber) {
- var frame = components.stack.caller;
- var weakref = Cu.getWeakReference(object);
-
- if (!bin && 'constructor' in object)
- bin = object.constructor.name;
- if (bin == "Object")
- bin = frame.name;
- if (!bin)
- bin = "generic";
- if (!(bin in trackedObjects))
- trackedObjects[bin] = [];
-
- if (stackFrameNumber > 0)
- for (var i = 0; i < stackFrameNumber; i++)
- frame = frame.caller;
-
- trackedObjects[bin].push({weakref: weakref,
- created: new Date(),
- filename: frame.filename,
- lineNo: frame.lineNumber,
- bin: bin});
-}
-exports.track = track;
-
-var getBins = exports.getBins = function getBins() {
- var names = [];
- for (let name in trackedObjects)
- names.push(name);
- return names;
-};
-
-function getObjects(bin) {
- var results = [];
-
- function getLiveObjectsInBin(bin) {
- for (let i = 0, l = bin.length; i < l; i++) {
- let object = bin[i].weakref.get();
-
- if (object) {
- results.push(bin[i]);
- }
- }
- }
-
- if (bin) {
- if (bin in trackedObjects)
- getLiveObjectsInBin(trackedObjects[bin]);
- }
- else {
- for (let name in trackedObjects)
- getLiveObjectsInBin(trackedObjects[name]);
- }
-
- return results;
-}
-exports.getObjects = getObjects;
-
-function gc() {
- // Components.utils.forceGC() doesn't currently perform
- // cycle collection, which means that e.g. DOM elements
- // won't be collected by it. Fortunately, there are
- // other ways...
- var test_utils = Cc["@mozilla.org/appshell/appShellService;1"]
- .getService(Ci.nsIAppShellService)
- .hiddenDOMWindow
- .QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
- test_utils.garbageCollect();
- // Clean metadata for dead objects
- Compacter.notify();
- // Not sure why, but sometimes it appears that we don't get
- // them all with just one CC, so let's do it again.
- test_utils.garbageCollect();
-};
-exports.gc = gc;
-
-unload(_ => {
- trackedObjects = {};
- if (timer) {
- timer.cancel();
- timer = null;
- }
-});
diff --git a/addon-sdk/source/lib/sdk/deprecated/sync-worker.js b/addon-sdk/source/lib/sdk/deprecated/sync-worker.js
index 225b16ca524..051e25e3fa9 100644
--- a/addon-sdk/source/lib/sdk/deprecated/sync-worker.js
+++ b/addon-sdk/source/lib/sdk/deprecated/sync-worker.js
@@ -30,7 +30,6 @@ const unload = require('../system/unload');
const events = require('../system/events');
const { getInnerId } = require("../window/utils");
const { WorkerSandbox } = require('../content/sandbox');
-const { getTabForWindow } = require('../tabs/helpers');
const { isPrivate } = require('../private-browsing/utils');
// A weak map of workers to hold private attributes that
@@ -118,14 +117,6 @@ const Worker = Class({
return model.window ? model.window.document.URL : null;
},
- get tab () {
- let model = modelFor(this);
- // model.window will be null after detach
- if (model.window)
- return getTabForWindow(model.window);
- return null;
- },
-
// Implemented to provide some of the previous features of exposing sandbox
// so that Worker can be extended
getSandbox: function () {
diff --git a/addon-sdk/source/lib/sdk/deprecated/unit-test-finder.js b/addon-sdk/source/lib/sdk/deprecated/unit-test-finder.js
index 2f062b5b357..518d813df4d 100644
--- a/addon-sdk/source/lib/sdk/deprecated/unit-test-finder.js
+++ b/addon-sdk/source/lib/sdk/deprecated/unit-test-finder.js
@@ -8,7 +8,6 @@ module.metadata = {
};
const file = require("../io/file");
-const memory = require('./memory');
const { Loader } = require("../test/loader");
const { isNative } = require('@loader/options');
@@ -132,7 +131,6 @@ let loader = Loader(module);
const NOT_TESTS = ['setup', 'teardown'];
var TestFinder = exports.TestFinder = function TestFinder(options) {
- memory.track(this);
this.filter = options.filter;
this.testInProcess = options.testInProcess === false ? false : true;
this.testOutOfProcess = options.testOutOfProcess === true ? true : false;
diff --git a/addon-sdk/source/lib/sdk/deprecated/unit-test.js b/addon-sdk/source/lib/sdk/deprecated/unit-test.js
index 976472f5a82..b93001971ce 100644
--- a/addon-sdk/source/lib/sdk/deprecated/unit-test.js
+++ b/addon-sdk/source/lib/sdk/deprecated/unit-test.js
@@ -7,7 +7,6 @@ module.metadata = {
"stability": "deprecated"
};
-const memory = require("./memory");
const timer = require("../timers");
const cfxArgs = require("../test/options");
const { getTabs, closeTab, getURI, getTabId, getSelectedTab } = require("../tabs/utils");
@@ -47,7 +46,6 @@ const TestRunner = function TestRunner(options) {
this.fs = options.fs;
this.console = options.console || console;
- memory.track(this);
this.passed = 0;
this.failed = 0;
this.testRunSummary = [];
@@ -283,40 +281,46 @@ TestRunner.prototype = {
}
this.isDone = true;
+ this.pass("This test is done.");
+
if (this.test.teardown) {
this.test.teardown(this);
}
+
if (this.waitTimeout !== null) {
timer.clearTimeout(this.waitTimeout);
this.waitTimeout = null;
}
+
// Do not leave any callback set when calling to `waitUntil`
this.waitUntilCallback = null;
if (this.test.passed == 0 && this.test.failed == 0) {
this._logTestFailed("empty test");
+
if ("testMessage" in this.console) {
this.console.testMessage(false, false, this.test.name, "Empty test");
}
else {
this.console.error("fail:", "Empty test")
}
+
this.failed++;
this.test.failed++;
}
let wins = windows(null, { includePrivate: true });
- let winPromises = wins.map(win => {
- let { promise, resolve } = defer();
- if (["interactive", "complete"].indexOf(win.document.readyState) >= 0) {
- resolve()
- }
- else {
- win.addEventListener("DOMContentLoaded", function onLoad() {
- win.removeEventListener("DOMContentLoaded", onLoad, false);
- resolve();
- }, false);
- }
- return promise;
+ let winPromises = wins.map(win => {
+ return new Promise(resolve => {
+ if (["interactive", "complete"].indexOf(win.document.readyState) >= 0) {
+ resolve()
+ }
+ else {
+ win.addEventListener("DOMContentLoaded", function onLoad() {
+ win.removeEventListener("DOMContentLoaded", onLoad, false);
+ resolve();
+ }, false);
+ }
+ });
});
PromiseDebugging.flushUncaughtErrors();
@@ -358,9 +362,17 @@ TestRunner.prototype = {
}
}
- return null;
+ return failure;
+ }).
+ then(failure => {
+ if (!failure) {
+ this.pass("There was a clean UI.");
+ return null;
+ }
+ return cleanUI().then(() => {
+ this.pass("There is a clean UI.");
+ });
}).
- then(cleanUI).
then(() => {
this.testRunSummary.push({
name: this.test.name,
diff --git a/addon-sdk/source/lib/sdk/io/data.js b/addon-sdk/source/lib/sdk/io/data.js
deleted file mode 100644
index 57e80f2ce77..00000000000
--- a/addon-sdk/source/lib/sdk/io/data.js
+++ /dev/null
@@ -1,90 +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";
-
-module.metadata = {
- "stability": "unstable"
-};
-
-const { Cc, Ci, Cu } = require("chrome");
-const base64 = require("../base64");
-const IOService = Cc["@mozilla.org/network/io-service;1"].
- getService(Ci.nsIIOService);
-
-const { deprecateFunction } = require('../util/deprecate');
-const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm");
-const { Services } = Cu.import("resource://gre/modules/Services.jsm");
-const FaviconService = Cc["@mozilla.org/browser/favicon-service;1"].
- getService(Ci.nsIFaviconService);
-
-const PNG_B64 = "data:image/png;base64,";
-const DEF_FAVICON_URI = "chrome://mozapps/skin/places/defaultFavicon.png";
-let DEF_FAVICON = null;
-
-/**
- * Takes URI of the page and returns associated favicon URI.
- * If page under passed uri has no favicon then base64 encoded data URI of
- * default faveicon is returned.
- * @param {String} uri
- * @returns {String}
- */
-function getFaviconURIForLocation(uri) {
- let pageURI = NetUtil.newURI(uri);
- try {
- return FaviconService.getFaviconDataAsDataURL(
- FaviconService.getFaviconForPage(pageURI));
- }
- catch(e) {
- if (!DEF_FAVICON) {
- DEF_FAVICON = PNG_B64 +
- base64.encode(getChromeURIContent(DEF_FAVICON_URI));
- }
- return DEF_FAVICON;
- }
-}
-exports.getFaviconURIForLocation = getFaviconURIForLocation;
-
-/**
- * Takes chrome URI and returns content under that URI.
- * @param {String} chromeURI
- * @returns {String}
- */
-function getChromeURIContent(chromeURI) {
- let channel = IOService.newChannel2(chromeURI,
- null,
- null,
- null, // aLoadingNode
- Services.scriptSecurityManager.getSystemPrincipal(),
- null, // aTriggeringPrincipal
- Ci.nsILoadInfo.SEC_NORMAL,
- Ci.nsIContentPolicy.TYPE_OTHER);
- let input = channel.open();
- let stream = Cc["@mozilla.org/binaryinputstream;1"].
- createInstance(Ci.nsIBinaryInputStream);
- stream.setInputStream(input);
- let content = stream.readBytes(input.available());
- stream.close();
- input.close();
- return content;
-}
-exports.getChromeURIContent = deprecateFunction(getChromeURIContent,
- 'getChromeURIContent is deprecated, ' +
- 'please use require("sdk/net/url").readURI instead.'
-);
-
-/**
- * Creates a base-64 encoded ASCII string from a string of binary data.
- */
-exports.base64Encode = deprecateFunction(base64.encode,
- 'base64Encode is deprecated, ' +
- 'please use require("sdk/base64").encode instead.'
-);
-/**
- * Decodes a string of data which has been encoded using base-64 encoding.
- */
-exports.base64Decode = deprecateFunction(base64.decode,
- 'base64Dencode is deprecated, ' +
- 'please use require("sdk/base64").decode instead.'
-);
diff --git a/addon-sdk/source/lib/sdk/io/text-streams.js b/addon-sdk/source/lib/sdk/io/text-streams.js
index 7a385cf03c4..ed4ec4972b2 100644
--- a/addon-sdk/source/lib/sdk/io/text-streams.js
+++ b/addon-sdk/source/lib/sdk/io/text-streams.js
@@ -1,17 +1,15 @@
/* 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";
module.metadata = {
"stability": "experimental"
};
-const {Cc,Ci,Cu,components} = require("chrome");
-var NetUtil = {};
-Cu.import("resource://gre/modules/NetUtil.jsm", NetUtil);
-NetUtil = NetUtil.NetUtil;
+const { Cc, Ci, Cu, components } = require("chrome");
+const { ensure } = require("../system/unload");
+const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
// NetUtil.asyncCopy() uses this buffer length, and since we call it, for best
// performance we use it, too.
@@ -19,8 +17,6 @@ const BUFFER_BYTE_LEN = 0x8000;
const PR_UINT32_MAX = 0xffffffff;
const DEFAULT_CHARSET = "UTF-8";
-exports.TextReader = TextReader;
-exports.TextWriter = TextWriter;
/**
* An input stream that reads text from a backing stream using a given text
@@ -35,7 +31,6 @@ exports.TextWriter = TextWriter;
* documentation on how to determine other valid values for this.
*/
function TextReader(inputStream, charset) {
- const self = this;
charset = checkCharset(charset);
let stream = Cc["@mozilla.org/intl/converter-input-stream;1"].
@@ -89,6 +84,7 @@ function TextReader(inputStream, charset) {
return str;
};
}
+exports.TextReader = TextReader;
/**
* A buffered output stream that writes text to a backing stream using a given
@@ -103,7 +99,6 @@ function TextReader(inputStream, charset) {
* for documentation on how to determine other valid values for this.
*/
function TextWriter(outputStream, charset) {
- const self = this;
charset = checkCharset(charset);
let stream = outputStream;
@@ -169,7 +164,7 @@ function TextWriter(outputStream, charset) {
this.writeAsync = function TextWriter_writeAsync(str, callback) {
manager.ensureOpened();
let istream = uconv.convertToInputStream(str);
- NetUtil.asyncCopy(istream, stream, function (result) {
+ NetUtil.asyncCopy(istream, stream, (result) => {
let err = components.isSuccessCode(result) ? undefined :
new Error("An error occured while writing to the stream: " + result);
if (err)
@@ -180,7 +175,7 @@ function TextWriter(outputStream, charset) {
if (typeof(callback) === "function") {
try {
- callback.call(self, err);
+ callback.call(this, err);
}
catch (exc) {
console.exception(exc);
@@ -189,34 +184,32 @@ function TextWriter(outputStream, charset) {
});
};
}
+exports.TextWriter = TextWriter;
// This manages the lifetime of stream, a TextReader or TextWriter. It defines
// closed and close() on stream and registers an unload listener that closes
// rawStream if it's still opened. It also provides ensureOpened(), which
// throws an exception if the stream is closed.
function StreamManager(stream, rawStream) {
- const self = this;
this.rawStream = rawStream;
this.opened = true;
/**
* True iff the stream is closed.
*/
- stream.__defineGetter__("closed", function stream_closed() {
- return !self.opened;
- });
+ stream.__defineGetter__("closed", () => !this.opened);
/**
* Closes both the stream and its backing stream. If the stream is already
* closed, an exception is thrown. For TextWriters, this first flushes the
* backing stream's buffer.
*/
- stream.close = function stream_close() {
- self.ensureOpened();
- self.unload();
+ stream.close = () => {
+ this.ensureOpened();
+ this.unload();
};
- require("../system/unload").ensure(this);
+ ensure(this);
}
StreamManager.prototype = {
diff --git a/addon-sdk/source/lib/sdk/places/host/host-query.js b/addon-sdk/source/lib/sdk/places/host/host-query.js
index 12ba203afcd..6ce12c231c9 100644
--- a/addon-sdk/source/lib/sdk/places/host/host-query.js
+++ b/addon-sdk/source/lib/sdk/places/host/host-query.js
@@ -1,7 +1,6 @@
/* 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";
module.metadata = {
@@ -13,7 +12,7 @@ module.metadata = {
};
const { Cc, Ci } = require('chrome');
-const { defer, all, resolve } = require('../../core/promise');
+const { all } = require('../../core/promise');
const { safeMerge, omit } = require('../../util/object');
const historyService = Cc['@mozilla.org/browser/nav-history-service;1']
.getService(Ci.nsINavHistoryService);
@@ -45,13 +44,11 @@ const PLACES_PROPERTIES = [
];
function execute (queries, options) {
- let deferred = defer();
- let root = historyService
- .executeQueries(queries, queries.length, options).root;
-
- let items = collect([], root);
- deferred.resolve(items);
- return deferred.promise;
+ return new Promise(resolve => {
+ let root = historyService
+ .executeQueries(queries, queries.length, options).root;
+ resolve(collect([], root));
+ });
}
function collect (acc, node) {
@@ -69,40 +66,35 @@ function collect (acc, node) {
}
function query (queries, options) {
- queries = queries || [];
- options = options || {};
- let deferred = defer();
- let optionsObj, queryObjs;
+ return new Promise((resolve, reject) => {
+ queries = queries || [];
+ options = options || {};
+ let optionsObj, queryObjs;
- try {
optionsObj = historyService.getNewQueryOptions();
queryObjs = [].concat(queries).map(createQuery);
if (!queryObjs.length) {
queryObjs = [historyService.getNewQuery()];
}
safeMerge(optionsObj, options);
- } catch (e) {
- deferred.reject(e);
- return deferred.promise;
- }
- /*
- * Currently `places:` queries are not supported
- */
- optionsObj.excludeQueries = true;
+ /*
+ * Currently `places:` queries are not supported
+ */
+ optionsObj.excludeQueries = true;
- execute(queryObjs, optionsObj).then(function (results) {
- if (optionsObj.queryType === 0) {
- return results.map(normalize);
- } else if (optionsObj.queryType === 1) {
- // Formats query results into more standard
- // data structures for returning
- return all(results.map(({itemId}) =>
- send('sdk-places-bookmarks-get', { id: itemId })));
- }
- }).then(deferred.resolve, deferred.reject);
-
- return deferred.promise;
+ execute(queryObjs, optionsObj).then((results) => {
+ if (optionsObj.queryType === 0) {
+ return results.map(normalize);
+ }
+ else if (optionsObj.queryType === 1) {
+ // Formats query results into more standard
+ // data structures for returning
+ return all(results.map(({itemId}) =>
+ send('sdk-places-bookmarks-get', { id: itemId })));
+ }
+ }).then(resolve, reject);
+ });
}
exports.query = query;
@@ -140,7 +132,7 @@ function queryReceiver (message) {
/*
* Converts a nsINavHistoryResultNode into a plain object
- *
+ *
* https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsINavHistoryResultNode
*/
function normalize (historyObj) {
@@ -150,7 +142,8 @@ function normalize (historyObj) {
else if (prop === 'time') {
// Cast from microseconds to milliseconds
obj.time = Math.floor(historyObj.time / 1000)
- } else if (prop === 'accessCount')
+ }
+ else if (prop === 'accessCount')
obj.visitCount = historyObj[prop];
else
obj[prop] = historyObj[prop];
diff --git a/addon-sdk/source/lib/sdk/places/utils.js b/addon-sdk/source/lib/sdk/places/utils.js
index e016a145253..f03a8f6a75a 100644
--- a/addon-sdk/source/lib/sdk/places/utils.js
+++ b/addon-sdk/source/lib/sdk/places/utils.js
@@ -51,14 +51,14 @@ exports.TreeNode = TreeNode;
/*
* Descends down from `node` applying `fn` to each in order.
* `fn` can return values or promises -- if promise returned,
- * children are not processed until resolved. `fn` is passed
+ * children are not processed until resolved. `fn` is passed
* one argument, the current node, `curr`.
*/
function walk (curr, fn) {
return promised(fn)(curr).then(val => {
return all(curr.children.map(child => walk(child, fn)));
});
-}
+}
/*
* Descends from the TreeNode `node`, returning
@@ -122,7 +122,7 @@ exports.isRootGroup = isRootGroup;
/*
* Merges appropriate options into query based off of url
* 4 scenarios:
- *
+ *
* 'moz.com' // domain: moz.com, domainIsHost: true
* --> 'http://moz.com', 'http://moz.com/thunderbird'
* '*.moz.com' // domain: moz.com, domainIsHost: false
@@ -177,9 +177,9 @@ function createQuery (type, query) {
let qObj = {
searchTerms: query.query
};
-
+
urlQueryParser(qObj, query.url);
-
+
// 0 === history
if (type === 0) {
// PRTime used by query is in microseconds, not milliseconds
@@ -194,7 +194,7 @@ function createQuery (type, query) {
else if (type === 1) {
qObj.tags = query.tags;
qObj.folder = query.group && query.group.id;
- }
+ }
// 2 === unified (not implemented on platform)
else if (type === 2) {
diff --git a/addon-sdk/source/lib/sdk/self.js b/addon-sdk/source/lib/sdk/self.js
index af2a4a64756..d825a41a394 100644
--- a/addon-sdk/source/lib/sdk/self.js
+++ b/addon-sdk/source/lib/sdk/self.js
@@ -27,6 +27,9 @@ const metadata = options.metadata || {};
const permissions = metadata.permissions || {};
const isPacked = rootURI && rootURI.indexOf("jar:") === 0;
+const isPrivateBrowsingSupported = 'private-browsing' in permissions &&
+ permissions['private-browsing'] === true;
+
const uri = (path="") =>
path.includes(":") ? path : addonDataURI + path.replace(/^\.\//, "");
@@ -55,4 +58,4 @@ exports.data = Object.freeze({
return readURISync(uri(path));
}
});
-exports.isPrivateBrowsingSupported = permissions['private-browsing'] === true;
+exports.isPrivateBrowsingSupported = isPrivateBrowsingSupported;
diff --git a/addon-sdk/source/lib/sdk/tabs/helpers.js b/addon-sdk/source/lib/sdk/tabs/helpers.js
index fab18cd4e11..43bea1ca5b0 100644
--- a/addon-sdk/source/lib/sdk/tabs/helpers.js
+++ b/addon-sdk/source/lib/sdk/tabs/helpers.js
@@ -14,16 +14,6 @@ module.metadata = {
const { getTabForContentWindow, getTabForBrowser: getRawTabForBrowser } = require('./utils');
const { modelFor } = require('../model/core');
-function getTabForWindow(win) {
- let tab = getTabForContentWindow(win);
- // We were unable to find the related tab!
- if (!tab)
- return null;
-
- return modelFor(tab);
-}
-exports.getTabForWindow = getTabForWindow;
-
exports.getTabForRawTab = modelFor;
function getTabForBrowser(browser) {
diff --git a/addon-sdk/source/lib/sdk/tabs/tab-fennec.js b/addon-sdk/source/lib/sdk/tabs/tab-fennec.js
index 515f6e10279..6d32bc80903 100644
--- a/addon-sdk/source/lib/sdk/tabs/tab-fennec.js
+++ b/addon-sdk/source/lib/sdk/tabs/tab-fennec.js
@@ -71,26 +71,6 @@ const Tab = Class({
},
set url(url) setTabURL(tabNS(this).tab, url),
- /**
- * URI of the favicon for the page currently loaded in this tab.
- * @type {String}
- */
- get favicon() {
- /*
- * Synchronous favicon services were never supported on Fennec,
- * and as of FF22, are now deprecated. When/if favicon services
- * are supported for Fennec, this getter should reference
- * `require('sdk/places/favicon').getFavicon`
- */
- console.error(
- 'tab.favicon is deprecated, and currently ' +
- 'favicon helpers are not yet supported by Fennec'
- );
-
- // return 16x16 blank default
- return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAEklEQVQ4jWNgGAWjYBSMAggAAAQQAAF/TXiOAAAAAElFTkSuQmCC';
- },
-
getThumbnail: function() {
// TODO: implement!
console.error(ERR_FENNEC_MSG);
diff --git a/addon-sdk/source/lib/sdk/tabs/tab-firefox.js b/addon-sdk/source/lib/sdk/tabs/tab-firefox.js
index db7ac11b069..5362d8cf6c2 100644
--- a/addon-sdk/source/lib/sdk/tabs/tab-firefox.js
+++ b/addon-sdk/source/lib/sdk/tabs/tab-firefox.js
@@ -15,8 +15,6 @@ const { getBrowserForTab, setTabURL, getTabId, getTabURL, getTabForBrowser,
getTabs, getTabTitle, setTabTitle, getIndex, closeTab, reload, move,
activateTab, pin, unpin, isTab } = require('./utils');
const { isBrowser, getInnerId, isWindowPrivate } = require('../window/utils');
-const { getFaviconURIForLocation } = require("../io/data");
-const { deprecateUsage } = require('../util/deprecate');
const { getThumbnailURIForWindow, BLANK } = require("../content/thumbnail");
const { when } = require('../system/unload');
const { ignoreWindow, isPrivate } = require('../private-browsing/utils')
@@ -96,14 +94,6 @@ const Tab = Class({
setTabURL(viewsFor.get(this), val);
},
- get favicon() {
- deprecateUsage(
- 'tab.favicon is deprecated, ' +
- 'please use require("sdk/places/favicon").getFavicon instead.'
- );
- return isDestroyed(this) ? undefined : getFaviconURIForLocation(this.url);
- },
-
get contentType() {
return isDestroyed(this) ? undefined : browser(this).documentContentType;
},
diff --git a/addon-sdk/source/lib/sdk/test/harness.js b/addon-sdk/source/lib/sdk/test/harness.js
index b32cf54f7ef..c5e3f09d493 100644
--- a/addon-sdk/source/lib/sdk/test/harness.js
+++ b/addon-sdk/source/lib/sdk/test/harness.js
@@ -15,7 +15,6 @@ const { PlainTextConsole } = require("../console/plain-text");
const { when: unload } = require("../system/unload");
const { format, fromException } = require("../console/traceback");
const system = require("../system");
-const memory = require('../deprecated/memory');
const { gc: gcPromise } = require('./memory');
const { defer } = require('../core/promise');
const { extend } = require('../core/heritage');
@@ -150,7 +149,7 @@ function reportMemoryUsage() {
return emptyPromise();
}
- return gcPromise().then((function () {
+ return gcPromise().then((() => {
var mgr = Cc["@mozilla.org/memory-reporter-manager;1"]
.getService(Ci.nsIMemoryReporterManager);
let count = 0;
@@ -158,11 +157,6 @@ function reportMemoryUsage() {
print(((++count == 1) ? "\n" : "") + description + ": " + amount + "\n");
}
mgr.getReportsForThisProcess(logReporter, null, /* anonymize = */ false);
-
- var weakrefs = [info.weakref.get()
- for (info of memory.getObjects())];
- weakrefs = [weakref for (weakref of weakrefs) if (weakref)];
- print("Tracked memory objects in testing sandbox: " + weakrefs.length + "\n");
}));
}
@@ -216,16 +210,6 @@ function showResults() {
function cleanup() {
let coverObject = {};
try {
- for (let name in loader.modules)
- memory.track(loader.modules[name],
- "module global scope: " + name);
- memory.track(loader, "Cuddlefish Loader");
-
- if (profileMemory) {
- gWeakrefInfo = [{ weakref: info.weakref, bin: info.bin }
- for (info of memory.getObjects())];
- }
-
loader.unload();
if (loader.globals.console.errorsLogged && !results.failed) {
@@ -251,7 +235,7 @@ function cleanup() {
consoleListener.unregister();
- memory.gc();
+ Cu.forceGC();
}
catch (e) {
results.failed++;
@@ -278,7 +262,7 @@ function cleanup() {
}
function getPotentialLeaks() {
- memory.gc();
+ Cu.forceGC();
// Things we can assume are part of the platform and so aren't leaks
let GOOD_BASE_URLS = [
diff --git a/addon-sdk/source/lib/sdk/test/memory.js b/addon-sdk/source/lib/sdk/test/memory.js
index 1c564331266..bd1198bfe52 100644
--- a/addon-sdk/source/lib/sdk/test/memory.js
+++ b/addon-sdk/source/lib/sdk/test/memory.js
@@ -4,17 +4,8 @@
'use strict';
const { Cu } = require("chrome");
-const memory = require('../deprecated/memory');
-const { defer } = require('../core/promise');
function gc() {
- let { promise, resolve } = defer();
-
- Cu.forceGC();
- memory.gc();
-
- Cu.schedulePreciseGC(_ => resolve());
-
- return promise;
+ return new Promise(resolve => Cu.schedulePreciseGC(resolve));
}
exports.gc = gc;
diff --git a/addon-sdk/source/lib/sdk/util/bond.js b/addon-sdk/source/lib/sdk/util/bond.js
deleted file mode 100644
index 422f57737e1..00000000000
--- a/addon-sdk/source/lib/sdk/util/bond.js
+++ /dev/null
@@ -1,36 +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";
-
-module.metadata = {
- "stability": "experimental"
-};
-
-const makeDescriptor = (name, method) => ({
- get() {
- if (!Object.hasOwnProperty.call(this, name)) {
- Object.defineProperty(this, name, {value: method.bind(this)});
- return this[name];
- } else {
- return method;
- }
- }
-});
-
-const Bond = function(methods) {
- let descriptor = {};
- let members = [...Object.getOwnPropertyNames(methods),
- ...Object.getOwnPropertySymbols(methods)];
-
- for (let name of members) {
- let method = methods[name];
- if (typeof(method) !== "function") {
- throw new TypeError(`Property named "${name}" passed to Bond must be a function`);
- }
- descriptor[name] = makeDescriptor(name, method);
- }
-
- return Object.create(Bond.prototype, descriptor);
-}
-exports.Bond = Bond;
diff --git a/addon-sdk/source/lib/sdk/util/rules.js b/addon-sdk/source/lib/sdk/util/rules.js
index 9ab791ae7f2..1abe36b8735 100644
--- a/addon-sdk/source/lib/sdk/util/rules.js
+++ b/addon-sdk/source/lib/sdk/util/rules.js
@@ -1,7 +1,6 @@
/* 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";
module.metadata = {
@@ -10,9 +9,7 @@ module.metadata = {
const { Class } = require('../core/heritage');
const { MatchPattern } = require('./match-pattern');
-const { on, off, emit } = require('../event/core');
-const { method } = require('../lang/functional');
-const objectUtil = require('./object');
+const { emit } = require('../event/core');
const { EventTarget } = require('../event/target');
const { List, addListItem, removeListItem } = require('./list');
diff --git a/addon-sdk/source/lib/sdk/zip/utils.js b/addon-sdk/source/lib/sdk/zip/utils.js
index bc1e0b610b7..e600380cbea 100644
--- a/addon-sdk/source/lib/sdk/zip/utils.js
+++ b/addon-sdk/source/lib/sdk/zip/utils.js
@@ -1,22 +1,16 @@
/* 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';
+"use strict";
-const { Cc, Ci, Cu } = require("chrome");
-const { defer } = require("../core/promise");
+const { Cc, Ci } = require("chrome");
-const getZipReader = function getZipReader(aFile) {
- let { promise, resolve, reject } = defer();
- let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].
- createInstance(Ci.nsIZipReader);
- try {
+function getZipReader(aFile) {
+ return new Promise(resolve => {
+ let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].
+ createInstance(Ci.nsIZipReader);
zipReader.open(aFile);
- }
- catch(e){
- reject(e);
- }
- resolve(zipReader);
- return promise;
+ resolve(zipReader);
+ });
};
exports.getZipReader = getZipReader;
diff --git a/addon-sdk/source/lib/toolkit/loader.js b/addon-sdk/source/lib/toolkit/loader.js
index 53f3968d32c..73e28237d09 100644
--- a/addon-sdk/source/lib/toolkit/loader.js
+++ b/addon-sdk/source/lib/toolkit/loader.js
@@ -874,7 +874,8 @@ function Loader(options) {
metadata: {
addonID: options.id,
URI: "Addon-SDK"
- }
+ },
+ prototype: options.sandboxPrototype || {}
});
}
diff --git a/addon-sdk/source/mapping.json b/addon-sdk/source/mapping.json
index 18b78b979a1..d8f497a26fc 100644
--- a/addon-sdk/source/mapping.json
+++ b/addon-sdk/source/mapping.json
@@ -13,7 +13,6 @@
"l10n/prefs": "sdk/l10n/prefs",
"list": "sdk/util/list",
"loader": "sdk/loader/loader",
- "memory": "sdk/deprecated/memory",
"namespace": "sdk/core/namespace",
"preferences-service": "sdk/preferences/service",
"promise": "sdk/core/promise",
diff --git a/addon-sdk/source/package.json b/addon-sdk/source/package.json
index 35a4e9c9034..5a9707afb83 100644
--- a/addon-sdk/source/package.json
+++ b/addon-sdk/source/package.json
@@ -22,6 +22,7 @@
"async": "0.9.0",
"chai": "2.1.1",
"fs-extra": "0.18.2",
+ "fx-runner": "0.0.7",
"glob": "4.4.2",
"gulp": "3.8.11",
"ini-parser": "0.0.2",
diff --git a/addon-sdk/source/python-lib/cuddlefish/__init__.py b/addon-sdk/source/python-lib/cuddlefish/__init__.py
index 7fafe14689b..365d96c5ef4 100644
--- a/addon-sdk/source/python-lib/cuddlefish/__init__.py
+++ b/addon-sdk/source/python-lib/cuddlefish/__init__.py
@@ -236,10 +236,6 @@ parser_groups = (
help="Where to put the finished .xpi",
default=None,
cmds=['xpi'])),
- (("", "--manifest-overload",), dict(dest="manifest_overload",
- help="JSON file to overload package.json properties",
- default=None,
- cmds=['xpi'])),
(("", "--abort-on-missing-module",), dict(dest="abort_on_missing",
help="Abort if required module is missing",
action="store_true",
@@ -661,10 +657,6 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
target_cfg_json = os.path.join(options.pkgdir, 'package.json')
target_cfg = packaging.get_config_in_dir(options.pkgdir)
- if options.manifest_overload:
- for k, v in packaging.load_json_file(options.manifest_overload).items():
- target_cfg[k] = v
-
# At this point, we're either building an XPI or running Jetpack code in
# a Mozilla application (which includes running tests).
diff --git a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/main.js b/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/main.js
deleted file mode 100644
index 22018c2a2eb..00000000000
--- a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/main.js
+++ /dev/null
@@ -1,17 +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 { Cc, Ci } = require("chrome");
-
-exports.main = function(options, callbacks) {
- // Close Firefox window. Firefox should quit.
- require("sdk/deprecated/window-utils").activeBrowserWindow.close();
-
- // But not on Mac where it stay alive! We have to request application quit.
- if (require("sdk/system/runtime").OS == "Darwin") {
- let appStartup = Cc['@mozilla.org/toolkit/app-startup;1'].
- getService(Ci.nsIAppStartup);
- appStartup.quit(appStartup.eAttemptQuit);
- }
-}
diff --git a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/manifest-overload.json b/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/manifest-overload.json
deleted file mode 100644
index a446378b0cf..00000000000
--- a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/manifest-overload.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "version": "1.0-nightly"
-}
diff --git a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/package.json b/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/package.json
deleted file mode 100644
index afbc15803da..00000000000
--- a/addon-sdk/source/python-lib/cuddlefish/tests/addons/simplest-test/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "id": "simplest-test",
- "directories": {
- "lib": "."
- }
-}
diff --git a/addon-sdk/source/python-lib/cuddlefish/tests/test_init.py b/addon-sdk/source/python-lib/cuddlefish/tests/test_init.py
index f331b09cbea..5ececfea602 100644
--- a/addon-sdk/source/python-lib/cuddlefish/tests/test_init.py
+++ b/addon-sdk/source/python-lib/cuddlefish/tests/test_init.py
@@ -182,35 +182,6 @@ class TestCfxQuits(unittest.TestCase):
container)
self.fail(standardMsg)
- def test_cfx_run(self):
- addon_path = os.path.join(tests_path,
- "addons", "simplest-test")
- rc, out, err = self.run_cfx(addon_path, ["run"])
- self.assertEqual(rc, 0)
- self.assertIn("Program terminated successfully.", err)
-
- def test_cfx_test(self):
- addon_path = os.path.join(tests_path, "addons", "simplest-test")
- rc, out, err = self.run_cfx(addon_path, ["test"])
- self.assertEqual(rc, 0)
- self.assertIn("1 of 1 tests passed.", err)
- self.assertIn("Program terminated successfully.", err)
-
- def test_cfx_xpi(self):
- addon_path = os.path.join(tests_path,
- "addons", "simplest-test")
- rc, out, err = self.run_cfx(addon_path, \
- ["xpi", "--manifest-overload", "manifest-overload.json"])
- self.assertEqual(rc, 0)
- # Ensure that the addon version from our manifest overload is used
- # in install.rdf
- xpi_path = os.path.join(addon_path, "simplest-test.xpi")
- xpi = zipfile.ZipFile(xpi_path, "r")
- manifest = xpi.read("install.rdf")
- self.assertIn("
'+
- '');
- let subDocument = encodeURIComponent(
- 'Iframe
'+
- '');
- let url = 'data:text/html;charset=utf-8,' + encodeURIComponent(
- 'Content
');
-
- // Open up a new tab in the background.
- //
- // This lets us test whether GetTabForWindow works even when the tab in
- // question is not active.
- tabs.open({
- inBackground: true,
- url: "about:mozilla",
- onReady: function(tab) { auxTab = tab; step2(url, assert);},
- onActivate: function(tab) { step3(assert, done); }
- });
-};
-
-function step2(url, assert) {
-
- tabs.open({
- url: url,
- onReady: function(tab) {
- primaryTab = tab;
- let window = windowUtils.activeBrowserWindow.content;
-
- let matchedTab = getTabForWindow(window);
- assert.equal(matchedTab, tab,
- "We are able to find the tab with his content window object");
-
- let timer = require("sdk/timers");
- function waitForFrames() {
- let iframe = window.document.getElementById("iframe");
- if (!iframe) {
- timer.setTimeout(waitForFrames, 100);
- return;
- }
- iframeWin = iframe.contentWindow;
- let subIframe = iframeWin.document.getElementById("sub-iframe");
- if (!subIframe) {
- timer.setTimeout(waitForFrames, 100);
- return;
- }
- let subIframeWin = subIframe.contentWindow;
- let subSubIframe = subIframeWin.document.getElementById("sub-sub-iframe");
- if (!subSubIframe) {
- timer.setTimeout(waitForFrames, 100);
- return;
- }
- let subSubIframeWin = subSubIframe.contentWindow;
-
- matchedTab = getTabForWindow(iframeWin);
- assert.equal(matchedTab, tab,
- "We are able to find the tab with an iframe window object");
-
- matchedTab = getTabForWindow(subIframeWin);
- assert.equal(matchedTab, tab,
- "We are able to find the tab with a sub-iframe window object");
-
- matchedTab = getTabForWindow(subSubIframeWin);
- assert.equal(matchedTab, tab,
- "We are able to find the tab with a sub-sub-iframe window object");
-
- // Put our primary tab in the background and test again.
- // The onActivate listener will take us to step3.
- auxTab.activate();
- }
- waitForFrames();
- }
- });
-}
-
-function step3(assert, done) {
-
- let matchedTab = getTabForWindow(iframeWin);
- assert.equal(matchedTab, primaryTab,
- "We get the correct tab even when it's in the background");
-
- primaryTab.close(function () {
- auxTab.close(function () { done();});
- });
-}
-
exports["test behavior on close"] = function(assert, done) {
-
tabs.open({
url: "about:mozilla",
onReady: function(tab) {
@@ -156,7 +51,6 @@ exports["test viewFor(tab)"] = (assert, done) => {
tabs.open({ url: "about:mozilla" });
};
-
exports["test modelFor(xulTab)"] = (assert, done) => {
tabs.open({
url: "about:mozilla",
diff --git a/addon-sdk/source/test/addons/layout-change/lib/test-cuddlefish-loader.js b/addon-sdk/source/test/addons/layout-change/lib/test-cuddlefish-loader.js
index e1cbddf7c2b..971723bffea 100644
--- a/addon-sdk/source/test/addons/layout-change/lib/test-cuddlefish-loader.js
+++ b/addon-sdk/source/test/addons/layout-change/lib/test-cuddlefish-loader.js
@@ -147,19 +147,9 @@ exports["test compatibility"] = function(assert) {
assert.equal(require("tabs/tab.js"),
require("sdk/tabs/tab"), "sdk/tabs/tab -> tabs/tab.js");
- assert.equal(require("memory"),
- require("sdk/deprecated/memory"), "sdk/deprecated/memory -> memory");
-
assert.equal(require("environment"),
require("sdk/system/environment"), "sdk/system/environment -> environment");
- if (app.is("Firefox")) {
- // This module fails on fennec because of favicon xpcom component
- // being not implemented on it.
- assert.equal(require("utils/data"),
- require("sdk/io/data"), "sdk/io/data -> utils/data");
- }
-
assert.equal(require("test/assert"),
require("sdk/test/assert"), "sdk/test/assert -> test/assert");
diff --git a/addon-sdk/source/test/addons/places/lib/places-helper.js b/addon-sdk/source/test/addons/places/lib/places-helper.js
index fb6cc631328..5a20db42cd7 100644
--- a/addon-sdk/source/test/addons/places/lib/places-helper.js
+++ b/addon-sdk/source/test/addons/places/lib/places-helper.js
@@ -33,13 +33,6 @@ function invalidResolve (assert) {
}
exports.invalidResolve = invalidResolve;
-function invalidReject (assert) {
- return function (e) {
- assert.fail('Reject state should not be called: ' + e);
- };
-}
-exports.invalidReject = invalidReject;
-
// Removes all children of group
function clearBookmarks (group) {
group
diff --git a/addon-sdk/source/test/addons/places/lib/test-places-bookmarks.js b/addon-sdk/source/test/addons/places/lib/test-places-bookmarks.js
index f329e91ab40..d04334714ea 100644
--- a/addon-sdk/source/test/addons/places/lib/test-places-bookmarks.js
+++ b/addon-sdk/source/test/addons/places/lib/test-places-bookmarks.js
@@ -24,7 +24,7 @@ const {
MENU, TOOLBAR, UNSORTED
} = require('sdk/places/bookmarks');
const {
- invalidResolve, invalidReject, createTree,
+ invalidResolve, createTree,
compareWithHost, createBookmark, createBookmarkItem,
createBookmarkTree, addVisits, resetPlaces
} = require('./places-helper');
@@ -369,28 +369,27 @@ exports.testPromisedSave = function (assert, done) {
}).then(done).catch(assert.fail);
};
-exports.testPromisedErrorSave = function (assert, done) {
+exports.testPromisedErrorSave = function*(assert) {
let bookmarks = [
{ title: 'moz1', url: 'http://moz1.com', type: 'bookmark'},
{ title: 'moz2', url: 'invalidurl', type: 'bookmark'},
{ title: 'moz3', url: 'http://moz3.com', type: 'bookmark'}
];
- saveP(bookmarks).then(invalidResolve, reason => {
+ yield saveP(bookmarks).then(() => {
+ assert.fail("should not resolve");
+ }, reason => {
assert.ok(
/The `url` property must be a valid URL/.test(reason),
'Error event called with correct reason');
+ });
- bookmarks[1].url = 'http://moz2.com';
- return saveP(bookmarks);
- }).
- then(res => searchP({ query: 'moz' })).
- then(res => {
- assert.equal(res.length, 3, 'all 3 should be saved upon retry');
- res.map(item => assert.ok(/moz\d\.com/.test(item.url), 'correct item'));
- done();
- }, invalidReject).
- catch(assert.fail);
+ bookmarks[1].url = 'http://moz2.com';
+ yield saveP(bookmarks);
+
+ let res = yield searchP({ query: 'moz' });
+ assert.equal(res.length, 3, 'all 3 should be saved upon retry');
+ res.map(item => assert.ok(/moz\d\.com/.test(item.url), 'correct item'));
};
exports.testMovingChildren = function (assert, done) {
@@ -692,61 +691,63 @@ exports.testSearchTags = function (assert, done) {
* 'http://mozilla.com/'
* 'http://mozilla.com/*'
*/
-exports.testSearchURL = function (assert, done) {
- createBookmarkTree().then(() => {
- return searchP({ url: 'mozilla.org' });
- }).then(data => {
- assert.equal(data.length, 2, 'only URLs with host domain');
- assert.equal(data[0].url, 'http://mozilla.org/');
- assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
- return searchP({ url: '*.mozilla.org' });
- }).then(data => {
- assert.equal(data.length, 3, 'returns domain and when host is other than domain');
- assert.equal(data[0].url, 'http://mozilla.org/');
- assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
- assert.equal(data[2].url, 'http://developer.mozilla.org/en-US/');
- return searchP({ url: 'http://mozilla.org' });
- }).then(data => {
- assert.equal(data.length, 1, 'only exact URL match');
- assert.equal(data[0].url, 'http://mozilla.org/');
- return searchP({ url: 'http://mozilla.org/*' });
- }).then(data => {
- assert.equal(data.length, 2, 'only URLs that begin with query');
- assert.equal(data[0].url, 'http://mozilla.org/');
- assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
- return searchP([{ url: 'mozilla.org' }, { url: 'component.fm' }]);
- }).then(data => {
- assert.equal(data.length, 3, 'returns URLs that match EITHER query');
- assert.equal(data[0].url, 'http://mozilla.org/');
- assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
- assert.equal(data[2].url, 'http://component.fm/');
- }).then(done).catch(assert.fail);
+exports.testSearchURLForBookmarks = function*(assert) {
+ yield createBookmarkTree()
+ let data = yield searchP({ url: 'mozilla.org' });
+
+ assert.equal(data.length, 2, 'only URLs with host domain');
+ assert.equal(data[0].url, 'http://mozilla.org/');
+ assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
+
+ data = yield searchP({ url: '*.mozilla.org' });
+
+ assert.equal(data.length, 3, 'returns domain and when host is other than domain');
+ assert.equal(data[0].url, 'http://mozilla.org/');
+ assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
+ assert.equal(data[2].url, 'http://developer.mozilla.org/en-US/');
+
+ data = yield searchP({ url: 'http://mozilla.org' });
+
+ assert.equal(data.length, 1, 'only exact URL match');
+ assert.equal(data[0].url, 'http://mozilla.org/');
+
+ data = yield searchP({ url: 'http://mozilla.org/*' });
+
+ assert.equal(data.length, 2, 'only URLs that begin with query');
+ assert.equal(data[0].url, 'http://mozilla.org/');
+ assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
+
+ data = yield searchP([{ url: 'mozilla.org' }, { url: 'component.fm' }]);
+
+ assert.equal(data.length, 3, 'returns URLs that match EITHER query');
+ assert.equal(data[0].url, 'http://mozilla.org/');
+ assert.equal(data[1].url, 'http://mozilla.org/thunderbird/');
+ assert.equal(data[2].url, 'http://component.fm/');
};
/*
* Searches url, title, tags
*/
-exports.testSearchQuery = function (assert, done) {
- createBookmarkTree().then(() => {
- return searchP({ query: 'thunder' });
- }).then(data => {
- assert.equal(data.length, 3);
- assert.equal(data[0].title, 'mozilla.com', 'query matches tag, url, or title');
- assert.equal(data[1].title, 'mozilla.org', 'query matches tag, url, or title');
- assert.equal(data[2].title, 'thunderbird', 'query matches tag, url, or title');
- return searchP([{ query: 'rust' }, { query: 'component' }]);
- }).then(data => {
- // rust OR component
- assert.equal(data.length, 3);
- assert.equal(data[0].title, 'mozilla.com', 'query matches tag, url, or title');
- assert.equal(data[1].title, 'mozilla.org', 'query matches tag, url, or title');
- assert.equal(data[2].title, 'web audio components', 'query matches tag, url, or title');
- return searchP([{ query: 'moz', tags: ['javascript']}]);
- }).then(data => {
- assert.equal(data.length, 1);
- assert.equal(data[0].title, 'mdn',
- 'only one item matches moz query AND has a javascript tag');
- }).then(done).catch(assert.fail);
+exports.testSearchQueryForBookmarks = function*(assert) {
+ yield createBookmarkTree();
+
+ let data = yield searchP({ query: 'thunder' });
+ assert.equal(data.length, 3);
+ assert.equal(data[0].title, 'mozilla.com', 'query matches tag, url, or title');
+ assert.equal(data[1].title, 'mozilla.org', 'query matches tag, url, or title');
+ assert.equal(data[2].title, 'thunderbird', 'query matches tag, url, or title');
+
+ data = yield searchP([{ query: 'rust' }, { query: 'component' }]);
+ // rust OR component
+ assert.equal(data.length, 3);
+ assert.equal(data[0].title, 'mozilla.com', 'query matches tag, url, or title');
+ assert.equal(data[1].title, 'mozilla.org', 'query matches tag, url, or title');
+ assert.equal(data[2].title, 'web audio components', 'query matches tag, url, or title');
+
+ data = yield searchP([{ query: 'moz', tags: ['javascript']}]);
+ assert.equal(data.length, 1);
+ assert.equal(data[0].title, 'mdn',
+ 'only one item matches moz query AND has a javascript tag');
};
/*
@@ -827,7 +828,7 @@ exports.testSearchCount = function (assert, done) {
}
};
-exports.testSearchSort = function (assert, done) {
+exports.testSearchSortForBookmarks = function (assert, done) {
let urls = [
'http://mozilla.com/', 'http://webaud.io/', 'http://mozilla.com/webfwd/',
'http://developer.mozilla.com/', 'http://bandcamp.com/'
diff --git a/addon-sdk/source/test/addons/places/lib/test-places-events.js b/addon-sdk/source/test/addons/places/lib/test-places-events.js
index e31385238ff..dc033f6a881 100644
--- a/addon-sdk/source/test/addons/places/lib/test-places-events.js
+++ b/addon-sdk/source/test/addons/places/lib/test-places-events.js
@@ -27,7 +27,7 @@ const isOSX10_6 = (() => {
const { search } = require('sdk/places/history');
const {
- invalidResolve, invalidReject, createTree, createBookmark,
+ invalidResolve, createTree, createBookmark,
compareWithHost, addVisits, resetPlaces, createBookmarkItem,
removeVisits, historyBatch
} = require('./places-helper');
diff --git a/addon-sdk/source/test/addons/places/lib/test-places-history.js b/addon-sdk/source/test/addons/places/lib/test-places-history.js
index e53f26ba1cf..8aed2999b93 100644
--- a/addon-sdk/source/test/addons/places/lib/test-places-history.js
+++ b/addon-sdk/source/test/addons/places/lib/test-places-history.js
@@ -19,45 +19,44 @@ const {
search
} = require('sdk/places/history');
const {
- invalidResolve, invalidReject, createTree,
+ invalidResolve, createTree,
compareWithHost, addVisits, resetPlaces
} = require('./places-helper');
const { promisedEmitter } = require('sdk/places/utils');
-exports.testEmptyQuery = function (assert, done) {
+exports.testEmptyQuery = function*(assert) {
let within = toBeWithin();
- addVisits([
+ yield addVisits([
'http://simplequery-1.com', 'http://simplequery-2.com'
- ]).then(searchP).then(results => {
- assert.equal(results.length, 2, 'Correct number of entries returned');
- assert.equal(results[0].url, 'http://simplequery-1.com/',
- 'matches url');
- assert.equal(results[1].url, 'http://simplequery-2.com/',
- 'matches url');
- assert.equal(results[0].title, 'Test visit for ' + results[0].url,
- 'title matches');
- assert.equal(results[1].title, 'Test visit for ' + results[1].url,
- 'title matches');
- assert.equal(results[0].visitCount, 1, 'matches access');
- assert.equal(results[1].visitCount, 1, 'matches access');
- assert.ok(within(results[0].time), 'accurate access time');
- assert.ok(within(results[1].time), 'accurate access time');
- assert.equal(Object.keys(results[0]).length, 4,
- 'no addition exposed properties on history result');
- done();
- }, invalidReject);
+ ]);
+
+ let results = yield searchP();
+ assert.equal(results.length, 2, 'Correct number of entries returned');
+ assert.equal(results[0].url, 'http://simplequery-1.com/',
+ 'matches url');
+ assert.equal(results[1].url, 'http://simplequery-2.com/',
+ 'matches url');
+ assert.equal(results[0].title, 'Test visit for ' + results[0].url,
+ 'title matches');
+ assert.equal(results[1].title, 'Test visit for ' + results[1].url,
+ 'title matches');
+ assert.equal(results[0].visitCount, 1, 'matches access');
+ assert.equal(results[1].visitCount, 1, 'matches access');
+ assert.ok(within(results[0].time), 'accurate access time');
+ assert.ok(within(results[1].time), 'accurate access time');
+ assert.equal(Object.keys(results[0]).length, 4,
+ 'no addition exposed properties on history result');
};
-exports.testVisitCount = function (assert, done) {
- addVisits([
+exports.testVisitCount = function*(assert) {
+ yield addVisits([
'http://simplequery-1.com', 'http://simplequery-1.com',
'http://simplequery-1.com', 'http://simplequery-1.com'
- ]).then(searchP).then(results => {
- assert.equal(results.length, 1, 'Correct number of entries returned');
- assert.equal(results[0].url, 'http://simplequery-1.com/', 'correct url');
- assert.equal(results[0].visitCount, 4, 'matches access count');
- done();
- }, invalidReject);
+ ]);
+ let results = yield searchP();
+ assert.equal(results.length, 1, 'Correct number of entries returned');
+ assert.equal(results[0].url, 'http://simplequery-1.com/', 'correct url');
+ assert.equal(results[0].visitCount, 4, 'matches access count');
};
/*
@@ -67,24 +66,23 @@ exports.testVisitCount = function (assert, done) {
* 'http://mozilla.org/'
* 'http://mozilla.org/*'
*/
-exports.testSearchURL = function (assert, done) {
- addVisits([
+exports.testSearchURLForHistory = function*(assert) {
+ yield addVisits([
'http://developer.mozilla.org', 'http://mozilla.org',
'http://mozilla.org/index', 'https://mozilla.org'
- ]).then(() => searchP({ url: '*.mozilla.org' }))
- .then(results => {
- assert.equal(results.length, 4, 'returns all entries');
- return searchP({ url: 'mozilla.org' });
- }).then(results => {
- assert.equal(results.length, 3, 'returns entries where mozilla.org is host');
- return searchP({ url: 'http://mozilla.org/' });
- }).then(results => {
- assert.equal(results.length, 1, 'should just be an exact match');
- return searchP({ url: 'http://mozilla.org/*' });
- }).then(results => {
- assert.equal(results.length, 2, 'should match anything starting with substring');
- done();
- });
+ ]);
+
+ let results = yield searchP({ url: 'http://mozilla.org/' });
+ assert.equal(results.length, 1, 'should just be an exact match');
+
+ results = yield searchP({ url: '*.mozilla.org' });
+ assert.equal(results.length, 4, 'returns all entries');
+
+ results = yield searchP({ url: 'mozilla.org' });
+ assert.equal(results.length, 3, 'returns entries where mozilla.org is host');
+
+ results = yield searchP({ url: 'http://mozilla.org/*' });
+ assert.equal(results.length, 2, 'should match anything starting with substring');
};
// Disabling due to intermittent Bug 892619
@@ -124,23 +122,21 @@ exports.testSearchTimeRange = function (assert, done) {
});
};
*/
-exports.testSearchQuery = function (assert, done) {
- addVisits([
+exports.testSearchQueryForHistory = function*(assert) {
+ yield addVisits([
'http://mozilla.com', 'http://webaud.io', 'http://mozilla.com/webfwd'
- ]).then(() => {
- return searchP({ query: 'moz' });
- }).then(results => {
- assert.equal(results.length, 2, 'should return urls that match substring');
- results.map(({url}) => {
- assert.ok(/moz/.test(url), 'correct item');
- });
- return searchP([{ query: 'webfwd' }, { query: 'aud.io' }]);
- }).then(results => {
- assert.equal(results.length, 2, 'should OR separate queries');
- results.map(({url}) => {
- assert.ok(/webfwd|aud\.io/.test(url), 'correct item');
- });
- done();
+ ]);
+
+ let results = yield searchP({ query: 'moz' });
+ assert.equal(results.length, 2, 'should return urls that match substring');
+ results.map(({url}) => {
+ assert.ok(/moz/.test(url), 'correct item');
+ });
+
+ results = yield searchP([{ query: 'webfwd' }, { query: 'aud.io' }]);
+ assert.equal(results.length, 2, 'should OR separate queries');
+ results.map(({url}) => {
+ assert.ok(/webfwd|aud\.io/.test(url), 'correct item');
});
};
@@ -168,51 +164,50 @@ exports.testSearchCount = function (assert, done) {
}
};
-exports.testSearchSort = function (assert, done) {
- let places = [
- 'http://mozilla.com/', 'http://webaud.io/', 'http://mozilla.com/webfwd/',
- 'http://developer.mozilla.com/', 'http://bandcamp.com/'
- ];
- addVisits(places).then(() => {
- return searchP({}, { sort: 'title' });
- }).then(results => {
- checkOrder(results, [4,3,0,2,1]);
- return searchP({}, { sort: 'title', descending: true });
- }).then(results => {
- checkOrder(results, [1,2,0,3,4]);
- return searchP({}, { sort: 'url' });
- }).then(results => {
- checkOrder(results, [4,3,0,2,1]);
- return searchP({}, { sort: 'url', descending: true });
- }).then(results => {
- checkOrder(results, [1,2,0,3,4]);
- return addVisits('http://mozilla.com') // for visit conut
- .then(() => addVisits('http://github.com')); // for checking date
- }).then(() => {
- return searchP({}, { sort: 'visitCount' });
- }).then(results => {
- assert.equal(results[5].url, 'http://mozilla.com/',
- 'last entry is the highest visit count');
- return searchP({}, { sort: 'visitCount', descending: true });
- }).then(results => {
- assert.equal(results[0].url, 'http://mozilla.com/',
- 'first entry is the highest visit count');
- return searchP({}, { sort: 'date' });
- }).then(results => {
- assert.equal(results[5].url, 'http://github.com/',
- 'latest visited should be first');
- return searchP({}, { sort: 'date', descending: true });
- }).then(results => {
- assert.equal(results[0].url, 'http://github.com/',
- 'latest visited should be at the end');
- }).then(done);
-
+exports.testSearchSortForHistory = function*(assert) {
function checkOrder (results, nums) {
assert.equal(results.length, nums.length, 'expected return count');
for (let i = 0; i < nums.length; i++) {
assert.equal(results[i].url, places[nums[i]], 'successful order');
}
}
+
+ let places = [
+ 'http://mozilla.com/', 'http://webaud.io/', 'http://mozilla.com/webfwd/',
+ 'http://developer.mozilla.com/', 'http://bandcamp.com/'
+ ];
+ yield addVisits(places);
+
+ let results = yield searchP({}, { sort: 'title' });
+ checkOrder(results, [4,3,0,2,1]);
+
+ results = yield searchP({}, { sort: 'title', descending: true });
+ checkOrder(results, [1,2,0,3,4]);
+
+ results = yield searchP({}, { sort: 'url' });
+ checkOrder(results, [4,3,0,2,1]);
+
+ results = yield searchP({}, { sort: 'url', descending: true });
+ checkOrder(results, [1,2,0,3,4]);
+
+ yield addVisits('http://mozilla.com'); // for visit conut
+ yield addVisits('http://github.com'); // for checking date
+
+ results = yield searchP({}, { sort: 'visitCount' });
+ assert.equal(results[5].url, 'http://mozilla.com/',
+ 'last entry is the highest visit count');
+
+ results = yield searchP({}, { sort: 'visitCount', descending: true });
+ assert.equal(results[0].url, 'http://mozilla.com/',
+ 'first entry is the highest visit count');
+
+ results = yield searchP({}, { sort: 'date' });
+ assert.equal(results[5].url, 'http://github.com/',
+ 'latest visited should be first');
+
+ results = yield searchP({}, { sort: 'date', descending: true });
+ assert.equal(results[0].url, 'http://github.com/',
+ 'latest visited should be at the end');
};
exports.testEmitters = function (assert, done) {
diff --git a/addon-sdk/source/test/addons/places/lib/test-places-host.js b/addon-sdk/source/test/addons/places/lib/test-places-host.js
index ec9addc49dd..3d0b2b3f43a 100644
--- a/addon-sdk/source/test/addons/places/lib/test-places-host.js
+++ b/addon-sdk/source/test/addons/places/lib/test-places-host.js
@@ -21,7 +21,7 @@ require('sdk/places/host/host-bookmarks');
require('sdk/places/host/host-tags');
require('sdk/places/host/host-query');
const {
- invalidResolve, invalidReject, createTree,
+ invalidResolve, createTree,
compareWithHost, createBookmark, createBookmarkTree, resetPlaces
} = require('./places-helper');
@@ -32,7 +32,7 @@ const hsrv = Cc['@mozilla.org/browser/nav-history-service;1'].
const tagsrv = Cc['@mozilla.org/browser/tagging-service;1'].
getService(Ci.nsITaggingService);
-exports.testBookmarksCreate = function (assert, done) {
+exports.testBookmarksCreate = function*(assert) {
let items = [{
title: 'my title',
url: 'http://test-places-host.com/testBookmarksCreate/',
@@ -47,13 +47,11 @@ exports.testBookmarksCreate = function (assert, done) {
group: bmsrv.unfiledBookmarksFolder
}];
- all(items.map(function (item) {
- return send('sdk-places-bookmarks-create', item).then(function (data) {
+ yield all(items.map((item) => {
+ return send('sdk-places-bookmarks-create', item).then((data) => {
compareWithHost(assert, data);
- }, invalidReject(assert));
- })).then(function () {
- done();
- }, invalidReject(assert));
+ });
+ }));
};
exports.testBookmarksCreateFail = function (assert, done) {
diff --git a/addon-sdk/source/test/addons/require/memory.js b/addon-sdk/source/test/addons/require/list.js
similarity index 94%
rename from addon-sdk/source/test/addons/require/memory.js
rename to addon-sdk/source/test/addons/require/list.js
index f8b0c0f255d..9d2566a8717 100644
--- a/addon-sdk/source/test/addons/require/memory.js
+++ b/addon-sdk/source/test/addons/require/list.js
@@ -1,5 +1,6 @@
/* 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.local = true;
diff --git a/addon-sdk/source/test/addons/require/main.js b/addon-sdk/source/test/addons/require/main.js
index d7dd2ae76ff..53391f08b67 100644
--- a/addon-sdk/source/test/addons/require/main.js
+++ b/addon-sdk/source/test/addons/require/main.js
@@ -6,10 +6,10 @@
var { isNative } = require("@loader/options");
exports["test local vs sdk module"] = function (assert) {
- assert.notEqual(require("memory"),
- require("sdk/deprecated/memory"),
+ assert.notEqual(require("list"),
+ require("sdk/util/list"),
"Local module takes the priority over sdk modules");
- assert.ok(require("memory").local,
+ assert.ok(require("list").local,
"this module is really the local one");
}
diff --git a/addon-sdk/source/test/fixtures/index.html b/addon-sdk/source/test/fixtures/index.html
index e5b5859cb69..ba77c6a26fb 100644
--- a/addon-sdk/source/test/fixtures/index.html
+++ b/addon-sdk/source/test/fixtures/index.html
@@ -9,5 +9,10 @@
This is an add-on page test!
+