Bug 907509 - Uplift Addon SDK to fx-team
authorWes Kocher <wkocher@mozilla.com>
Tue, 20 Aug 2013 18:24:12 -0700
changeset 156486 a5d574cfbeacc7810eabeb56b4166516ef6b1314
parent 156485 45b023d6ed731d6249d1527ef7b7ad267f09cbe7
child 156487 e0f58fd2d9bacd0b06ccf41bc2002eee02756ad0
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs907509
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 907509 - Uplift Addon SDK to fx-team
addon-sdk/source/app-extension/bootstrap.js
addon-sdk/source/lib/method/core.js
addon-sdk/source/lib/sdk/addon/installer.js
addon-sdk/source/lib/sdk/addon/runner.js
addon-sdk/source/lib/sdk/addon/window.js
addon-sdk/source/lib/sdk/clipboard.js
addon-sdk/source/lib/sdk/console/plain-text.js
addon-sdk/source/lib/sdk/content/content.js
addon-sdk/source/lib/sdk/content/loader.js
addon-sdk/source/lib/sdk/content/mod.js
addon-sdk/source/lib/sdk/content/symbiont.js
addon-sdk/source/lib/sdk/content/utils.js
addon-sdk/source/lib/sdk/content/worker.js
addon-sdk/source/lib/sdk/core/heritage.js
addon-sdk/source/lib/sdk/core/promise.js
addon-sdk/source/lib/sdk/deprecated/api-utils.js
addon-sdk/source/lib/sdk/deprecated/cortex.js
addon-sdk/source/lib/sdk/deprecated/events/assembler.js
addon-sdk/source/lib/sdk/deprecated/light-traits.js
addon-sdk/source/lib/sdk/deprecated/unit-test.js
addon-sdk/source/lib/sdk/dom/events.js
addon-sdk/source/lib/sdk/dom/events/keys.js
addon-sdk/source/lib/sdk/event/core.js
addon-sdk/source/lib/sdk/event/target.js
addon-sdk/source/lib/sdk/frame/hidden-frame.js
addon-sdk/source/lib/sdk/hotkeys.js
addon-sdk/source/lib/sdk/io/buffer.js
addon-sdk/source/lib/sdk/io/byte-streams.js
addon-sdk/source/lib/sdk/io/fs.js
addon-sdk/source/lib/sdk/io/stream.js
addon-sdk/source/lib/sdk/io/text-streams.js
addon-sdk/source/lib/sdk/keyboard/hotkeys.js
addon-sdk/source/lib/sdk/keyboard/observer.js
addon-sdk/source/lib/sdk/keyboard/utils.js
addon-sdk/source/lib/sdk/lang/type.js
addon-sdk/source/lib/sdk/loader/cuddlefish.js
addon-sdk/source/lib/sdk/loader/sandbox.js
addon-sdk/source/lib/sdk/notifications.js
addon-sdk/source/lib/sdk/page-mod.js
addon-sdk/source/lib/sdk/page-worker.js
addon-sdk/source/lib/sdk/passwords.js
addon-sdk/source/lib/sdk/passwords/utils.js
addon-sdk/source/lib/sdk/places/contract.js
addon-sdk/source/lib/sdk/self.js
addon-sdk/source/lib/sdk/simple-prefs.js
addon-sdk/source/lib/sdk/simple-storage.js
addon-sdk/source/lib/sdk/stylesheet/style.js
addon-sdk/source/lib/sdk/system.js
addon-sdk/source/lib/sdk/system/environment.js
addon-sdk/source/lib/sdk/system/globals.js
addon-sdk/source/lib/sdk/system/runtime.js
addon-sdk/source/lib/sdk/tabs/observer.js
addon-sdk/source/lib/sdk/tabs/utils.js
addon-sdk/source/lib/sdk/test.js
addon-sdk/source/lib/sdk/test/assert.js
addon-sdk/source/lib/sdk/test/harness.js
addon-sdk/source/lib/sdk/test/httpd.js
addon-sdk/source/lib/sdk/test/utils.js
addon-sdk/source/lib/sdk/util/array.js
addon-sdk/source/lib/sdk/util/collection.js
addon-sdk/source/lib/sdk/util/match-pattern.js
addon-sdk/source/lib/sdk/util/registry.js
addon-sdk/source/lib/sdk/util/rules.js
addon-sdk/source/lib/sdk/view/core.js
addon-sdk/source/lib/sdk/widget.js
addon-sdk/source/lib/sdk/windows/observer.js
addon-sdk/source/lib/test.js
addon-sdk/source/lib/toolkit/loader.js
addon-sdk/source/python-lib/cuddlefish/options_defaults.py
addon-sdk/source/python-lib/cuddlefish/options_xul.py
addon-sdk/source/python-lib/cuddlefish/packaging.py
addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/curly-id/lib/main.js
addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/curly-id/package.json
addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/preferences-branch/lib/main.js
addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/preferences-branch/package.json
addon-sdk/source/python-lib/cuddlefish/tests/test_packaging.py
addon-sdk/source/python-lib/cuddlefish/tests/test_xpi.py
addon-sdk/source/python-lib/cuddlefish/xpi.py
addon-sdk/source/test/addons/curly-id/lib/main.js
addon-sdk/source/test/addons/curly-id/package.json
addon-sdk/source/test/addons/predefined-id-with-at/lib/main.js
addon-sdk/source/test/addons/predefined-id-with-at/package.json
addon-sdk/source/test/addons/preferences-branch/lib/main.js
addon-sdk/source/test/addons/preferences-branch/package.json
addon-sdk/source/test/addons/simple-prefs/lib/main.js
addon-sdk/source/test/addons/standard-id/lib/main.js
addon-sdk/source/test/addons/standard-id/package.json
addon-sdk/source/test/fixtures/addon-install-unit-test@mozilla.com.xpi
addon-sdk/source/test/fixtures/chrome-worker/addEventListener.js
addon-sdk/source/test/fixtures/chrome-worker/jsctypes.js
addon-sdk/source/test/fixtures/chrome-worker/onerror.js
addon-sdk/source/test/fixtures/chrome-worker/onmessage.js
addon-sdk/source/test/fixtures/chrome-worker/setTimeout.js
addon-sdk/source/test/fixtures/chrome-worker/xhr.js
addon-sdk/source/test/tabs/test-firefox-tabs.js
addon-sdk/source/test/test-addon-window.js
addon-sdk/source/test/test-api-utils.js
addon-sdk/source/test/test-byte-streams.js
addon-sdk/source/test/test-chrome.js
addon-sdk/source/test/test-clipboard.js
addon-sdk/source/test/test-collection.js
addon-sdk/source/test/test-context-menu.js
addon-sdk/source/test/test-cortex.js
addon-sdk/source/test/test-events.js
addon-sdk/source/test/test-globals.js
addon-sdk/source/test/test-hidden-frame.js
addon-sdk/source/test/test-match-pattern.js
addon-sdk/source/test/test-method.js
addon-sdk/source/test/test-notifications.js
addon-sdk/source/test/test-panel.js
addon-sdk/source/test/test-places-bookmarks.js
addon-sdk/source/test/test-places-host.js
addon-sdk/source/test/test-plain-text-console.js
addon-sdk/source/test/test-promise.js
addon-sdk/source/test/test-self.js
addon-sdk/source/test/test-simple-storage.js
addon-sdk/source/test/test-system-runtime.js
addon-sdk/source/test/test-text-streams.js
addon-sdk/source/test/test-traits-core.js
addon-sdk/source/test/test-unload.js
addon-sdk/source/test/test-widget.js
addon-sdk/source/test/test-window-events.js
addon-sdk/source/test/test-window-loader.js
addon-sdk/source/test/test-window-observer.js
addon-sdk/source/test/windows/test-firefox-windows.js
--- a/addon-sdk/source/app-extension/bootstrap.js
+++ b/addon-sdk/source/app-extension/bootstrap.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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/. */
 
 // @see http://mxr.mozilla.org/mozilla-central/source/js/src/xpconnect/loader/mozJSComponentLoader.cpp
 
 'use strict';
 
@@ -217,18 +216,16 @@ function startup(data, reasonCode) {
       prefixURI: prefixURI,
       // Add-on URI.
       rootURI: rootURI,
       // options used by system module.
       // File to write 'OK' or 'FAIL' (exit code emulation).
       resultFile: options.resultFile,
       // Arguments passed as --static-args
       staticArgs: options.staticArgs,
-      // Add-on preferences branch name
-      preferencesBranch: options.preferencesBranch,
 
       // Arguments related to test runner.
       modules: {
         '@test/options': {
           allTestModules: options.allTestModules,
           iterations: options.iterations,
           filter: options.filter,
           profileMemory: options.profileMemory,
--- a/addon-sdk/source/lib/method/core.js
+++ b/addon-sdk/source/lib/method/core.js
@@ -94,17 +94,17 @@ function Method(hint) {
                  ((type = builtin[(value.constructor || "").name]) &&
                   type[name]) ||
                  // Otherwise assume it's a host object. For host objects
                  // actual method implementations are stored in the `host`
                  // array and only index for the implementation is stored
                  // in the host object's prototype chain. This avoids memory
                  // leaks that otherwise could happen when saving JS objects
                  // on host object.
-                 host[value["!" + name]] ||
+                 host[value["!" + name] || void(0)] ||
                  // Otherwise attempt to lookup implementation for builtins by
                  // a type of the value. This basically makes sure that all
                  // non primitive values will delegate to an `Object`.
                  ((type = builtin[types[typeof(value)]]) && type[name])
 
 
     // If method implementation for the type is still not found then
     // just fallback for default implementation.
--- a/addon-sdk/source/lib/sdk/addon/installer.js
+++ b/addon-sdk/source/lib/sdk/addon/installer.js
@@ -1,18 +1,14 @@
 /* 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/. */
 
 module.metadata = {
-  "stability": "experimental",
-  "engines": {
-    // TODO Fennec Support in bug 894515
-    "Firefox": "*"
-  }
+  "stability": "experimental"
 };
 
 const { Cc, Ci, Cu } = require("chrome");
 const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
 const { defer } = require("../core/promise");
 const { setTimeout } = require("../timers");
 
 /**
--- a/addon-sdk/source/lib/sdk/addon/runner.js
+++ b/addon-sdk/source/lib/sdk/addon/runner.js
@@ -1,25 +1,24 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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/.
- */
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 module.metadata = {
   "stability": "experimental"
 };
 
 const { Cc, Ci } = require('chrome');
 const { descriptor, Sandbox, evaluate, main, resolveURI } = require('toolkit/loader');
 const { once } = require('../system/events');
 const { exit, env, staticArgs } = require('../system');
 const { when: unload } = require('../system/unload');
 const { loadReason } = require('../self');
 const { rootURI } = require("@loader/options");
+const cfxArgs = require("@test/options");
 const globals = require('../system/globals');
 const xulApp = require('../system/xul-app');
 const appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
                         getService(Ci.nsIAppShellService);
 
 const NAME2TOPIC = {
   'Firefox': 'sessionstore-windows-restored',
   'Fennec': 'sessionstore-windows-restored',
@@ -98,25 +97,33 @@ function startup(reason, options) {
 
   // NOTE: Module is intentionally required only now because it relies
   // on existence of hidden window, which does not exists until startup.
   let { ready } = require('../addon/window');
   // Load localization manifest and .properties files.
   // Run the addon even in case of error (best effort approach)
   require('../l10n/loader').
     load(rootURI).
-    then(null, function failure(error) {
+    then(function l10nSuccess() {
+      if (cfxArgs.parseable) {
+        console.info("localization information has loaded successfully.");
+      }
+    }, function l10nFailure(error) {
       console.info("Error while loading localization: " + error.message);
     }).
     then(function onLocalizationReady(data) {
       // Exports data to a pseudo module so that api-utils/l10n/core
       // can get access to it
       definePseudo(options.loader, '@l10n/data', data ? data : null);
       return ready;
     }).then(function() {
+      if (cfxArgs.parseable) {
+        console.info("addon window has loaded successfully.");
+      }
+
       run(options);
     }).then(null, console.exception);
 }
 
 function run(options) {
   try {
     // Try initializing HTML localization before running main module. Just print
     // an exception in case of error, instead of preventing addon to be run.
@@ -125,16 +132,17 @@ function run(options) {
       // disable. Because unit tests are evaluated in a another Loader who
       // doesn't have access to this current loader.
       if (options.main !== 'test-harness/run-tests')
         require('../l10n/html').enable();
     }
     catch(error) {
       console.exception(error);
     }
+
     // Initialize inline options localization, without preventing addon to be
     // run in case of error
     try {
       require('../l10n/prefs');
     }
     catch(error) {
       console.exception(error);
     }
@@ -154,17 +162,18 @@ function run(options) {
       program.main({
         loadReason: loadReason,
         staticArgs: staticArgs
       }, {
         print: function print(_) { dump(_ + '\n') },
         quit: exit
       });
     }
-  } catch (error) {
+  }
+  catch (error) {
     console.exception(error);
     throw error;
   }
 }
 exports.startup = startup;
 
 // If add-on is lunched via `cfx run` we need to use `system.exit` to let
 // cfx know we're done (`cfx test` will take care of exit so we don't do
--- a/addon-sdk/source/lib/sdk/addon/window.js
+++ b/addon-sdk/source/lib/sdk/addon/window.js
@@ -1,13 +1,11 @@
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 module.metadata = {
   "stability": "experimental"
 };
 
 const { Ci, Cc } = require("chrome");
 const { make: makeWindow, getHiddenWindow } = require("../window/utils");
--- a/addon-sdk/source/lib/sdk/clipboard.js
+++ b/addon-sdk/source/lib/sdk/clipboard.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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": "stable",
--- a/addon-sdk/source/lib/sdk/console/plain-text.js
+++ b/addon-sdk/source/lib/sdk/console/plain-text.js
@@ -15,17 +15,17 @@ const { merge } = require("../util/objec
 const { ConsoleAPI } = Cu.import("resource://gre/modules/devtools/Console.jsm");
 
 const DEFAULT_LOG_LEVEL = "error";
 const ADDON_LOG_LEVEL_PREF = "extensions." + self.id + ".sdk.console.logLevel";
 const SDK_LOG_LEVEL_PREF = "extensions.sdk.console.logLevel";
 
 let logLevel = DEFAULT_LOG_LEVEL;
 function setLogLevel() {
-  logLevel = prefs.get(ADDON_LOG_LEVEL_PREF, 
+  logLevel = prefs.get(ADDON_LOG_LEVEL_PREF,
                            prefs.get(SDK_LOG_LEVEL_PREF,
                                      DEFAULT_LOG_LEVEL));
 }
 setLogLevel();
 
 let logLevelObserver = {
   QueryInterface: function(iid) {
     if (!iid.equals(Ci.nsIObserver) &&
--- a/addon-sdk/source/lib/sdk/content/content.js
+++ b/addon-sdk/source/lib/sdk/content/content.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/content/loader.js
+++ b/addon-sdk/source/lib/sdk/content/loader.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/content/mod.js
+++ b/addon-sdk/source/lib/sdk/content/mod.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/content/symbiont.js
+++ b/addon-sdk/source/lib/sdk/content/symbiont.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/content/utils.js
+++ b/addon-sdk/source/lib/sdk/content/utils.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/content/worker.js
+++ b/addon-sdk/source/lib/sdk/content/worker.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/core/heritage.js
+++ b/addon-sdk/source/lib/sdk/core/heritage.js
@@ -1,14 +1,11 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 module.metadata = {
   "stability": "unstable"
 };
 
 var getPrototypeOf = Object.getPrototypeOf;
 var getNames = Object.getOwnPropertyNames;
--- a/addon-sdk/source/lib/sdk/core/promise.js
+++ b/addon-sdk/source/lib/sdk/core/promise.js
@@ -1,12 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
-/*jshint undef: true es5: true node: true browser: true devel: true
-         forin: true latedef: false */
-/*global define: true, Cu: true, __URI__: true */
 ;(function(id, factory) { // Module boilerplate :(
   if (typeof(define) === 'function') { // RequireJS
     define(factory);
   } else if (typeof(require) === 'function') { // CommonJS
     factory.call(this, require, exports, module);
   } else if (String(this).indexOf('BackstagePass') >= 0) { // JSM
     this[factory.name] = {};
     try {
--- a/addon-sdk/source/lib/sdk/deprecated/api-utils.js
+++ b/addon-sdk/source/lib/sdk/deprecated/api-utils.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/deprecated/cortex.js
+++ b/addon-sdk/source/lib/sdk/deprecated/cortex.js
@@ -1,10 +1,9 @@
-/* vim:set ts=2 sw=2 sts=2
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/sdk/deprecated/events/assembler.js
+++ b/addon-sdk/source/lib/sdk/deprecated/events/assembler.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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 { Trait } = require("../light-traits");
 const { removeListener, on } = require("../../dom/events");
--- a/addon-sdk/source/lib/sdk/deprecated/light-traits.js
+++ b/addon-sdk/source/lib/sdk/deprecated/light-traits.js
@@ -1,10 +1,9 @@
-/* vim:ts=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/sdk/deprecated/unit-test.js
+++ b/addon-sdk/source/lib/sdk/deprecated/unit-test.js
@@ -1,10 +1,9 @@
-/* vim:st=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/sdk/dom/events.js
+++ b/addon-sdk/source/lib/sdk/dom/events.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/dom/events/keys.js
+++ b/addon-sdk/source/lib/sdk/dom/events/keys.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/event/core.js
+++ b/addon-sdk/source/lib/sdk/event/core.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/event/target.js
+++ b/addon-sdk/source/lib/sdk/event/target.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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": "stable"
--- a/addon-sdk/source/lib/sdk/frame/hidden-frame.js
+++ b/addon-sdk/source/lib/sdk/frame/hidden-frame.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/hotkeys.js
+++ b/addon-sdk/source/lib/sdk/hotkeys.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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": "stable"
--- a/addon-sdk/source/lib/sdk/io/buffer.js
+++ b/addon-sdk/source/lib/sdk/io/buffer.js
@@ -1,12 +1,11 @@
 /* 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/.
- */
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 module.metadata = {
   "stability": "experimental"
 };
 
 
 const { Cu } = require("chrome");
--- a/addon-sdk/source/lib/sdk/io/byte-streams.js
+++ b/addon-sdk/source/lib/sdk/io/byte-streams.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/sdk/io/fs.js
+++ b/addon-sdk/source/lib/sdk/io/fs.js
@@ -1,12 +1,11 @@
 /* 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/.
- */
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 module.metadata = {
   "stability": "experimental"
 };
 
 const { Cc, Ci, CC } = require("chrome");
 
@@ -922,9 +921,9 @@ exports.watchFile = watchFile;
 function unwatchFile(path, listener) {
   throw Error("Not implemented");
 }
 exports.unwatchFile = unwatchFile;
 
 function watch(path, options, listener) {
   throw Error("Not implemented");
 }
-exports.watch = watch;
\ No newline at end of file
+exports.watch = watch;
--- a/addon-sdk/source/lib/sdk/io/stream.js
+++ b/addon-sdk/source/lib/sdk/io/stream.js
@@ -1,12 +1,11 @@
 /* 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/.
- */
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 module.metadata = {
   "stability": "experimental"
 };
 
 const { CC, Cc, Ci, Cu, Cr, components } = require("chrome");
 const { EventTarget } = require("../event/target");
--- a/addon-sdk/source/lib/sdk/io/text-streams.js
+++ b/addon-sdk/source/lib/sdk/io/text-streams.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/sdk/keyboard/hotkeys.js
+++ b/addon-sdk/source/lib/sdk/keyboard/hotkeys.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/keyboard/observer.js
+++ b/addon-sdk/source/lib/sdk/keyboard/observer.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/keyboard/utils.js
+++ b/addon-sdk/source/lib/sdk/keyboard/utils.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/lang/type.js
+++ b/addon-sdk/source/lib/sdk/lang/type.js
@@ -1,10 +1,9 @@
-/* vim:ts=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/sdk/loader/cuddlefish.js
+++ b/addon-sdk/source/lib/sdk/loader/cuddlefish.js
@@ -1,14 +1,11 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 module.metadata = {
   "stability": "unstable"
 };
 
 // This module is manually loaded by bootstrap.js in a sandbox and immediatly
 // put in module cache so that it is never loaded in any other way.
--- a/addon-sdk/source/lib/sdk/loader/sandbox.js
+++ b/addon-sdk/source/lib/sdk/loader/sandbox.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/notifications.js
+++ b/addon-sdk/source/lib/sdk/notifications.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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": "stable"
 };
--- a/addon-sdk/source/lib/sdk/page-mod.js
+++ b/addon-sdk/source/lib/sdk/page-mod.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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": "stable"
 };
--- a/addon-sdk/source/lib/sdk/page-worker.js
+++ b/addon-sdk/source/lib/sdk/page-worker.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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": "stable"
 };
--- a/addon-sdk/source/lib/sdk/passwords.js
+++ b/addon-sdk/source/lib/sdk/passwords.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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": "stable"
 };
--- a/addon-sdk/source/lib/sdk/passwords/utils.js
+++ b/addon-sdk/source/lib/sdk/passwords/utils.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/places/contract.js
+++ b/addon-sdk/source/lib/sdk/places/contract.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/self.js
+++ b/addon-sdk/source/lib/sdk/self.js
@@ -1,10 +1,9 @@
-/* vim:st=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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": "stable"
 };
 
--- a/addon-sdk/source/lib/sdk/simple-prefs.js
+++ b/addon-sdk/source/lib/sdk/simple-prefs.js
@@ -6,21 +6,19 @@
 module.metadata = {
   "stability": "experimental"
 };
 
 const { emit, off } = require("./event/core");
 const { when: unload } = require("./system/unload");
 const { PrefsTarget } = require("./preferences/event-target");
 const { id } = require("./self");
-const { preferencesBranch } = require('@loader/options');
-
 const observers = require("./deprecated/observer-service");
 
-const ADDON_BRANCH = "extensions." + preferencesBranch + ".";
+const ADDON_BRANCH = "extensions." + id + ".";
 const BUTTON_PRESSED = id + "-cmdPressed";
 
 const target = PrefsTarget({ branchName: ADDON_BRANCH });
 
 // Listen to clicks on buttons
 function buttonClick(subject, data) {
   emit(target, data);
 }
--- a/addon-sdk/source/lib/sdk/simple-storage.js
+++ b/addon-sdk/source/lib/sdk/simple-storage.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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": "stable"
 };
--- a/addon-sdk/source/lib/sdk/stylesheet/style.js
+++ b/addon-sdk/source/lib/sdk/stylesheet/style.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/system.js
+++ b/addon-sdk/source/lib/sdk/system.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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"
--- a/addon-sdk/source/lib/sdk/system/environment.js
+++ b/addon-sdk/source/lib/sdk/system/environment.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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": "stable"
--- a/addon-sdk/source/lib/sdk/system/globals.js
+++ b/addon-sdk/source/lib/sdk/system/globals.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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"
--- a/addon-sdk/source/lib/sdk/system/runtime.js
+++ b/addon-sdk/source/lib/sdk/system/runtime.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/tabs/observer.js
+++ b/addon-sdk/source/lib/sdk/tabs/observer.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/tabs/utils.js
+++ b/addon-sdk/source/lib/sdk/tabs/utils.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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'
 };
--- a/addon-sdk/source/lib/sdk/test.js
+++ b/addon-sdk/source/lib/sdk/test.js
@@ -1,10 +1,9 @@
-/* vim:ts=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/sdk/test/assert.js
+++ b/addon-sdk/source/lib/sdk/test/assert.js
@@ -1,10 +1,9 @@
-/* vim:ts=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
 
--- a/addon-sdk/source/lib/sdk/test/harness.js
+++ b/addon-sdk/source/lib/sdk/test/harness.js
@@ -421,17 +421,17 @@ function nextIteration(tests) {
     setTimeout(cleanup, 0);
   }
 }
 
 var POINTLESS_ERRORS = [
   'Invalid chrome URI:',
   'OpenGL LayerManager Initialized Succesfully.',
   '[JavaScript Error: "TelemetryStopwatch:',
-  '[JavaScript Warning: "ReferenceError: reference to undefined property',
+  'reference to undefined property',
   '[JavaScript Error: "The character encoding of the HTML document was ' +
     'not declared.',
   '[Javascript Warning: "Error: Failed to preserve wrapper of wrapped ' +
     'native weak map key',
   '[JavaScript Warning: "Duplicate resource declaration for',
   'file: "chrome://browser/content/',
   'file: "chrome://global/content/',
   '[JavaScript Warning: "The character encoding of a framed document was ' +
--- a/addon-sdk/source/lib/sdk/test/httpd.js
+++ b/addon-sdk/source/lib/sdk/test/httpd.js
@@ -1,10 +1,8 @@
-/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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/. */
 
 /*
 * An implementation of an HTTP server both as a loadable script and as an XPCOM
 * component. See the accompanying README file for user documentation on
 * httpd.js.
--- a/addon-sdk/source/lib/sdk/test/utils.js
+++ b/addon-sdk/source/lib/sdk/test/utils.js
@@ -1,10 +1,9 @@
-/* vim:ts=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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'
 };
--- a/addon-sdk/source/lib/sdk/util/array.js
+++ b/addon-sdk/source/lib/sdk/util/array.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/util/collection.js
+++ b/addon-sdk/source/lib/sdk/util/collection.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/util/match-pattern.js
+++ b/addon-sdk/source/lib/sdk/util/match-pattern.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/util/registry.js
+++ b/addon-sdk/source/lib/sdk/util/registry.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/sdk/util/rules.js
+++ b/addon-sdk/source/lib/sdk/util/rules.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/view/core.js
+++ b/addon-sdk/source/lib/sdk/view/core.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
--- a/addon-sdk/source/lib/sdk/widget.js
+++ b/addon-sdk/source/lib/sdk/widget.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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";
 
 // The widget module currently supports only Firefox.
 // See: https://bugzilla.mozilla.org/show_bug.cgi?id=560716
--- a/addon-sdk/source/lib/sdk/windows/observer.js
+++ b/addon-sdk/source/lib/sdk/windows/observer.js
@@ -1,9 +1,8 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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"
 };
--- a/addon-sdk/source/lib/test.js
+++ b/addon-sdk/source/lib/test.js
@@ -1,10 +1,9 @@
-/* vim:ts=2:sts=2:sw=2:
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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"
 };
--- a/addon-sdk/source/lib/toolkit/loader.js
+++ b/addon-sdk/source/lib/toolkit/loader.js
@@ -1,13 +1,12 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
 /* 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/.
- */
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 ;(function(id, factory) { // Module boilerplate :(
   if (typeof(define) === 'function') { // RequireJS
     define(factory);
   } else if (typeof(require) === 'function') { // CommonJS
     factory.call(this, require, exports, module);
   } else if (~String(this).indexOf('BackstagePass')) { // JSM
     this[factory.name] = {};
     factory(function require(uri) {
--- a/addon-sdk/source/python-lib/cuddlefish/options_defaults.py
+++ b/addon-sdk/source/python-lib/cuddlefish/options_defaults.py
@@ -1,13 +1,13 @@
 # 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/.
 
-def parse_options_defaults(options, preferencesBranch):
+def parse_options_defaults(options, jetpack_id):
     # this returns a unicode string
     pref_list = []
 
     for pref in options:
         if ('value' in pref):
             value = pref["value"]
 
             if isinstance(value, float):
@@ -16,11 +16,11 @@ def parse_options_defaults(options, pref
                 value = str(pref["value"]).lower()
             elif isinstance(value, str): # presumably ASCII
                 value = "\"" + unicode(pref["value"]) + "\""
             elif isinstance(value, unicode):
                 value = "\"" + pref["value"] + "\""
             else:
                 value = str(pref["value"])
 
-            pref_list.append("pref(\"extensions." + preferencesBranch + "." + pref["name"] + "\", " + value + ");")
+            pref_list.append("pref(\"extensions." + jetpack_id + "." + pref["name"] + "\", " + value + ");")
 
     return "\n".join(pref_list) + "\n"
--- a/addon-sdk/source/python-lib/cuddlefish/options_xul.py
+++ b/addon-sdk/source/python-lib/cuddlefish/options_xul.py
@@ -40,30 +40,30 @@ def validate_prefs(options):
             for item in pref["options"]:
                 if ("value" not in item):
                     raise MissingPrefAttr("'options' requires a 'value'")
                 if ("label" not in item):
                     raise MissingPrefAttr("'options' requires a 'label'")
 
         # TODO: Check that pref["type"] matches default value type
 
-def parse_options(options, jetpack_id, preferencesBranch):
+def parse_options(options, jetpack_id):
     doc = Document()
     root = doc.createElement("vbox")
     root.setAttribute("xmlns", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
     doc.appendChild(root)
 
     for pref in options:
         if ("hidden" in pref and pref["hidden"] == True):
             continue;
 
         setting = doc.createElement("setting")
         setting.setAttribute("pref-name", pref["name"])
         setting.setAttribute("data-jetpack-id", jetpack_id)
-        setting.setAttribute("pref", "extensions." + preferencesBranch + "." + pref["name"])
+        setting.setAttribute("pref", "extensions." + jetpack_id + "." + pref["name"])
         setting.setAttribute("type", pref["type"])
         setting.setAttribute("title", pref["title"])
 
         if ("description" in pref):
             setting.appendChild(doc.createTextNode(pref["description"]))
 
         if (pref["type"] == "control"):
             button = doc.createElement("button")
--- a/addon-sdk/source/python-lib/cuddlefish/packaging.py
+++ b/addon-sdk/source/python-lib/cuddlefish/packaging.py
@@ -391,31 +391,16 @@ def generate_build_for_target(pkg_cfg, t
 
     if 'icon64' in target_cfg:
         build['icon64'] = os.path.join(target_cfg.root_dir, target_cfg.icon64)
         del target_cfg['icon64']
 
     if ('preferences' in target_cfg):
         build['preferences'] = target_cfg.preferences
 
-    if 'id' in target_cfg:
-        # NOTE: logic duplicated from buildJID()
-        jid = target_cfg['id']
-        if not ('@' in jid or jid.startswith('{')):
-            jid += '@jetpack'
-        build['preferencesBranch'] = jid
-
-    if 'preferences-branch' in target_cfg:
-        # check it's a non-empty, valid branch name
-        preferencesBranch = target_cfg['preferences-branch']
-        if re.match('^[\w{@}-]+$', preferencesBranch):
-            build['preferencesBranch'] = preferencesBranch
-        elif not is_running_tests:
-            print >>sys.stderr, "IGNORING preferences-branch (not a valid branch name)"
-
     return build
 
 def _get_files_in_dir(path):
     data = {}
     files = os.listdir(path)
     for filename in files:
         fullpath = os.path.join(path, filename)
         if os.path.isdir(fullpath):
deleted file mode 100644
--- a/addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/curly-id/lib/main.js
+++ /dev/null
@@ -1,4 +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/. */
-
deleted file mode 100644
--- a/addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/curly-id/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-    "id": "{34a1eae1-c20a-464f-9b0e-000000000000}",
-    "fullName": "curly ID test",
-    "author": "Tomislav Jovanovic",
-
-    "preferences": [{
-        "name": "test13",
-        "type": "integer",
-        "title": "test13",
-        "value": 26
-    }],
-
-    "preferences-branch": "invalid^branch*name"
-}
deleted file mode 100644
--- a/addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/preferences-branch/lib/main.js
+++ /dev/null
@@ -1,4 +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/. */
-
deleted file mode 100644
--- a/addon-sdk/source/python-lib/cuddlefish/tests/preferences-files/packages/preferences-branch/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-    "id": "test-preferences-branch",
-    "fullName": "preferences-branch test",
-    "author": "Tomislav Jovanovic",
-
-    "preferences": [{
-        "name": "test42",
-        "type": "bool",
-        "title": "test42",
-        "value": true
-    }],
-
-    "preferences-branch": "human-readable"
-}
--- a/addon-sdk/source/python-lib/cuddlefish/tests/test_packaging.py
+++ b/addon-sdk/source/python-lib/cuddlefish/tests/test_packaging.py
@@ -17,18 +17,17 @@ def get_configs(pkg_name, dirname='stati
     if not (os.path.exists(pkg_path) and os.path.isdir(pkg_path)):
         raise Exception('path does not exist: %s' % pkg_path)
     target_cfg = packaging.get_config_in_dir(pkg_path)
     pkg_cfg = packaging.build_config(root_path, target_cfg)
     deps = packaging.get_deps_for_targets(pkg_cfg, [pkg_name])
     build = packaging.generate_build_for_target(
         pkg_cfg=pkg_cfg,
         target=pkg_name,
-        deps=deps,
-        is_running_tests=True,
+        deps=deps
         )
     return Bunch(target_cfg=target_cfg, pkg_cfg=pkg_cfg, build=build)
 
 class PackagingTests(unittest.TestCase):
     def test_bug_588661(self):
         configs = get_configs('foo', 'bug-588661-files')
         self.assertEqual(configs.build.loader,
                          'foo/lib/foo-loader.js')
--- a/addon-sdk/source/python-lib/cuddlefish/tests/test_xpi.py
+++ b/addon-sdk/source/python-lib/cuddlefish/tests/test_xpi.py
@@ -35,30 +35,30 @@ class PrefsTests(unittest.TestCase):
     def tearDown(self):
         if self.xpi:
             self.xpi.close()
         if self.xpiname and os.path.exists(self.xpiname):
             os.remove(self.xpiname)
 
     def testPackageWithSimplePrefs(self):
         self.makexpi('simple-prefs')
-        packageName = 'jid1-fZHqN9JfrDBa8A@jetpack'
         self.failUnless('options.xul' in self.xpi.namelist())
         optsxul = self.xpi.read('options.xul').decode("utf-8")
-        self.failUnlessEqual(self.xpi_harness_options["jetpackID"], packageName)
-        self.failUnlessEqual(self.xpi_harness_options["preferencesBranch"], packageName)
+        self.failUnlessEqual(self.xpi_harness_options["jetpackID"],
+                             "jid1-fZHqN9JfrDBa8A@jetpack")
 
         root = ElementTree.XML(optsxul.encode('utf-8'))
 
         xulNamespacePrefix = \
             "{http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul}"
         
         settings = root.findall(xulNamespacePrefix + 'setting')
 
         def assertPref(setting, name, prefType, title):
+            packageName = 'jid1-fZHqN9JfrDBa8A@jetpack'
             self.failUnlessEqual(setting.get('data-jetpack-id'), packageName)
             self.failUnlessEqual(setting.get('pref'),
                                  'extensions.' + packageName + '.' + name)
             self.failUnlessEqual(setting.get('pref-name'), name)
             self.failUnlessEqual(setting.get('type'), prefType)
             self.failUnlessEqual(setting.get('title'), title)
 
         assertPref(settings[0], 'test', 'bool', u't\u00EBst')
@@ -83,70 +83,24 @@ class PrefsTests(unittest.TestCase):
         prefsjs = self.xpi.read('defaults/preferences/prefs.js').decode("utf-8")
         exp = [u'pref("extensions.jid1-fZHqN9JfrDBa8A@jetpack.test", false);',
                u'pref("extensions.jid1-fZHqN9JfrDBa8A@jetpack.test2", "\u00FCnic\u00F8d\u00E9");',
                u'pref("extensions.jid1-fZHqN9JfrDBa8A@jetpack.test3", "1");',
                u'pref("extensions.jid1-fZHqN9JfrDBa8A@jetpack.test4", "red");',
                ]
         self.failUnlessEqual(prefsjs, "\n".join(exp)+"\n")
 
-    def testPackageWithPreferencesBranch(self):
-        self.makexpi('preferences-branch')
-        self.failUnless('options.xul' in self.xpi.namelist())
-        optsxul = self.xpi.read('options.xul').decode("utf-8")
-        self.failUnlessEqual(self.xpi_harness_options["preferencesBranch"], 
-                             "human-readable")
-
-        root = ElementTree.XML(optsxul.encode('utf-8'))
-        xulNamespacePrefix = \
-            "{http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul}"
-        
-        setting = root.find(xulNamespacePrefix + 'setting')
-        self.failUnlessEqual(setting.get('pref'),
-                             'extensions.human-readable.test42')
-
-        prefsjs = self.xpi.read('defaults/preferences/prefs.js').decode("utf-8")
-        self.failUnlessEqual(prefsjs, 
-                            'pref("extensions.human-readable.test42", true);\n')
-
     def testPackageWithNoPrefs(self):
         self.makexpi('no-prefs')
         self.failIf('options.xul' in self.xpi.namelist())
         self.failUnlessEqual(self.xpi_harness_options["jetpackID"],
                              "jid1-fZHqN9JfrDBa8A@jetpack")
         prefsjs = self.xpi.read('defaults/preferences/prefs.js').decode("utf-8")
         self.failUnlessEqual(prefsjs, "")
 
-    def testPackageWithInvalidPreferencesBranch(self):
-        self.makexpi('curly-id')
-        self.failIfEqual(self.xpi_harness_options["preferencesBranch"], 
-                         "invalid^branch*name")
-        self.failUnlessEqual(self.xpi_harness_options["preferencesBranch"], 
-                             "{34a1eae1-c20a-464f-9b0e-000000000000}")
-
-    def testPackageWithCurlyID(self):
-        self.makexpi('curly-id')
-        self.failUnlessEqual(self.xpi_harness_options["jetpackID"], 
-                             "{34a1eae1-c20a-464f-9b0e-000000000000}")
-
-        self.failUnless('options.xul' in self.xpi.namelist())
-        optsxul = self.xpi.read('options.xul').decode("utf-8")
-
-        root = ElementTree.XML(optsxul.encode('utf-8'))
-        xulNamespacePrefix = \
-            "{http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul}"
-        
-        setting = root.find(xulNamespacePrefix + 'setting')
-        self.failUnlessEqual(setting.get('pref'),
-                             'extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test13')
-
-        prefsjs = self.xpi.read('defaults/preferences/prefs.js').decode("utf-8")
-        self.failUnlessEqual(prefsjs, 
-                            'pref("extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test13", 26);\n')
-
 
 class Bug588119Tests(unittest.TestCase):
     def makexpi(self, pkg_name):
         self.xpiname = "%s.xpi" % pkg_name
         create_xpi(self.xpiname, pkg_name, 'bug-588119-files')
         self.xpi = zipfile.ZipFile(self.xpiname, 'r')
         options = self.xpi.read('harness-options.json')
         self.xpi_harness_options = json.loads(options)
--- a/addon-sdk/source/python-lib/cuddlefish/xpi.py
+++ b/addon-sdk/source/python-lib/cuddlefish/xpi.py
@@ -72,25 +72,24 @@ def build_xpi(template_root_dir, manifes
 
     # Handle simple-prefs
     if 'preferences' in harness_options:
         from options_xul import parse_options, validate_prefs
 
         validate_prefs(harness_options["preferences"])
 
         opts_xul = parse_options(harness_options["preferences"],
-                                 harness_options["jetpackID"],
-                                 harness_options["preferencesBranch"])
+                                 harness_options["jetpackID"])
         open('.options.xul', 'wb').write(opts_xul.encode("utf-8"))
         zf.write('.options.xul', 'options.xul')
         os.remove('.options.xul')
 
         from options_defaults import parse_options_defaults
         prefs_js = parse_options_defaults(harness_options["preferences"],
-                                          harness_options["preferencesBranch"])
+                                          harness_options["jetpackID"])
         open('.prefs.js', 'wb').write(prefs_js.encode("utf-8"))
 
     else:
         open('.prefs.js', 'wb').write("")
 
     zf.write('.prefs.js', 'defaults/preferences/prefs.js')
     os.remove('.prefs.js')
 
deleted file mode 100644
--- a/addon-sdk/source/test/addons/curly-id/lib/main.js
+++ /dev/null
@@ -1,45 +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 { id } = require('sdk/self');
-const simple = require('sdk/simple-prefs');
-const service = require('sdk/preferences/service');
-const { preferencesBranch } = require('@loader/options');
-const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm');
-
-exports.testCurlyID = function(assert) {
-  assert.equal(id, '{34a1eae1-c20a-464f-9b0e-000000000000}', 'curly ID is curly');
-
-  assert.equal(simple.prefs.test13, 26, 'test13 is 26');
-
-  simple.prefs.test14 = '15';
-  assert.equal(service.get('extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test14'), '15', 'test14 is 15');
-
-  assert.equal(service.get('extensions.{34a1eae1-c20a-464f-9b0e-000000000000}.test14'), simple.prefs.test14, 'simple test14 also 15');
-  
-}
-
-exports.testInvalidPreferencesBranch = function(assert) {
-  assert.notEqual(preferencesBranch, 'invalid^branch*name', 'invalid preferences-branch value ignored');
-
-  assert.equal(preferencesBranch, '{34a1eae1-c20a-464f-9b0e-000000000000}', 'preferences-branch is {34a1eae1-c20a-464f-9b0e-000000000000}');
-
-}
-
-// from `/test/test-self.js`, adapted to `sdk/test/assert` API
-exports.testSelfID = function(assert, done) {
-
-  assert.equal(typeof(id), 'string', 'self.id is a string');
-  assert.ok(id.length > 0, 'self.id not empty');
-
-  AddonManager.getAddonByID(id, function(addon) {
-    assert.ok(addon, 'found addon with self.id');
-    done();
-  });
-
-}
-
-require('sdk/test/runner').runTestsFromModule(module);
deleted file mode 100644
--- a/addon-sdk/source/test/addons/curly-id/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-    "id": "{34a1eae1-c20a-464f-9b0e-000000000000}",
-    "fullName": "curly ID test",
-    "author": "Tomislav Jovanovic",
-
-    "preferences": [{
-        "name": "test13",
-        "type": "integer",
-        "title": "test13",
-        "value": 26
-    }],
-
-    "preferences-branch": "invalid^branch*name"
-}
deleted file mode 100644
--- a/addon-sdk/source/test/addons/predefined-id-with-at/lib/main.js
+++ /dev/null
@@ -1,35 +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 { id } = require('sdk/self');
-const simple = require('sdk/simple-prefs');
-const service = require('sdk/preferences/service');
-const { preferencesBranch } = require('@loader/options');
-const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm', {});
-
-const expected_id = 'predefined-id@test';
-
-exports.testExpectedID = function(assert) {
-  assert.equal(id, expected_id, 'ID is as expected');
-  assert.equal(preferencesBranch, expected_id, 'preferences-branch is ' + expected_id);
-
-  assert.equal(simple.prefs.test, 5, 'test pref is 5');
-
-  simple.prefs.test2 = '25';
-  assert.equal(service.get('extensions.'+expected_id+'.test2'), '25', 'test pref is 25');
-  assert.equal(service.get('extensions.'+expected_id+'.test2'), simple.prefs.test2, 'test pref is 25');
-}
-
-exports.testSelfID = function(assert, done) {
-  assert.equal(typeof(id), 'string', 'self.id is a string');
-  assert.ok(id.length > 0, 'self.id not empty');
-
-  AddonManager.getAddonByID(id, function(addon) {
-    assert.equal(addon.id, id, 'found addon with self.id');
-    done();
-  });
-}
-
-require('sdk/test/runner').runTestsFromModule(module);
deleted file mode 100644
--- a/addon-sdk/source/test/addons/predefined-id-with-at/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
-    "id": "predefined-id@test",
-    "fullName": "predefined ID test",
-    "author": "Erik Vold",
-    "preferences": [{
-        "name": "test",
-        "type": "integer",
-        "title": "test",
-        "value": 5
-    }]
-}
deleted file mode 100644
--- a/addon-sdk/source/test/addons/preferences-branch/lib/main.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';
-
-const { id } = require('sdk/self');
-const simple = require('sdk/simple-prefs');
-const service = require('sdk/preferences/service');
-const { preferencesBranch } = require('@loader/options');
-const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm');
-
-exports.testPreferencesBranch = function(assert) {
-  assert.equal(preferencesBranch, 'human-readable', 'preferencesBranch is human-readable');
-
-  assert.equal(simple.prefs.test42, true, 'test42 is true');
-
-  simple.prefs.test43 = 'movie';
-  assert.equal(service.get('extensions.human-readable.test43'), 'movie', 'test43 is a movie');
-  
-}
-
-// from `/test/test-self.js`, adapted to `sdk/test/assert` API
-exports.testSelfID = function(assert, done) {
-
-  assert.equal(typeof(id), 'string', 'self.id is a string');
-  assert.ok(id.length > 0, 'self.id not empty');
-
-  AddonManager.getAddonByID(id, function(addon) {
-    assert.ok(addon, 'found addon with self.id');
-    done();
-  });
-
-}
-
-require('sdk/test/runner').runTestsFromModule(module);
deleted file mode 100644
--- a/addon-sdk/source/test/addons/preferences-branch/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-    "id": "test-preferences-branch",
-    "fullName": "preferences-branch test",
-    "author": "Tomislav Jovanovic",
-
-    "preferences": [{
-        "name": "test42",
-        "type": "bool",
-        "title": "test42",
-        "value": true
-    }],
-
-    "preferences-branch": "human-readable"
-}
--- a/addon-sdk/source/test/addons/simple-prefs/lib/main.js
+++ b/addon-sdk/source/test/addons/simple-prefs/lib/main.js
@@ -3,17 +3,16 @@
  * 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 self = require('sdk/self');
 const tabs = require('sdk/tabs');
-const { preferencesBranch } = require('@loader/options');
 
 const { AddonManager } = Cu.import('resource://gre/modules/AddonManager.jsm', {});
 
 exports.testDefaultValues = function (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');
 }
@@ -85,13 +84,9 @@ if (app.is('Firefox')) {
               tab.close(done);
             }
           });
       	}
       });
   }
 }
 
-exports.testDefaultPreferencesBranch = function(assert) {
-  assert.equal(preferencesBranch, self.id, 'preferencesBranch default the same as self.id');
-}
-
 require('sdk/test/runner').runTestsFromModule(module);
deleted file mode 100644
--- a/addon-sdk/source/test/addons/standard-id/lib/main.js
+++ /dev/null
@@ -1,45 +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 { id } = require('sdk/self');
-const simple = require('sdk/simple-prefs');
-const service = require('sdk/preferences/service');
-const { preferencesBranch } = require('@loader/options');
-const { AddonManager } = require('chrome').Cu.import('resource://gre/modules/AddonManager.jsm');
-
-exports.testStandardID = function(assert) {
-  assert.equal(id, 'standard-id@jetpack', 'standard ID is standard');
-
-  assert.equal(simple.prefs.test13, 26, 'test13 is 26');
-
-  simple.prefs.test14 = '15';
-  assert.equal(service.get('extensions.standard-id@jetpack.test14'), '15', 'test14 is 15');
-
-  assert.equal(service.get('extensions.standard-id@jetpack.test14'), simple.prefs.test14, 'simple test14 also 15');
-  
-}
-
-exports.testInvalidPreferencesBranch = function(assert) {
-  assert.notEqual(preferencesBranch, 'invalid^branch*name', 'invalid preferences-branch value ignored');
-
-  assert.equal(preferencesBranch, 'standard-id@jetpack', 'preferences-branch is standard-id@jetpack');
-
-}
-
-// from `/test/test-self.js`, adapted to `sdk/test/assert` API
-exports.testSelfID = function(assert, done) {
-
-  assert.equal(typeof(id), 'string', 'self.id is a string');
-  assert.ok(id.length > 0, 'self.id not empty');
-
-  AddonManager.getAddonByID(id, function(addon) {
-    assert.ok(addon, 'found addon with self.id');
-    done();
-  });
-
-}
-
-require('sdk/test/runner').runTestsFromModule(module);
deleted file mode 100644
--- a/addon-sdk/source/test/addons/standard-id/package.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-    "id": "standard-id",
-    "fullName": "standard ID test",
-    "author": "Tomislav Jovanovic",
-
-    "preferences": [{
-        "name": "test13",
-        "type": "integer",
-        "title": "test13",
-        "value": 26
-    }],
-
-    "preferences-branch": "invalid^branch*name"
-}
index c7cfccd7abd114c59a8b12f1fc9e8caf5803b081..48945af0577a41d56f7b789fb64331bcacf8b388
GIT binary patch
literal 1692
zc${^VdpOg39LImmWsEHMOLTCK!pvwz=r;Flm6j<)rjlEmC?zVl(L$CI&84ssB9B`r
zj!VSJu*PVktVm->Xs*Yhp65Judd~Oze4p><`^V?~{p0g~y`3;1F+~6XzyO^nVU1j=
zeVGRWfOIeb$N-xFZxZQT$hlxb5Zpfm?<@s?klrG=^>h9r1P~FM69Is4-NpFEV2%T{
zZbr$&A_{`3I_TcXX3GoAox#<K<?zk+xEQ_dG-hWa)zM(Jeo!|`q`Wd5p|Y2?vN)H~
zS3E4!IS<-Qn$p{rexUVfd5cj*X6MV}oLgF%jmLenkc;Z|Zx8ZJ>#>ucmJI409!?}<
zq~BM+6xH6w$@{vYLq0-V6ZQZFRc`F%U+A#9Xe|jo&X6m(9l2zIH;pOiaIzd=dz%-E
zUEYvX+wA*UWXHoeT;N^}x$P}~vK!K54CQbN@ntyNCz+g^^<J<zzLWRGNd$IGoD4xf
z+F``=Py}~{k%hhIQ;_==(u{ch{dg4WcMle%d{$PNh8Zo!1|;w7v9J#Z>|sKXOlmJQ
zNg3g4LzUh#NM&a0CEpu;r^WM|{fwaP+TFaYkm%F(`IPB1HBp>dY=UvBt-ZWEbwK~4
z2@EP6H(|f7P&`Jydn~0D{Rwa60yZqSD|+A=m0A=H$9&p!8}>jY`^AMP%W9{KxNnWR
z^bh*ycm;mx<|<sD+xNl-W2`?U(f0^z>zh?i!ddDDnGR@h<=bG=Z2iGl`cvP>^XVl<
zNML0eD1pPTa6RWT=2h*`jn>==kVQoRuK0tcURPX#N!64@-}1GlX|i*UfzZy)lsko=
zzag%<Tw_3XHdzoPZ}6sD>7&OE)iDr3=DVZ>&lKO(F2Qq#Q$T8k&rV*6Fk6zi@Q8^s
z%pVmi=@-9VQ8xIv+rchId)J_U<8Oz{AhydY%CZ9+IThp+Fxu^hR9BI^LB)Lr0qoc0
zr7?J#aNlTcsmA;r8(U?D4Vr<Ou)3bfL`Cy<V%if;uy+U*8hq)uP?SC^R>X|g&{V4%
zcK;#MzuA|RYDJx<_9FVTRN6|YyrcH3AXWT|Fl7sxe7?0BH`-G`VyPMAw?m-AA2umn
z%C6DnM*~qQEochN*FBD*graO6RLDDv^{Tx`oSt&y^c~viADSOXM7@d<C)S<C#?ZAJ
zur4W?8qXK^yy%afn1#}+3R*#a2M&$<<X;92b`lTNT^)k)=X87;Uu~OV#(R>mOIe@&
zs@`)jBi@|o3iHK{XKZt6+Ghl*Ep%j9arYk(T4+jl%R3LpDXJ&Qbv#ihLy#UHFT4ja
zj_aujvXdJ+E$5YX0;e*g1T&jKK9(I{tab4R-)sxX>w42OoI67c?X0mM)wLLltl>PV
zyW|nL>fwJ*E;*n&_iK&c?2_V}T+Jgn_l1H}l6~w2NvD57zq<xHJTJnsa*f`dVgLYH
z1Kp1pa*hxf2oFB#^Nn+zHO6&*<(%Q%cq0R`&N)21XxK}JD`wMQLi>0J^Wf|5hSC5j
zZd<w@w{X?dTU3fs89yR6^H!rPT>aLrtdrJPa`~|??t6}ztm+G&3%JCC5;o`ES9>`-
zWTQV!S6kQ_p7D%EIHp8SM~3(p(n3jpHBkyD8-;BPXPXp9P=<5HOyrPyQ0seO#C2t8
zG-fN8a73NSAxMjoCnwlbNoeC-=SQ6=mXj2^r{8sp`pK<_4~;nC-Ix@XA)!Fi;a<Kj
z#;Dwj-dUC~5)mXQ<%jF_KUEHyL<lWFWOh}#1ZRMzrO9*qV#kq0w|lBSo})NjVkve&
zIHOf(Y@|YWlhhiVGgekwgPV0+p7^z^b<ZC@#-e*UG=p^<5U%za^Ic8v>32{o>6sQy
z`w5P*Eaz2o`6pz*)*)h>Np|?*KE(~SP}#qep+N2zlVR=R`$I^dHohJ#s$}E*i6mRK
zI6+oishOMW7d(DAQaRL%u<@EGWnm_a(te849(L8^cs!$H?4w|+IondJpi(=*axcAP
z(Pw}$MjXgFsxDTv|B5OJypX%UC@F(W(OVYqHotU5ENcW$89QM_M72Qw7xJpW`dS+>
yK#y9levW+c?~(r>8~mvFtDAmQ<gfknlefgbd+QfLaf$UN(Y2koc7G6GfBge0?DkLq
--- a/addon-sdk/source/test/fixtures/chrome-worker/addEventListener.js
+++ b/addon-sdk/source/test/fixtures/chrome-worker/addEventListener.js
@@ -1,8 +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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 postMessage('Hello');
--- a/addon-sdk/source/test/fixtures/chrome-worker/jsctypes.js
+++ b/addon-sdk/source/test/fixtures/chrome-worker/jsctypes.js
@@ -1,8 +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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 postMessage(typeof ctypes.open);
--- a/addon-sdk/source/test/fixtures/chrome-worker/onerror.js
+++ b/addon-sdk/source/test/fixtures/chrome-worker/onerror.js
@@ -1,8 +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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 throw new Error('ok');
--- a/addon-sdk/source/test/fixtures/chrome-worker/onmessage.js
+++ b/addon-sdk/source/test/fixtures/chrome-worker/onmessage.js
@@ -1,10 +1,8 @@
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 onmessage = function (event) {
   postMessage(event.data);
 };
--- a/addon-sdk/source/test/fixtures/chrome-worker/setTimeout.js
+++ b/addon-sdk/source/test/fixtures/chrome-worker/setTimeout.js
@@ -1,10 +1,8 @@
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 setTimeout(function () {
   postMessage('ok');
 }, 0);
--- a/addon-sdk/source/test/fixtures/chrome-worker/xhr.js
+++ b/addon-sdk/source/test/fixtures/chrome-worker/xhr.js
@@ -1,13 +1,11 @@
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 let xhr = XMLHttpRequest();
 xhr.open("GET", "data:text/plain,ok", true);
 xhr.onload = function () {
   postMessage(xhr.responseText);
 };
 xhr.send(null);
--- a/addon-sdk/source/test/tabs/test-firefox-tabs.js
+++ b/addon-sdk/source/test/tabs/test-firefox-tabs.js
@@ -8,20 +8,17 @@ const { Loader } = require('sdk/test/loa
 const timer = require('sdk/timers');
 const { getOwnerWindow } = require('sdk/private-browsing/window/utils');
 const { windows, onFocus, getMostRecentBrowserWindow } = require('sdk/window/utils');
 const { open, focus, close } = require('sdk/window/helpers');
 const { StringBundle } = require('sdk/deprecated/app-strings');
 const tabs = require('sdk/tabs');
 const { browserWindows } = require('sdk/windows');
 
-const base64png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYA" +
-                  "AABzenr0AAAASUlEQVRYhe3O0QkAIAwD0eyqe3Q993AQ3cBSUKpygfsNTy" +
-                  "N5ugbQpK0BAADgP0BRDWXWlwEAAAAAgPsA3rzDaAAAAHgPcGrpgAnzQ2FG" +
-                  "bWRR9AAAAABJRU5ErkJggg%3D%3D";
+const base64png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAA";
 
 // Bug 682681 - tab.title should never be empty
 exports.testBug682681_aboutURI = function(assert, done) {
   let tabStrings = StringBundle('chrome://browser/locale/tabbrowser.properties');
 
   tabs.on('ready', function onReady(tab) {
     tabs.removeListener('ready', onReady);
 
@@ -859,60 +856,55 @@ exports['test unique tab ids'] = functio
     results[0].win.close();
     results[1].win.close();
     done();
   });
 }
 
 // related to Bug 671305
 exports.testOnLoadEventWithDOM = function(assert, done) {
-  openBrowserWindow(function(window, browser) {
-    let count = 0;
-    tabs.on('load', function onLoad(tab) {
-      assert.equal(tab.title, 'tab', 'tab passed in as arg, load called');
-      if (!count++) {
-        tab.reload();
+  let count = 0;
+  let title = 'testOnLoadEventWithDOM';
+
+  // open a about: url
+  tabs.open({
+    url: 'data:text/html;charset=utf-8,<title>' + title + '</title>',
+    inBackground: true,
+    onLoad: function(tab) {
+      assert.equal(tab.title, title, 'tab passed in as arg, load called');
+
+      if (++count > 1) {
+        assert.pass('onLoad event called on reload');
+        tab.close(done);
       }
       else {
-        // end of test
-        tabs.removeListener('load', onLoad);
-        assert.pass('onLoad event called on reload');
-        close(window).then(done);
+        assert.pass('first onLoad event occured');
+        tab.reload();
       }
-    });
-
-    // open a about: url
-    tabs.open({
-      url: 'data:text/html;charset=utf-8,<title>tab</title>',
-      inBackground: true
-    });
+    }
   });
 };
 
 // related to Bug 671305
 exports.testOnLoadEventWithImage = function(assert, done) {
-  openBrowserWindow(function(window, browser) {
-    let count = 0;
-    tabs.on('load', function onLoad(tab) {
-      if (!count++) {
-        tab.reload();
+  let count = 0;
+
+  tabs.open({
+    url: base64png,
+    inBackground: true,
+    onLoad: function(tab) {
+      if (++count > 1) {
+        assert.pass('onLoad event called on reload with image');
+        tab.close(done);
       }
       else {
-        // end of test
-        tabs.removeListener('load', onLoad);
-        assert.pass('onLoad event called on reload with image');
-        close(window).then(done);
+        assert.pass('first onLoad event occured');
+        tab.reload();
       }
-    });
-
-    // open a image url
-    tabs.open({
-      url: base64png,
-      inBackground: true
-    });
+    }
   });
 };
 
 exports.testFaviconGetterDeprecation = function (assert, done) {
   const { LoaderWithHookedConsole } = require("sdk/test/loader");
   let { loader, messages } = LoaderWithHookedConsole(module);
   let tabs = loader.require('sdk/tabs');
 
new file mode 100644
--- /dev/null
+++ b/addon-sdk/source/test/test-addon-window.js
@@ -0,0 +1,22 @@
+/* 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';
+
+let { Loader } = require('sdk/test/loader');
+
+exports.testReady = function(assert, done) {
+  let loader = Loader(module);
+  let { ready, window } = loader.require('sdk/addon/window');
+  let windowIsReady = false;
+
+  ready.then(function() {
+    assert.equal(windowIsReady, false, 'ready promise was resolved only once');
+    windowIsReady = true;
+
+    loader.unload();
+    done();
+  }).then(null, assert.fail);
+}
+
+require('sdk/test').run(exports);
--- a/addon-sdk/source/test/test-api-utils.js
+++ b/addon-sdk/source/test/test-api-utils.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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 apiUtils = require("sdk/deprecated/api-utils");
 
 exports.testPublicConstructor = function (assert) {
   function PrivateCtor() {}
--- a/addon-sdk/source/test/test-byte-streams.js
+++ b/addon-sdk/source/test/test-byte-streams.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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 byteStreams = require("sdk/io/byte-streams");
 const file = require("sdk/io/file");
 const { pathFor } = require("sdk/system");
 const { Loader } = require("sdk/test/loader");
 
--- a/addon-sdk/source/test/test-chrome.js
+++ b/addon-sdk/source/test/test-chrome.js
@@ -1,13 +1,11 @@
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 'use strict';
 
 let chrome = require('chrome');
 
 const FIXTURES_URL = module.uri.substr(0, module.uri.lastIndexOf('/') + 1) +
                      'fixtures/chrome-worker/'
 
 exports['test addEventListener'] = function(assert, done) {
@@ -67,20 +65,20 @@ exports['test XMLHttpRequest'] = functio
 };
 
 exports['test onerror'] = function(assert, done) {
   let uri = FIXTURES_URL + 'onerror.js';
 
   let worker = new chrome.ChromeWorker(uri);
   worker.onerror = function(event) {
     assert.equal(event.filename, uri, 'event reports the correct uri');
-    assert.equal(event.lineno, 8, 'event reports the correct line number');
+    assert.equal(event.lineno, 6, 'event reports the correct line number');
     assert.equal(event.target, worker, 'event reports the correct worker');
     assert.ok(event.message.match(/ok/),
                 'event contains the exception message');
     // Call preventDefault in order to avoid being displayed in JS console.
     event.preventDefault();
     worker.terminate();
     done();
   };
 };
 
-require('test').run(exports);
+require('sdk/test').run(exports);
--- a/addon-sdk/source/test/test-clipboard.js
+++ b/addon-sdk/source/test/test-clipboard.js
@@ -1,12 +1,11 @@
 /* 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";
 
 require("sdk/clipboard");
 
 const { Cc, Ci } = require("chrome");
 
 const imageTools = Cc["@mozilla.org/image/tools;1"].
                     getService(Ci.imgITools);
--- a/addon-sdk/source/test/test-collection.js
+++ b/addon-sdk/source/test/test-collection.js
@@ -1,127 +1,128 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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 collection = require("sdk/util/collection");
 
-exports.testAddRemove = function (test) {
+exports.testAddRemove = function (assert) {
   let coll = new collection.Collection();
-  compare(test, coll, []);
-  addRemove(test, coll, [], false);
+  compare(assert, coll, []);
+  addRemove(assert, coll, [], false);
 };
 
-exports.testAddRemoveBackingArray = function (test) {
+exports.testAddRemoveBackingArray = function (assert) {
   let items = ["foo"];
   let coll = new collection.Collection(items);
-  compare(test, coll, items);
-  addRemove(test, coll, items, true);
+  compare(assert, coll, items);
+  addRemove(assert, coll, items, true);
 
   items = ["foo", "bar"];
   coll = new collection.Collection(items);
-  compare(test, coll, items);
-  addRemove(test, coll, items, true);
+  compare(assert, coll, items);
+  addRemove(assert, coll, items, true);
 };
 
-exports.testProperty = function (test) {
+exports.testProperty = function (assert) {
   let obj = makeObjWithCollProp();
-  compare(test, obj.coll, []);
-  addRemove(test, obj.coll, [], false);
+  compare(assert, obj.coll, []);
+  addRemove(assert, obj.coll, [], false);
 
   // Test single-value set.
   let items = ["foo"];
   obj.coll = items[0];
-  compare(test, obj.coll, items);
-  addRemove(test, obj.coll, items, false);
+  compare(assert, obj.coll, items);
+  addRemove(assert, obj.coll, items, false);
 
   // Test array set.
   items = ["foo", "bar"];
   obj.coll = items;
-  compare(test, obj.coll, items);
-  addRemove(test, obj.coll, items, false);
+  compare(assert, obj.coll, items);
+  addRemove(assert, obj.coll, items, false);
 };
 
-exports.testPropertyBackingArray = function (test) {
+exports.testPropertyBackingArray = function (assert) {
   let items = ["foo"];
   let obj = makeObjWithCollProp(items);
-  compare(test, obj.coll, items);
-  addRemove(test, obj.coll, items, true);
+  compare(assert, obj.coll, items);
+  addRemove(assert, obj.coll, items, true);
 
   items = ["foo", "bar"];
   obj = makeObjWithCollProp(items);
-  compare(test, obj.coll, items);
-  addRemove(test, obj.coll, items, true);
+  compare(assert, obj.coll, items);
+  addRemove(assert, obj.coll, items, true);
 };
 
 // Adds some values to coll and then removes them.  initialItems is an array
 // containing coll's initial items.  isBacking is true if initialItems is coll's
 // backing array; the point is that updates to coll should affect initialItems
 // if that's the case.
-function addRemove(test, coll, initialItems, isBacking) {
+function addRemove(assert, coll, initialItems, isBacking) {
   let items = isBacking ? initialItems : initialItems.slice(0);
   let numInitialItems = items.length;
 
   // Test add(val).
   let numInsertions = 5;
   for (let i = 0; i < numInsertions; i++) {
-    compare(test, coll, items);
+    compare(assert, coll, items);
     coll.add(i);
     if (!isBacking)
       items.push(i);
   }
-  compare(test, coll, items);
+  compare(assert, coll, items);
 
   // Add the items we just added to make sure duplicates aren't added.
   for (let i = 0; i < numInsertions; i++)
     coll.add(i);
-  compare(test, coll, items);
+  compare(assert, coll, items);
 
   // Test remove(val).  Do a kind of shuffled remove.  Remove item 1, then
   // item 0, 3, 2, 5, 4, ...
   for (let i = 0; i < numInsertions; i++) {
     let val = i % 2 ? i - 1 :
               i === numInsertions - 1 ? i : i + 1;
     coll.remove(val);
     if (!isBacking)
       items.splice(items.indexOf(val), 1);
-    compare(test, coll, items);
+    compare(assert, coll, items);
   }
-  test.assertEqual(coll.length, numInitialItems,
-                   "All inserted items should be removed");
+  assert.equal(coll.length, numInitialItems,
+               "All inserted items should be removed");
 
   // Remove the items we just removed.  coll should be unchanged.
   for (let i = 0; i < numInsertions; i++)
     coll.remove(i);
-  compare(test, coll, items);
+  compare(assert, coll, items);
 
   // Test add and remove([val1, val2]).
   let newItems = [0, 1];
   coll.add(newItems);
-  compare(test, coll, isBacking ? items : items.concat(newItems));
+  compare(assert, coll, isBacking ? items : items.concat(newItems));
   coll.remove(newItems);
-  compare(test, coll, items);
-  test.assertEqual(coll.length, numInitialItems,
-                   "All inserted items should be removed");
+  compare(assert, coll, items);
+  assert.equal(coll.length, numInitialItems,
+               "All inserted items should be removed");
 }
 
 // Asserts that the items in coll are the items of array.
-function compare(test, coll, array) {
-  test.assertEqual(coll.length, array.length,
-                   "Collection length should be correct");
+function compare(assert, coll, array) {
+  assert.equal(coll.length, array.length,
+               "Collection length should be correct");
   let numItems = 0;
   for (let item in coll) {
-    test.assertEqual(item, array[numItems], "Items should be equal");
+    assert.equal(item, array[numItems], "Items should be equal");
     numItems++;
   }
-  test.assertEqual(numItems, array.length,
-                   "Number of items in iteration should be correct");
+  assert.equal(numItems, array.length,
+               "Number of items in iteration should be correct");
 }
 
 // Returns a new object with a collection property named "coll".  backingArray,
 // if defined, will create the collection with that backing array.
 function makeObjWithCollProp(backingArray) {
   let obj = {};
   collection.addCollectionProperty(obj, "coll", backingArray);
   return obj;
 }
+
+require("sdk/test").run(exports);
--- a/addon-sdk/source/test/test-context-menu.js
+++ b/addon-sdk/source/test/test-context-menu.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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';
 
 let { Cc, Ci } = require("chrome");
 
 require("sdk/context-menu");
--- a/addon-sdk/source/test/test-cortex.js
+++ b/addon-sdk/source/test/test-cortex.js
@@ -1,14 +1,12 @@
 /* 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/. */
 
-// vim:set ts=2 sw=2 sts=2
-
 "use strict";
 
 var Cortex = require("sdk/deprecated/cortex").Cortex;
 
 exports["test property changes propagate"] = function (assert) {
   var source = {
     _foo: "secret",
     get foo() {
--- a/addon-sdk/source/test/test-events.js
+++ b/addon-sdk/source/test/test-events.js
@@ -1,145 +1,144 @@
 /* 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 { LoaderWithHookedConsole } = require("sdk/test/loader");
 
 // Exposing private methods as public in order to test
 const EventEmitter = require('sdk/deprecated/events').EventEmitter.compose({
   listeners: function(type) this._listeners(type),
   emit: function() this._emit.apply(this, arguments),
   emitOnObject: function() this._emitOnObject.apply(this, arguments),
   removeAllListeners: function(type) this._removeAllListeners(type)
 });
 
-exports['test:add listeners'] = function(test) {
+exports['test:add listeners'] = function(assert) {
   let e = new EventEmitter();
 
   let events_new_listener_emited = [];
   let times_hello_emited = 0;
 
   e.on("newListener", function (event, listener) {
     events_new_listener_emited.push(event)
   })
 
   e.on("hello", function (a, b) {
     times_hello_emited += 1
-    test.assertEqual("a", a)
-    test.assertEqual("b", b)
-    test.assertEqual(this, e, '`this` pseudo-variable is bound to instance');
+    assert.equal("a", a)
+    assert.equal("b", b)
+    assert.equal(this, e, '`this` pseudo-variable is bound to instance');
   })
 
   e.emit("hello", "a", "b")
 };
 
-exports['test:removeListener'] = function(test) {
+exports['test:removeListener'] = function(assert) {
   let count = 0;
 
   function listener1 () {
     count++;
   }
   function listener2 () {
     count++;
   }
 
   // test adding and removing listener
   let e1 = new EventEmitter();
-  test.assertEqual(0, e1.listeners('hello').length);
+  assert.equal(0, e1.listeners('hello').length);
   e1.on("hello", listener1);
-  test.assertEqual(1, e1.listeners('hello').length);
-  test.assertEqual(listener1, e1.listeners('hello')[0]);
+  assert.equal(1, e1.listeners('hello').length);
+  assert.equal(listener1, e1.listeners('hello')[0]);
   e1.removeListener("hello", listener1);
-  test.assertEqual(0, e1.listeners('hello').length);
+  assert.equal(0, e1.listeners('hello').length);
   e1.emit("hello", "");
-  test.assertEqual(0, count);
+  assert.equal(0, count);
 
   // test adding one listener and removing another which was not added
   let e2 = new EventEmitter();
-  test.assertEqual(0, e2.listeners('hello').length);
+  assert.equal(0, e2.listeners('hello').length);
   e2.on("hello", listener1);
-  test.assertEqual(1, e2.listeners('hello').length);
+  assert.equal(1, e2.listeners('hello').length);
   e2.removeListener("hello", listener2);
-  test.assertEqual(1, e2.listeners('hello').length);
-  test.assertEqual(listener1, e2.listeners('hello')[0]);
+  assert.equal(1, e2.listeners('hello').length);
+  assert.equal(listener1, e2.listeners('hello')[0]);
   e2.emit("hello", "");
-  test.assertEqual(1, count);
+  assert.equal(1, count);
 
   // test adding 2 listeners, and removing one
   let e3 = new EventEmitter();
-  test.assertEqual(0, e3.listeners('hello').length);
+  assert.equal(0, e3.listeners('hello').length);
   e3.on("hello", listener1);
-  test.assertEqual(1, e3.listeners('hello').length);
+  assert.equal(1, e3.listeners('hello').length);
   e3.on("hello", listener2);
-  test.assertEqual(2, e3.listeners('hello').length);
+  assert.equal(2, e3.listeners('hello').length);
   e3.removeListener("hello", listener1);
-  test.assertEqual(1, e3.listeners('hello').length);
-  test.assertEqual(listener2, e3.listeners('hello')[0]);
+  assert.equal(1, e3.listeners('hello').length);
+  assert.equal(listener2, e3.listeners('hello')[0]);
   e3.emit("hello", "");
-  test.assertEqual(2, count);
+  assert.equal(2, count);
 };
 
-exports['test:removeAllListeners'] = function(test) {
+exports['test:removeAllListeners'] = function(assert) {
   let count = 0;
 
   function listener1 () {
     count++;
   }
   function listener2 () {
     count++;
   }
 
   // test adding a listener and removing all of that type
   let e1 = new EventEmitter();
   e1.on("hello", listener1);
-  test.assertEqual(1, e1.listeners('hello').length);
+  assert.equal(1, e1.listeners('hello').length);
   e1.removeAllListeners("hello");
-  test.assertEqual(0, e1.listeners('hello').length);
+  assert.equal(0, e1.listeners('hello').length);
   e1.emit("hello", "");
-  test.assertEqual(0, count);
+  assert.equal(0, count);
 
   // test adding a listener and removing all of another type
   let e2 = new EventEmitter();
   e2.on("hello", listener1);
-  test.assertEqual(1, e2.listeners('hello').length);
+  assert.equal(1, e2.listeners('hello').length);
   e2.removeAllListeners('goodbye');
-  test.assertEqual(1, e2.listeners('hello').length);
+  assert.equal(1, e2.listeners('hello').length);
   e2.emit("hello", "");
-  test.assertEqual(1, count);
+  assert.equal(1, count);
 
   // test adding 1+ listeners and removing all of that type
   let e3 = new EventEmitter();
   e3.on("hello", listener1);
-  test.assertEqual(1, e3.listeners('hello').length);
+  assert.equal(1, e3.listeners('hello').length);
   e3.on("hello", listener2);
-  test.assertEqual(2, e3.listeners('hello').length);
+  assert.equal(2, e3.listeners('hello').length);
   e3.removeAllListeners("hello");
-  test.assertEqual(0, e3.listeners('hello').length);
+  assert.equal(0, e3.listeners('hello').length);
   e3.emit("hello", "");
-  test.assertEqual(1, count);
+  assert.equal(1, count);
 
   // test adding 2 listeners for 2 types and removing all listeners
   let e4 = new EventEmitter();
   e4.on("hello", listener1);
-  test.assertEqual(1, e4.listeners('hello').length);
+  assert.equal(1, e4.listeners('hello').length);
   e4.on('goodbye', listener2);
-  test.assertEqual(1, e4.listeners('goodbye').length);
+  assert.equal(1, e4.listeners('goodbye').length);
   e4.emit("goodbye", "");
   e4.removeAllListeners();
-  test.assertEqual(0, e4.listeners('hello').length);
-  test.assertEqual(0, e4.listeners('goodbye').length);
+  assert.equal(0, e4.listeners('hello').length);
+  assert.equal(0, e4.listeners('goodbye').length);
   e4.emit("hello", "");
   e4.emit("goodbye", "");
-  test.assertEqual(2, count);
+  assert.equal(2, count);
 };
 
-exports['test: modify in emit'] = function(test) {
+exports['test: modify in emit'] = function(assert) {
   let callbacks_called = [ ];
   let e = new EventEmitter();
 
   function callback1() {
     callbacks_called.push("callback1");
     e.on("foo", callback2);
     e.on("foo", callback3);
     e.removeListener("foo", callback1);
@@ -149,116 +148,116 @@ exports['test: modify in emit'] = functi
     e.removeListener("foo", callback2);
   }
   function callback3() {
     callbacks_called.push("callback3");
     e.removeListener("foo", callback3);
   }
 
   e.on("foo", callback1);
-  test.assertEqual(1, e.listeners("foo").length);
+  assert.equal(1, e.listeners("foo").length);
 
   e.emit("foo");
-  test.assertEqual(2, e.listeners("foo").length);
-  test.assertEqual(1, callbacks_called.length);
-  test.assertEqual('callback1', callbacks_called[0]);
+  assert.equal(2, e.listeners("foo").length);
+  assert.equal(1, callbacks_called.length);
+  assert.equal('callback1', callbacks_called[0]);
 
   e.emit("foo");
-  test.assertEqual(0, e.listeners("foo").length);
-  test.assertEqual(3, callbacks_called.length);
-  test.assertEqual('callback1', callbacks_called[0]);
-  test.assertEqual('callback2', callbacks_called[1]);
-  test.assertEqual('callback3', callbacks_called[2]);
+  assert.equal(0, e.listeners("foo").length);
+  assert.equal(3, callbacks_called.length);
+  assert.equal('callback1', callbacks_called[0]);
+  assert.equal('callback2', callbacks_called[1]);
+  assert.equal('callback3', callbacks_called[2]);
 
   e.emit("foo");
-  test.assertEqual(0, e.listeners("foo").length);
-  test.assertEqual(3, callbacks_called.length);
-  test.assertEqual('callback1', callbacks_called[0]);
-  test.assertEqual('callback2', callbacks_called[1]);
-  test.assertEqual('callback3', callbacks_called[2]);
+  assert.equal(0, e.listeners("foo").length);
+  assert.equal(3, callbacks_called.length);
+  assert.equal('callback1', callbacks_called[0]);
+  assert.equal('callback2', callbacks_called[1]);
+  assert.equal('callback3', callbacks_called[2]);
 
   e.on("foo", callback1);
   e.on("foo", callback2);
-  test.assertEqual(2, e.listeners("foo").length);
+  assert.equal(2, e.listeners("foo").length);
   e.removeAllListeners("foo");
-  test.assertEqual(0, e.listeners("foo").length);
+  assert.equal(0, e.listeners("foo").length);
 
   // Verify that removing callbacks while in emit allows emits to propagate to
   // all listeners
   callbacks_called = [ ];
 
   e.on("foo", callback2);
   e.on("foo", callback3);
-  test.assertEqual(2, e.listeners("foo").length);
+  assert.equal(2, e.listeners("foo").length);
   e.emit("foo");
-  test.assertEqual(2, callbacks_called.length);
-  test.assertEqual('callback2', callbacks_called[0]);
-  test.assertEqual('callback3', callbacks_called[1]);
-  test.assertEqual(0, e.listeners("foo").length);
+  assert.equal(2, callbacks_called.length);
+  assert.equal('callback2', callbacks_called[0]);
+  assert.equal('callback3', callbacks_called[1]);
+  assert.equal(0, e.listeners("foo").length);
 };
 
-exports['test:adding same listener'] = function(test) {
+exports['test:adding same listener'] = function(assert) {
   function foo() {}
   let e = new EventEmitter();
   e.on("foo", foo);
   e.on("foo", foo);
-  test.assertEqual(
+  assert.equal(
     1,
     e.listeners("foo").length,
     "listener reregistration is ignored"
  );
 }
 
-exports['test:errors are reported if listener throws'] = function(test) {
+exports['test:errors are reported if listener throws'] = function(assert) {
   let e = new EventEmitter(),
       reported = false;
   e.on('error', function(e) reported = true)
   e.on('boom', function() { throw new Error('Boom!') });
   e.emit('boom', 3);
-  test.assert(reported, 'error should be reported through event');
+  assert.ok(reported, 'error should be reported through event');
 };
 
-exports['test:emitOnObject'] = function(test) {
+exports['test:emitOnObject'] = function(assert) {
   let e = new EventEmitter();
 
   e.on("foo", function() {
-    test.assertEqual(this, e, "`this` should be emitter");
+    assert.equal(this, e, "`this` should be emitter");
   });
   e.emitOnObject(e, "foo");
 
   e.on("bar", function() {
-    test.assertEqual(this, obj, "`this` should be other object");
+    assert.equal(this, obj, "`this` should be other object");
   });
   let obj = {};
   e.emitOnObject(obj, "bar");
 };
 
-exports['test:once'] = function(test) {
+exports['test:once'] = function(assert) {
   let e = new EventEmitter();
   let called = false;
 
   e.once('foo', function(value) {
-    test.assert(!called, "listener called only once");
-    test.assertEqual(value, "bar", "correct argument was passed");
+    assert.ok(!called, "listener called only once");
+    assert.equal(value, "bar", "correct argument was passed");
   });
 
   e.emit('foo', 'bar');
   e.emit('foo', 'baz');
 };
 
-exports["test:removing once"] = function(test) {
+exports["test:removing once"] = function(assert) {
   let e = require("sdk/deprecated/events").EventEmitterTrait.create();
-  e.once("foo", function() { test.pass("listener was called"); });
-  e.once("error", function() { test.fail("error event was emitted"); });
+  e.once("foo", function() { assert.pass("listener was called"); });
+  e.once("error", function() { assert.fail("error event was emitted"); });
   e._emit("foo", "bug-656684");
 };
 
 // Bug 726967: Ensure that `emit` doesn't do an infinite loop when `error`
 // listener throws an exception
-exports['test:emitLoop'] = function(test) {
+exports['test:emitLoop'] = function(assert) {
   // Override the console for this test so it doesn't log the exception to the
   // test output
   let { loader } = LoaderWithHookedConsole(module);
 
   let EventEmitter = loader.require('sdk/deprecated/events').EventEmitter.compose({
     listeners: function(type) this._listeners(type),
     emit: function() this._emit.apply(this, arguments),
     emitOnObject: function() this._emitOnObject.apply(this, arguments),
@@ -271,10 +270,12 @@ exports['test:emitLoop'] = function(test
     throw new Error("foo");
   });
 
   e.on("error", function() {
     throw new Error("error");
   });
   e.emit("foo");
 
-  test.pass("emit didn't looped");
+  assert.pass("emit didn't looped");
 };
+
+require('sdk/test').run(exports);
--- a/addon-sdk/source/test/test-globals.js
+++ b/addon-sdk/source/test/test-globals.js
@@ -1,22 +1,23 @@
 /* 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';
 
-Object.defineProperty(this, "global", { value: this });
+Object.defineProperty(this, 'global', { value: this });
 
-exports.testGlobals = function(test) {
+exports.testGlobals = function(assert) {
   // the only globals in module scope should be:
-  //   module, exports, require, dump, console
-  test.assertObject(module, "have 'module', good");
-  test.assertObject(exports, "have 'exports', good");
-  test.assertFunction(require, "have 'require', good");
-  test.assertFunction(dump, "have 'dump', good");
-  test.assertObject(console, "have 'console', good");
+  assert.equal(typeof module, 'object', 'have "module" global');
+  assert.equal(typeof exports, 'object', 'have "exports" global');
+  assert.equal(typeof require, 'function', 'have "require" global');
+  assert.equal(typeof dump, 'function', 'have "dump" global');
+  assert.equal(typeof console, 'object', 'have "console" global');
 
   // in particular, these old globals should no longer be present
-  test.assert(!('packaging' in global), "no 'packaging', good");
-  test.assert(!('memory' in global), "no 'memory', good");
+  assert.ok(!('packaging' in global), 'no "packaging" global was found');
+  assert.ok(!('memory' in global), 'no "memory" global was found');
 
-  test.assertMatches(module.uri, /test-globals\.js$/,
-                     'should contain filename');
+  assert.ok(/test-globals\.js$/.test(module.uri), 'should contain filename');
 };
+
+require("test").run(exports);
--- a/addon-sdk/source/test/test-hidden-frame.js
+++ b/addon-sdk/source/test/test-hidden-frame.js
@@ -1,12 +1,11 @@
 /* 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 { Loader } = require("sdk/test/loader");
 const hiddenFrames = require("sdk/frame/hidden-frame");
 const { HiddenFrame } = hiddenFrames;
 
 exports["test Frame"] = function(assert, done) {
   let url = "data:text/html;charset=utf-8,<!DOCTYPE%20html>";
@@ -39,17 +38,16 @@ exports["test frame removed properly"] =
       assert.ok(frame.parentNode, "frame has a parent node");
       hiddenFrames.remove(hiddenFrame);
       assert.ok(!frame.parentNode, "frame no longer has a parent node");
       done();
     }
   }));
 };
 
-
 exports["test unload detaches panels"] = function(assert, done) {
   let loader = Loader(module);
   let { add, remove, HiddenFrame } = loader.require("sdk/frame/hidden-frame");
   let frames = []
 
   function ready() {
     frames.push(this.element);
     if (frames.length === 2) complete();
@@ -65,11 +63,9 @@ exports["test unload detaches panels"] =
     loader.unload();
     frames.forEach(function(frame) {
       assert.ok(!frame.parentNode, "frame isn't in the document'");
     });
     done();
   }
 };
 
-
-
 require("test").run(exports);
--- a/addon-sdk/source/test/test-match-pattern.js
+++ b/addon-sdk/source/test/test-match-pattern.js
@@ -1,10 +1,8 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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 { MatchPattern } = require("sdk/util/match-pattern");
 
 exports.testMatchPatternTestTrue = function(test) {
new file mode 100644
--- /dev/null
+++ b/addon-sdk/source/test/test-method.js
@@ -0,0 +1,7 @@
+/* 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.exports = require("method/test/common");
--- a/addon-sdk/source/test/test-notifications.js
+++ b/addon-sdk/source/test/test-notifications.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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 { Loader } = require('sdk/test/loader');
 
 exports.testOnClick = function (test) {
   let [loader, mockAlertServ] = makeLoader(module);
   let notifs = loader.require("sdk/notifications");
--- a/addon-sdk/source/test/test-panel.js
+++ b/addon-sdk/source/test/test-panel.js
@@ -127,34 +127,36 @@ exports["test Show Hide Panel"] = functi
 };
 
 exports["test Document Reload"] = function(assert, done) {
   const { Panel } = require('sdk/panel');
 
   let url2 = "data:text/html;charset=utf-8,page2";
   let content =
     "<script>" +
-    "window.addEventListener('message', function() {"+
-    "  window.location = '" + url2 + "';" +
+    "window.addEventListener('message', function({ data }) {"+
+    "  if (data == 'move') window.location = '" + url2 + "';" +
     '}, false);' +
     "</script>";
   let messageCount = 0;
   let panel = Panel({
     // using URL here is intentional, see bug 859009
     contentURL: URL("data:text/html;charset=utf-8," + encodeURIComponent(content)),
     contentScript: "self.postMessage(window.location.href);" +
                    // initiate change to url2
                    "self.port.once('move', function() document.defaultView.postMessage('move', '*'));",
     onMessage: function (message) {
       messageCount++;
       assert.notEqual(message, "about:blank", "about:blank is not a message " + messageCount);
 
       if (messageCount == 1) {
         assert.ok(/data:text\/html/.test(message), "First document had a content script; " + message);
         panel.port.emit('move');
+        assert.pass('move message was sent');
+        return;
       }
       else if (messageCount == 2) {
         assert.equal(message, url2, "Second document too; " + message);
         panel.destroy();
         done();
       }
     }
   });
--- a/addon-sdk/source/test/test-places-bookmarks.js
+++ b/addon-sdk/source/test/test-places-bookmarks.js
@@ -312,22 +312,22 @@ exports.testAddingToExistingParent = fun
   firstBatch, secondBatch;
 
   saveP(bookmarks).then(data => {
     firstBatch = data;
     return saveP([
       { title: 'moz4', url: 'http://moz4.com', type: 'bookmark', group: group },
       { title: 'moz5', url: 'http://moz5.com', type: 'bookmark', group: group }
     ]);
-  }, console.error).then(data => {
+  }, assert.fail).then(data => {
     secondBatch = data;
     assert.equal(firstBatch[0].group.id, secondBatch[0].group.id,
       'successfully saved to the same parent');
     done();
-  }, console.error);
+  }, assert.fail);
 };
 
 exports.testUpdateParent = function (assert, done) {
   let group = { type: 'group', title: 'mozgroup' };
   saveP(group).then(item => {
     item[0].title = 'mozgroup-resave';
     return saveP(item[0]);
   }).then(item => {
@@ -621,17 +621,17 @@ exports.testSearchByGroupSimple = functi
   }).then(results => {
     let groups = results.filter(({type}) => type === 'group');
     assert.equal(groups.length, 1, 'returns one subfolder');
     assert.equal(results.length, 6,
       'returns all children bookmarks/folders');
     assert.ok(results.filter(({url}) => url === 'http://w3schools.com/'),
       'returns nested children');
     done();
-  }).then(null, console.error);
+  }).then(null, assert.fail);
 };
 
 exports.testSearchByGroupComplex = function (assert, done) {
   let mozgroup;
   createBookmarkTree().then(results => {
     mozgroup = results.filter(({title}) => title === 'mozgroup')[0];
     return searchP({ group: mozgroup, query: 'javascript' });
   }).then(results => {
@@ -639,17 +639,17 @@ exports.testSearchByGroupComplex = funct
     assert.equal(results[0].url, 'http://w3schools.com/', 'correct result');
     return searchP({ group: mozgroup, url: '*.mozilla.org' });
   }).then(results => {
     assert.equal(results.length, 2, 'expected results');
     assert.ok(
       !results.filter(({url}) => /developer.mozilla/.test(url)).length,
       'does not find results from other folders');
     done();
-  }, console.error);
+  }, assert.fail);
 };
 
 exports.testSearchEmitters = function (assert, done) {
   createBookmarkTree().then(() => {
     let count = 0;
     search({ tags: ['mozilla', 'firefox'] }).on('data', data => {
       assert.ok(/mozilla|firefox/.test(data.title), 'one of the correct items');
       assert.ok(data.tags.has('firefox'), 'has firefox tag');
@@ -768,24 +768,24 @@ exports.testSearchQuery = function (asse
  * and if implementation changes, this could increase or decrease
  */
 
 exports.testCaching = function (assert, done) {
   let count = 0;
   let stream = filter(request, ({event}) =>
     /sdk-places-bookmarks-get/.test(event));
   on(stream, 'data', handle);
- 
+
   let group = { type: 'group', title: 'mozgroup' };
   let bookmarks = [
     { title: 'moz1', url: 'http://moz1.com', type: 'bookmark', group: group },
     { title: 'moz2', url: 'http://moz2.com', type: 'bookmark', group: group },
     { title: 'moz3', url: 'http://moz3.com', type: 'bookmark', group: group }
   ];
-  
+
   /*
    * Use timeout in tests since the platform calls are synchronous
    * and the counting event shim may not have occurred yet
    */
 
   saveP(bookmarks).then(() => {
     assert.equal(count, 0, 'all new items and root group, no fetches should occur');
     count = 0;
@@ -811,17 +811,17 @@ exports.testCaching = function (assert, 
 };
 
 /*
  * Search Query Options
  */
 
 exports.testSearchCount = function (assert, done) {
   let max = 8;
-  createBookmarkTree()  
+  createBookmarkTree()
   .then(testCount(1))
   .then(testCount(2))
   .then(testCount(3))
   .then(testCount(5))
   .then(testCount(10))
   .then(() => {
     done();
   });
@@ -837,17 +837,17 @@ exports.testSearchCount = function (asse
   }
 };
 
 exports.testSearchSort = function (assert, done) {
   let urls = [
     'http://mozilla.com/', 'http://webaud.io/', 'http://mozilla.com/webfwd/',
     'http://developer.mozilla.com/', 'http://bandcamp.com/'
   ];
-  
+
   saveP(
     urls.map(url =>
       Bookmark({ url: url, title: url.replace(/http:\/\/|\//g,'')}))
   ).then(() => {
     return searchP({}, { sort: 'title' });
   }).then(results => {
     checkOrder(results, [4,3,0,2,1]);
     return searchP({}, { sort: 'title', descending: true });
@@ -863,17 +863,17 @@ exports.testSearchSort = function (asser
   }).then(() =>
     saveP(Bookmark({ url: 'http://github.com', title: 'github.com' }))
   ).then(() => addVisits('http://bandcamp.com/'))
   .then(() => searchP({ query: 'webfwd' }))
   .then(results => {
     results[0].title = 'new title for webfwd';
     return saveP(results[0]);
   })
-  .then(() => 
+  .then(() =>
     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');
@@ -899,17 +899,17 @@ exports.testSearchSort = function (asser
       'last modified should be last');
     return searchP({}, { sort: 'lastModified', descending: true });
   }).then(results => {
     assert.equal(results[0].url, 'http://mozilla.com/webfwd/',
       'last modified should be first');
   }).then(() => {
     done();
   });
-  
+
   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, urls[nums[i]], 'successful order');
     }
   }
 };
 
--- a/addon-sdk/source/test/test-places-host.js
+++ b/addon-sdk/source/test/test-places-host.js
@@ -41,17 +41,17 @@ exports.testBookmarksCreate = function (
   }, {
     title: 'my folder',
     type: 'group',
     group: bmsrv.bookmarksMenuFolder
   }, {
     type: 'separator',
     group: bmsrv.unfiledBookmarksFolder
   }];
-  
+
   all(items.map(function (item) {
     return send('sdk-places-bookmarks-create', item).then(function (data) {
       compareWithHost(assert, data);
     }, invalidReject(assert));
   })).then(function () {
     done();
   }, invalidReject(assert));
 };
@@ -106,17 +106,17 @@ exports.testBookmarkRemove = function (a
     compareWithHost(assert, data); // ensure bookmark exists
     bmsrv.getItemTitle(id); // does not throw an error
     return send('sdk-places-bookmarks-remove', data);
   }).then(function () {
     assert.throws(function () {
       bmsrv.getItemTitle(id);
     }, 'item should no longer exist');
     done();
-  }, console.error);
+  }, assert.fail);
 };
 
 exports.testBookmarkGet = function (assert, done) {
   let bookmark;
   createBookmark({
     url: 'http://test-places-host.com/testBookmarkGet/'
   }).then(function (data) {
     bookmark = data;
@@ -222,25 +222,25 @@ exports.testHostQuery = function (assert
     }),
     createBookmark({
       url: 'http://mozilla.com/testHostQuery/',
       tags: ['mozilla']
     }),
     createBookmark({ url: 'http://thunderbird.com/testHostQuery/' })
   ]).then(data => {
     return send('sdk-places-query', {
-      queries: { tags: ['mozilla'] }, 
+      queries: { tags: ['mozilla'] },
       options: { sortingMode: 6, queryType: 1 } // sort by URI ascending, bookmarks only
     });
   }).then(results => {
     assert.equal(results.length, 2, 'should only return two');
     assert.equal(results[0].url,
       'http://mozilla.com/testHostQuery/', 'is sorted by URI asc');
     return send('sdk-places-query', {
-      queries: { tags: ['mozilla'] }, 
+      queries: { tags: ['mozilla'] },
       options: { sortingMode: 5, queryType: 1 } // sort by URI descending, bookmarks only
     });
   }).then(results => {
     assert.equal(results.length, 2, 'should only return two');
     assert.equal(results[0].url,
       'http://firefox.com/testHostQuery/', 'is sorted by URI desc');
     done();
   });
@@ -274,22 +274,22 @@ exports.testHostMultiQuery = function (a
     });
   }).then(results => {
     assert.equal(results.length, 0, 'query props should be AND\'d');
     done();
   });
 };
 
 exports.testGetAllBookmarks = function (assert, done) {
-  createBookmarkTree().then(() => { 
+  createBookmarkTree().then(() => {
     return send('sdk-places-bookmarks-get-all', {});
   }).then(res => {
     assert.equal(res.length, 8, 'all bookmarks returned');
     done();
-  }, console.error);
+  }, assert.fail);
 };
 
 exports.testGetAllChildren = function (assert, done) {
   createBookmarkTree().then(results => {
     return send('sdk-places-bookmarks-get-children', {
       id: results.filter(({title}) => title === 'mozgroup')[0].id
     });
   }).then(results => {
--- a/addon-sdk/source/test/test-plain-text-console.js
+++ b/addon-sdk/source/test/test-plain-text-console.js
@@ -11,106 +11,106 @@ const { loadSubScript } = Cc['@mozilla.o
 const ADDON_LOG_LEVEL_PREF = "extensions." + id + ".sdk.console.logLevel";
 const SDK_LOG_LEVEL_PREF = "extensions.sdk.console.logLevel";
 
 const HAS_ORIGINAL_ADDON_LOG_LEVEL = prefs.has(ADDON_LOG_LEVEL_PREF);
 const ORIGINAL_ADDON_LOG_LEVEL = prefs.get(ADDON_LOG_LEVEL_PREF);
 const HAS_ORIGINAL_SDK_LOG_LEVEL = prefs.has(SDK_LOG_LEVEL_PREF);
 const ORIGINAL_SDK_LOG_LEVEL = prefs.get(SDK_LOG_LEVEL_PREF);
 
-exports.testPlainTextConsole = function(test) {
-  var prints = [];
+exports.testPlainTextConsole = function(assert) {
+  let prints = [];
   function print(message) {
     prints.push(message);
   }
   function lastPrint() {
-    var last = prints.slice(-1)[0];
+    let last = prints.slice(-1)[0];
     prints = [];
     return last;
   }
 
   prefs.set(SDK_LOG_LEVEL_PREF, "all");
   prefs.reset(ADDON_LOG_LEVEL_PREF);
 
-  var Console = require("sdk/console/plain-text").PlainTextConsole;
-  var con = new Console(print);
+  let Console = require("sdk/console/plain-text").PlainTextConsole;
+  let con = new Console(print);
 
-  test.pass("PlainTextConsole instantiates");
+  assert.ok("PlainTextConsole instantiates");
 
   con.log('testing', 1, [2, 3, 4]);
-  test.assertEqual(lastPrint(), "console.log: " + name + ": testing 1 Array [2,3,4]\n",
+  assert.equal(lastPrint(), "console.log: " + name + ": testing 1 Array [2,3,4]\n",
                    "PlainTextConsole.log() must work.");
 
   con.info('testing', 1, [2, 3, 4]);
-  test.assertEqual(lastPrint(), "console.info: " + name + ": testing 1 Array [2,3,4]\n",
+  assert.equal(lastPrint(), "console.info: " + name + ": testing 1 Array [2,3,4]\n",
                    "PlainTextConsole.info() must work.");
 
   con.warn('testing', 1, [2, 3, 4]);
-  test.assertEqual(lastPrint(), "console.warn: " + name + ": testing 1 Array [2,3,4]\n",
+  assert.equal(lastPrint(), "console.warn: " + name + ": testing 1 Array [2,3,4]\n",
                    "PlainTextConsole.warn() must work.");
 
   con.error('testing', 1, [2, 3, 4]);
-  test.assertEqual(prints[0], "console.error: " + name + ": \n",
+  assert.equal(prints[0], "console.error: " + name + ": \n",
                    "PlainTextConsole.error() must work.");
-  test.assertEqual(prints[1], "  testing\n")
-  test.assertEqual(prints[2], "  1\n")
-  test.assertEqual(prints[3], "Array\n    - 0 = 2\n    - 1 = 3\n    - 2 = 4\n    - length = 3\n");
+  assert.equal(prints[1], "  testing\n")
+  assert.equal(prints[2], "  1\n")
+  assert.equal(prints[3], "Array\n    - 0 = 2\n    - 1 = 3\n    - 2 = 4\n    - length = 3\n");
   prints = [];
 
   con.debug('testing', 1, [2, 3, 4]);
-  test.assertEqual(prints[0], "console.debug: " + name + ": \n",
+  assert.equal(prints[0], "console.debug: " + name + ": \n",
                    "PlainTextConsole.debug() must work.");
-  test.assertEqual(prints[1], "  testing\n")
-  test.assertEqual(prints[2], "  1\n")
-  test.assertEqual(prints[3], "Array\n    - 0 = 2\n    - 1 = 3\n    - 2 = 4\n    - length = 3\n");
+  assert.equal(prints[1], "  testing\n")
+  assert.equal(prints[2], "  1\n")
+  assert.equal(prints[3], "Array\n    - 0 = 2\n    - 1 = 3\n    - 2 = 4\n    - length = 3\n");
   prints = [];
 
   con.log('testing', undefined);
-  test.assertEqual(lastPrint(), "console.log: " + name + ": testing undefined\n",
+  assert.equal(lastPrint(), "console.log: " + name + ": testing undefined\n",
                    "PlainTextConsole.log() must stringify undefined.");
 
   con.log('testing', null);
-  test.assertEqual(lastPrint(), "console.log: " + name + ": testing null\n",
+  assert.equal(lastPrint(), "console.log: " + name + ": testing null\n",
                    "PlainTextConsole.log() must stringify null.");
 
   // TODO: Fix console.jsm to detect custom toString.
   con.log("testing", { toString: function() "obj.toString()" });
-  test.assertEqual(lastPrint(), "console.log: " + name + ": testing {}\n",
+  assert.equal(lastPrint(), "console.log: " + name + ": testing {}\n",
                    "PlainTextConsole.log() doesn't printify custom toString.");
 
   con.log("testing", { toString: function() { throw "fail!"; } });
-  test.assertEqual(lastPrint(), "console.log: " + name + ": testing {}\n",
+  assert.equal(lastPrint(), "console.log: " + name + ": testing {}\n",
                    "PlainTextConsole.log() must stringify custom bad toString.");
 
-  
+
   con.exception(new Error("blah"));
 
-  
-  test.assertEqual(prints[0], "console.error: " + name + ": \n");
+
+  assert.equal(prints[0], "console.error: " + name + ": \n");
   let tbLines = prints[1].split("\n");
-  test.assertEqual(tbLines[0], "  Message: Error: blah");
-  test.assertEqual(tbLines[1], "  Stack:");
-  test.assert(prints[1].indexOf(module.uri + ":84") !== -1);
+  assert.equal(tbLines[0], "  Message: Error: blah");
+  assert.equal(tbLines[1], "  Stack:");
+  assert.ok(prints[1].indexOf(module.uri + ":84") !== -1);
   prints = []
 
   try {
     loadSubScript("invalid-url", {});
-    test.fail("successed in calling loadSubScript with invalid-url");
+    assert.fail("successed in calling loadSubScript with invalid-url");
   }
   catch(e) {
     con.exception(e);
   }
-  test.assertEqual(prints[0], "console.error: " + name + ": \n");
-  test.assertEqual(prints[1], "  Error creating URI (invalid URL scheme?)\n");
+  assert.equal(prints[0], "console.error: " + name + ": \n");
+  assert.equal(prints[1], "  Error creating URI (invalid URL scheme?)\n");
   prints = [];
 
   con.trace();
   let tbLines = prints[0].split("\n");
-  test.assertEqual(tbLines[0], "console.trace: " + name + ": ");
-  test.assert(tbLines[1].indexOf("_ain-text-console.js 105") == 0);
+  assert.equal(tbLines[0], "console.trace: " + name + ": ");
+  assert.ok(tbLines[1].indexOf("_ain-text-console.js 105") == 0);
   prints = [];
 
   // Whether or not console methods should print at the various log levels,
   // structured as a hash of levels, each of which contains a hash of methods,
   // each of whose value is whether or not it should print, i.e.:
   // { [level]: { [method]: [prints?], ... }, ... }.
   let levels = {
     all:   { debug: true,  log: true,  info: true,  warn: true,  error: true  },
@@ -135,40 +135,111 @@ exports.testPlainTextConsole = function(
     for (let method in methods) {
       // We have to reset the log level pref each time we run the test
       // because the test runner relies on the console to print test output,
       // and test results would not get printed to the console for some
       // values of the pref.
       prefs.set(SDK_LOG_LEVEL_PREF, level);
       con[method]("");
       prefs.set(SDK_LOG_LEVEL_PREF, "all");
-      test.assertEqual(prints.join(""), 
+      assert.equal(prints.join(""),
                        (methods[method] ? messages[method] : ""),
                        "at log level '" + level + "', " + method + "() " +
                        (methods[method] ? "prints" : "doesn't print"));
       prints = [];
     }
   }
 
   prefs.set(SDK_LOG_LEVEL_PREF, "off");
   prefs.set(ADDON_LOG_LEVEL_PREF, "all");
   con.debug("");
-  test.assertEqual(prints.join(""), messages["debug"],
+  assert.equal(prints.join(""), messages["debug"],
                    "addon log level 'all' overrides SDK log level 'off'");
   prints = [];
 
   prefs.set(SDK_LOG_LEVEL_PREF, "all");
   prefs.set(ADDON_LOG_LEVEL_PREF, "off");
   con.error("");
   prefs.reset(ADDON_LOG_LEVEL_PREF);
-  test.assertEqual(lastPrint(), null,
+  assert.equal(lastPrint(), null,
                    "addon log level 'off' overrides SDK log level 'all'");
 
+  restorePrefs();
+};
+
+exports.testPlainTextConsoleBoundMethods = function(assert) {
+  let prints = [];
+  function print(message) {
+    prints.push(message);
+  }
+  function lastPrint() {
+    let last = prints.slice(-1)[0];
+    prints = [];
+    return last;
+  }
+
+  prefs.set(SDK_LOG_LEVEL_PREF, "all");
+  prefs.reset(ADDON_LOG_LEVEL_PREF);
+
+  let Console = require("sdk/console/plain-text").PlainTextConsole;
+  let { log, info, warn, error, debug, exception, trace } = new Console(print);
+
+  assert.ok("PlainTextConsole instantiates");
+
+  log('testing', 1, [2, 3, 4]);
+  assert.equal(lastPrint(), "console.log: " + name + ": testing 1 Array [2,3,4]\n",
+                   "PlainTextConsole.log() must work.");
+
+  info('testing', 1, [2, 3, 4]);
+  assert.equal(lastPrint(), "console.info: " + name + ": testing 1 Array [2,3,4]\n",
+                   "PlainTextConsole.info() must work.");
+
+  warn('testing', 1, [2, 3, 4]);
+  assert.equal(lastPrint(), "console.warn: " + name + ": testing 1 Array [2,3,4]\n",
+                   "PlainTextConsole.warn() must work.");
+
+  error('testing', 1, [2, 3, 4]);
+  assert.equal(prints[0], "console.error: " + name + ": \n",
+                   "PlainTextConsole.error() must work.");
+  assert.equal(prints[1], "  testing\n")
+  assert.equal(prints[2], "  1\n")
+  assert.equal(prints[3], "Array\n    - 0 = 2\n    - 1 = 3\n    - 2 = 4\n    - length = 3\n");
+  prints = [];
+
+  debug('testing', 1, [2, 3, 4]);
+  assert.equal(prints[0], "console.debug: " + name + ": \n",
+                   "PlainTextConsole.debug() must work.");
+  assert.equal(prints[1], "  testing\n")
+  assert.equal(prints[2], "  1\n")
+  assert.equal(prints[3], "Array\n    - 0 = 2\n    - 1 = 3\n    - 2 = 4\n    - length = 3\n");
+  prints = [];
+
+  exception(new Error("blah"));
+
+  assert.equal(prints[0], "console.error: " + name + ": \n");
+  let tbLines = prints[1].split("\n");
+  assert.equal(tbLines[0], "  Message: Error: blah");
+  assert.equal(tbLines[1], "  Stack:");
+  assert.ok(prints[1].indexOf(module.uri + ":215") !== -1);
+  prints = []
+
+  trace();
+  let tbLines = prints[0].split("\n");
+  assert.equal(tbLines[0], "console.trace: " + name + ": ");
+  assert.ok(tbLines[1].indexOf("_ain-text-console.js 224") === 0);
+  prints = [];
+
+  restorePrefs();
+};
+
+function restorePrefs() {
   if (HAS_ORIGINAL_ADDON_LOG_LEVEL)
     prefs.set(ADDON_LOG_LEVEL_PREF, ORIGINAL_ADDON_LOG_LEVEL);
   else
     prefs.reset(ADDON_LOG_LEVEL_PREF);
 
   if (HAS_ORIGINAL_SDK_LOG_LEVEL)
     prefs.set(SDK_LOG_LEVEL_PREF, ORIGINAL_SDK_LOG_LEVEL);
   else
     prefs.reset(SDK_LOG_LEVEL_PREF);
-};
+}
+
+require("test").run(exports);
--- a/addon-sdk/source/test/test-promise.js
+++ b/addon-sdk/source/test/test-promise.js
@@ -1,12 +1,11 @@
-/* vim:set ts=2 sw=2 sts=2 expandtab */
-/*jshint asi: true undef: true es5: true node: true devel: true
-         forin: true */
-/*global define: true */
+/* 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 core = require('sdk/core/promise'),
     defer = core.defer, resolve = core.resolve, reject = core.reject, all = core.all,
     promised = core.promised;
 
 var { setTimeout } = require('sdk/timers');
--- a/addon-sdk/source/test/test-self.js
+++ b/addon-sdk/source/test/test-self.js
@@ -1,65 +1,65 @@
 /* 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 {Cc, Ci, Cu, Cm, components} = require('chrome');
-Cu.import("resource://gre/modules/AddonManager.jsm", this);
+const { Cc, Ci, Cu, Cm, components } = require("chrome");
 const xulApp = require("sdk/system/xul-app");
+const self = require("sdk/self");
 
-exports.testSelf = function(test) {
-  var self = require("sdk/self");
+const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm", {});
 
+exports.testSelf = function(assert) {
   var source = self.data.load("test-content-symbiont.js");
-  test.assert(source.match(/test-content-symbiont/), "self.data.load() works");
+  assert.ok(source.match(/test-content-symbiont/), "self.data.load() works");
 
   // Likewise, we can't assert anything about the full URL, because that
   // depends on self.id . We can only assert that it ends in the right
   // thing.
   var url = self.data.url("test-content-symbiont.js");
-  test.assertEqual(typeof(url), "string", "self.data.url('x') returns string");
-  test.assertEqual(/\/test-content-symbiont\.js$/.test(url), true);
+  assert.equal(typeof(url), "string", "self.data.url('x') returns string");
+  assert.equal(/\/test-content-symbiont\.js$/.test(url), true);
 
   // Make sure 'undefined' is not in url when no string is provided.
   url = self.data.url();
-  test.assertEqual(typeof(url), "string", "self.data.url() returns string");
-  test.assertEqual(/\/undefined$/.test(url), false);
+  assert.equal(typeof(url), "string", "self.data.url() returns string");
+  assert.equal(/\/undefined$/.test(url), false);
 
   // When tests are run on just the api-utils package, self.name is
   // api-utils. When they're run as 'cfx testall', self.name is testpkgs.
-  test.assert(self.name == "addon-sdk", "self.name is addon-sdk");
+  assert.equal(self.name, "addon-sdk", "self.name is addon-sdk");
 
   // loadReason may change here, as we change the way tests addons are installed
   // Bug 854937 fixed loadReason and is now install
   let testLoadReason = xulApp.versionInRange(xulApp.platformVersion,
                                              "23.0a1", "*") ? "install"
                                                             : "startup";
-  test.assertEqual(self.loadReason, testLoadReason,
-                   "self.loadReason is either startup or install on test runs");
+  assert.equal(self.loadReason, testLoadReason,
+               "self.loadReason is either startup or install on test runs");
 
-  test.assertEqual(self.isPrivateBrowsingSupported, false,
-                   'usePrivateBrowsing property is false by default');
+  assert.equal(self.isPrivateBrowsingSupported, false,
+               'usePrivateBrowsing property is false by default');
 };
 
-exports.testSelfID = function(test) {
-  test.waitUntilDone();
-
+exports.testSelfID = function(assert, done) {
   var self = require("sdk/self");
   // We can't assert anything about the ID inside the unit test right now,
   // because the ID we get depends upon how the test was invoked. The idea
   // is that it is supposed to come from the main top-level package's
   // package.json file, from the "id" key.
-  test.assertEqual(typeof(self.id), "string", "self.id is a string");
-  test.assert(self.id.length > 0);
+  assert.equal(typeof(self.id), "string", "self.id is a string");
+  assert.ok(self.id.length > 0);
 
   AddonManager.getAddonByID(self.id, function(addon) {
     if (!addon) {
-      test.fail("did not find addon with self.id");
+      assert.fail("did not find addon with self.id");
     }
     else {
-      test.pass("found addon with self.id");
+      assert.pass("found addon with self.id");
     }
-    test.done();
+
+    done();
   });
 }
+
+require("sdk/test").run(exports);
--- a/addon-sdk/source/test/test-simple-storage.js
+++ b/addon-sdk/source/test/test-simple-storage.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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 file = require("sdk/io/file");
 const prefs = require("sdk/preferences/service");
 
 const QUOTA_PREF = "extensions.addon-sdk.simple-storage.quota";
 
--- a/addon-sdk/source/test/test-system-runtime.js
+++ b/addon-sdk/source/test/test-system-runtime.js
@@ -1,13 +1,11 @@
 /* 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/.
- */
-
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 var runtime = require("sdk/system/runtime");
 
 exports["test system runtime"] = function(assert) {
   assert.equal(typeof(runtime.inSafeMode), "boolean",
                "inSafeMode is boolean");
   assert.equal(typeof(runtime.OS), "string",
--- a/addon-sdk/source/test/test-text-streams.js
+++ b/addon-sdk/source/test/test-text-streams.js
@@ -1,11 +1,9 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim:set ts=2 sw=2 sts=2 et filetype=javascript
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* 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 file = require("sdk/io/file");
 const { pathFor } = require("sdk/system");
 const { Loader } = require("sdk/test/loader");
 
 const STREAM_CLOSED_ERROR = "The stream is closed and cannot be used.";
--- a/addon-sdk/source/test/test-traits-core.js
+++ b/addon-sdk/source/test/test-traits-core.js
@@ -1,75 +1,76 @@
 /* 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 ERR_CONFLICT = 'Remaining conflicting property: ',
       ERR_REQUIRED = 'Missing required property: ';
 
-function assertSametrait(test, trait1, trait2) {
+function assertSametrait(assert, trait1, trait2) {
   let names1 = Object.getOwnPropertyNames(trait1),
       names2 = Object.getOwnPropertyNames(trait2);
 
-  test.assertEqual(
+  assert.equal(
     names1.length,
     names2.length,
     'equal traits must have same amount of properties'
   );
 
   for (let i = 0; i < names1.length; i++) {
     let name = names1[i];
-    test.assertNotEqual(
+    assert.notEqual(
       -1,
       names2.indexOf(name),
       'equal traits must contain same named properties: ' + name
     );
-    assertSameDescriptor(test, name, trait1[name], trait2[name]);
+    assertSameDescriptor(assert, name, trait1[name], trait2[name]);
   }
 }
 
-function assertSameDescriptor(test, name, desc1, desc2) {
+function assertSameDescriptor(assert, name, desc1, desc2) {
   if (desc1.conflict || desc2.conflict) {
-    test.assertEqual(
+    assert.equal(
       desc1.conflict,
       desc2.conflict,
       'if one of same descriptors has `conflict` another must have it: '
         + name
     );
-  } else if (desc1.required || desc2.required) {
-    test.assertEqual(
+  }
+  else if (desc1.required || desc2.required) {
+    assert.equal(
       desc1.required,
       desc2.required,
       'if one of same descriptors is has `required` another must have it: '
         + name
     );
-  } else {
-    test.assertEqual(
+  }
+  else {
+    assert.equal(
       desc1.get,
       desc2.get,
       'get must be the same on both descriptors: ' + name
     );
-    test.assertEqual(
+    assert.equal(
       desc1.set,
       desc2.set,
       'set must be the same on both descriptors: ' + name
     );
-    test.assertEqual(
+    assert.equal(
       desc1.value,
       desc2.value,
       'value must be the same on both descriptors: ' + name
     );
-    test.assertEqual(
+    assert.equal(
       desc1.enumerable,
       desc2.enumerable,
       'enumerable must be the same on both descriptors: ' + name
     );
-    test.assertEqual(
+    assert.equal(
       desc1.required,
       desc2.required,
       'value must be the same on both descriptors: ' + name
     );
   }
 }
 
 function Data(value, enumerable, confligurable, writable) {
@@ -118,199 +119,202 @@ function Conflict(name) {
 }
 
 function testMethod() {};
 
 const { trait, compose, resolve, required, override, create } =
   require('sdk/deprecated/traits/core');
 
 
-exports['test:empty trait'] = function(test) {
+exports['test:empty trait'] = function(assert) {
   assertSametrait(
-    test,
+    assert,
     trait({}),
     {}
   );
 };
 
-exports['test:simple trait'] = function(test) {
+exports['test:simple trait'] = function(assert) {
   assertSametrait(
-    test,
+    assert,
     trait({
       a: 0,
       b: testMethod
     }),
     {
       a: Data(0, true, true, true),
       b: Method(testMethod, true, true, true)
     }
   );
 };
 
-exports['test:simple trait with required prop'] = function(test) {
+exports['test:simple trait with required prop'] = function(assert) {
   assertSametrait(
-    test,
+    assert,
     trait({
       a: required,
       b: 1
     }),
     {
       a: Required('a'),
       b: Data(1)
     }
   );
 };
 
-exports['test:ordering of trait properties is irrelevant'] = function(test) {
-  assertSametrait(test,
+exports['test:ordering of trait properties is irrelevant'] = function(assert) {
+  assertSametrait(
+    assert,
     trait({ a: 0, b: 1, c: required }),
     trait({ b: 1, c: required, a: 0 })
   );
 };
 
-exports['test:trait with accessor property'] = function(test) {
+exports['test:trait with accessor property'] = function(assert) {
   let record = { get a() {}, set a(v) {} };
   let get = Object.getOwnPropertyDescriptor(record,'a').get;
   let set = Object.getOwnPropertyDescriptor(record,'a').set;
-  assertSametrait(test,
+  assertSametrait(assert,
     trait(record),
     { a: Accessor(get, set ) }
   );
 };
 
-exports['test:simple composition'] = function(test) {
-  assertSametrait(test,
+exports['test:simple composition'] = function(assert) {
+  assertSametrait(
+    assert,
     compose(
       trait({ a: 0, b: 1 }),
       trait({ c: 2, d: testMethod })
     ),
     {
       a: Data(0),
       b: Data(1),
       c: Data(2),
       d: Method(testMethod)
     }
   );
 };
 
-exports['test:composition with conflict'] = function(test) {
-  assertSametrait(test,
+exports['test:composition with conflict'] = function(assert) {
+  assertSametrait(
+    assert,
     compose(
       trait({ a: 0, b: 1 }),
       trait({ a: 2, c: testMethod })
     ),
     {
       a: Conflict('a'),
       b: Data(1),
       c: Method(testMethod)
     }
   );
 };
 
 exports['test:composition of identical props does not cause conflict'] =
-function(test) {
-  assertSametrait(test,
+function(assert) {
+  assertSametrait(assert,
     compose(
       trait({ a: 0, b: 1 }),
       trait({ a: 0, c: testMethod })
     ),
     {
       a: Data(0),
       b: Data(1),
       c: Method(testMethod) }
   )
 };
 
 exports['test:composition with identical required props'] =
-function(test) {
-  assertSametrait(test,
+function(assert) {
+  assertSametrait(assert,
     compose(
       trait({ a: required, b: 1 }),
       trait({ a: required, c: testMethod })
     ),
     {
       a: Required(),
       b: Data(1),
       c: Method(testMethod)
     }
   );
 };
 
-exports['test:composition satisfying a required prop'] = function (test) {
-  assertSametrait(test,
+exports['test:composition satisfying a required prop'] = function (assert) {
+  assertSametrait(assert,
     compose(
       trait({ a: required, b: 1 }),
       trait({ a: testMethod })
     ),
     {
       a: Method(testMethod),
       b: Data(1)
     }
   );
 };
 
-exports['test:compose is neutral wrt conflicts'] = function (test) {
-  assertSametrait(test,
+exports['test:compose is neutral wrt conflicts'] = function (assert) {
+  assertSametrait(assert,
     compose(
       compose(
         trait({ a: 1 }),
         trait({ a: 2 })
       ),
       trait({ b: 0 })
     ),
     {
       a: Conflict('a'),
       b: Data(0)
     }
   );
 };
 
-exports['test:conflicting prop overrides required prop'] = function (test) {
-  assertSametrait(test,
+exports['test:conflicting prop overrides required prop'] = function (assert) {
+  assertSametrait(assert,
     compose(
       compose(
         trait({ a: 1 }),
         trait({ a: 2 })
       ),
       trait({ a: required })
     ),
     {
       a: Conflict('a')
     }
   );
 };
 
-exports['test:compose is commutative'] = function (test) {
-  assertSametrait(test,
+exports['test:compose is commutative'] = function (assert) {
+  assertSametrait(assert,
     compose(
       trait({ a: 0, b: 1 }),
       trait({ c: 2, d: testMethod })
     ),
     compose(
       trait({ c: 2, d: testMethod }),
       trait({ a: 0, b: 1 })
     )
   );
 };
 
 exports['test:compose is commutative, also for required/conflicting props'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     compose(
       trait({ a: 0, b: 1, c: 3, e: required }),
       trait({ c: 2, d: testMethod })
     ),
     compose(
       trait({ c: 2, d: testMethod }),
       trait({ a: 0, b: 1, c: 3, e: required })
     )
   );
 };
-exports['test:compose is associative'] = function (test) {
-  assertSametrait(test,
+exports['test:compose is associative'] = function (assert) {
+  assertSametrait(assert,
     compose(
       trait({ a: 0, b: 1, c: 3, d: required }),
       compose(
         trait({ c: 3, d: required }),
         trait({ c: 2, d: testMethod, e: 'foo' })
       )
     ),
     compose(
@@ -319,18 +323,18 @@ exports['test:compose is associative'] =
         trait({ c: 3, d: required })
       ),
       trait({ c: 2, d: testMethod, e: 'foo' })
     )
   );
 };
 
 exports['test:diamond import of same prop does not generate conflict'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     compose(
       compose(
         trait({ b: 2 }),
         trait({ a: 1 })
       ),
       compose(
         trait({ c: 3 }),
         trait({ a: 1 })
@@ -342,371 +346,371 @@ function (test) {
       b: Data(2),
       c: Data(3),
       d: Data(4)
     }
   );
 };
 
 exports['test:resolve with empty resolutions has no effect'] =
-function (test) {
-  assertSametrait(test, resolve({}, trait({
+function (assert) {
+  assertSametrait(assert, resolve({}, trait({
     a: 1,
     b: required,
     c: testMethod
   })), {
     a: Data(1),
     b: Required(),
     c: Method(testMethod)
   });
 };
 
-exports['test:resolve: renaming'] = function (test) {
-  assertSametrait(test,
+exports['test:resolve: renaming'] = function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'A', c: 'C' },
       trait({ a: 1, b: required, c: testMethod })
     ),
     {
       A: Data(1),
       b: Required(),
       C: Method(testMethod),
       a: Required(),
       c: Required()
     }
   );
 };
 
 exports['test:resolve: renaming to conflicting name causes conflict, order 1']
-= function (test) {
-  assertSametrait(test,
+= function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'b'},
       trait({ a: 1, b: 2 })
     ),
     {
       b: Conflict('b'),
       a: Required()
     }
   );
 };
 
 exports['test:resolve: renaming to conflicting name causes conflict, order 2']
-= function (test) {
-  assertSametrait(test,
+= function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'b' },
       trait({ b: 2, a: 1 })
     ),
     {
       b: Conflict('b'),
       a: Required()
     }
   );
 };
 
-exports['test:resolve: simple exclusion'] = function (test) {
-  assertSametrait(test,
+exports['test:resolve: simple exclusion'] = function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: undefined },
       trait({ a: 1, b: 2 })
     ),
     {
       a: Required(),
       b: Data(2)
     }
   );
 };
 
-exports['test:resolve: exclusion to "empty" trait'] = function (test) {
-  assertSametrait(test,
+exports['test:resolve: exclusion to "empty" trait'] = function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: undefined, b: undefined },
       trait({ a: 1, b: 2 })
     ),
     {
       a: Required(),
       b: Required()
     }
   );
 };
 
 exports['test:resolve: exclusion and renaming of disjoint props'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: undefined, b: 'c' },
       trait({ a: 1, b: 2 })
     ),
     {
       a: Required(),
       c: Data(2),
       b: Required()
     }
   );
 };
 
 exports['test:resolve: exclusion and renaming of overlapping props'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: undefined, b: 'a' },
       trait({ a: 1, b: 2 })
     ),
     {
       a: Data(2),
       b: Required()
     }
   );
 };
 
 exports['test:resolve: renaming to a common alias causes conflict'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'c', b: 'c' },
       trait({ a: 1, b: 2 })
     ),
     {
       c: Conflict('c'),
       a: Required(),
       b: Required()
     }
   );
 };
 
 exports['test:resolve: renaming overrides required target'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { b: 'a' },
       trait({ a: required, b: 2 })
     ),
     {
       a: Data(2),
       b: Required()
     }
   );
 };
 
 exports['test:resolve: renaming required properties has no effect'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { b: 'a' },
       trait({ a: 2, b: required })
     ),
     {
       a: Data(2),
       b: Required()
     }
   );
 };
 
 exports['test:resolve: renaming of non-existent props has no effect'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'c', d: 'c' },
       trait({ a: 1, b: 2 })
     ),
     {
       c: Data(1),
       b: Data(2),
       a: Required()
     }
   );
 };
 
 exports['test:resolve: exclusion of non-existent props has no effect'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { b: undefined },
       trait({ a: 1 })
     ),
     {
       a: Data(1)
     }
   );
 };
 
 exports['test:resolve is neutral w.r.t. required properties'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'c', b: undefined },
       trait({ a: required, b: required, c: 'foo', d: 1 })
     ),
     {
       a: Required(),
       b: Required(),
       c: Data('foo'),
       d: Data(1)
     }
   );
 };
 
 exports['test:resolve supports swapping of property names, ordering 1'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'b', b: 'a' },
       trait({ a: 1, b: 2 })
     ),
     {
       a: Data(2),
       b: Data(1)
     }
   );
 };
 
 exports['test:resolve supports swapping of property names, ordering 2'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { b: 'a', a: 'b' },
       trait({ a: 1, b: 2 })
     ),
     {
       a: Data(2),
       b: Data(1)
     }
   );
 };
 
 exports['test:resolve supports swapping of property names, ordering 3'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { b: 'a', a: 'b' },
       trait({ b: 2, a: 1 })
     ),
     {
       a: Data(2),
       b: Data(1)
     }
   );
 };
 
 exports['test:resolve supports swapping of property names, ordering 4'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     resolve(
       { a: 'b', b: 'a' },
       trait({ b: 2, a: 1 })
     ),
     {
       a: Data(2),
       b: Data(1)
     }
   );
 };
 
-exports['test:override of mutually exclusive traits'] = function (test) {
-  assertSametrait(test,
+exports['test:override of mutually exclusive traits'] = function (assert) {
+  assertSametrait(assert,
     override(
       trait({ a: 1, b: 2 }),
       trait({ c: 3, d: testMethod })
     ),
     {
       a: Data(1),
       b: Data(2),
       c: Data(3),
       d: Method(testMethod)
     }
   );
 };
 
 exports['test:override of mutually exclusive traits is compose'] =
-function (test) {
-  assertSametrait(test,
+function (assert) {
+  assertSametrait(assert,
     override(
       trait({ a: 1, b: 2 }),
       trait({ c: 3, d: testMethod })
     ),
     compose(
       trait({ d: testMethod, c: 3 }),
       trait({ b: 2, a: 1 })
     )
   );
 };
 
-exports['test:override of overlapping traits'] = function (test) {
-  assertSametrait(test,
+exports['test:override of overlapping traits'] = function (assert) {
+  assertSametrait(assert,
     override(
       trait({ a: 1, b: 2 }),
       trait({ a: 3, c: testMethod })
     ),
     {
       a: Data(1),
       b: Data(2),
       c: Method(testMethod)
     }
   );
 };
 
-exports['test:three-way override of overlapping traits'] = function (test) {
-  assertSametrait(test,
+exports['test:three-way override of overlapping traits'] = function (assert) {
+  assertSametrait(assert,
     override(
       trait({ a: 1, b: 2 }),
       trait({ b: 4, c: 3 }),
       trait({ a: 3, c: testMethod, d: 5 })
     ),
     {
       a: Data(1),
       b: Data(2),
       c: Data(3),
       d: Data(5)
     }
   );
 };
 
-exports['test:override replaces required properties'] = function (test) {
-  assertSametrait(test,
+exports['test:override replaces required properties'] = function (assert) {
+  assertSametrait(assert,
     override(
       trait({ a: required, b: 2 }),
       trait({ a: 1, c: testMethod })
     ),
     {
       a: Data(1),
       b: Data(2),
       c: Method(testMethod)
     }
   );
 };
 
-exports['test:override is not commutative'] = function (test) {
-  assertSametrait(test,
+exports['test:override is not commutative'] = function (assert) {
+  assertSametrait(assert,
     override(
       trait({ a: 1, b: 2 }),
       trait({ a: 3, c: 4 })
     ),
     {
       a: Data(1),
       b: Data(2),
       c: Data(4)
     }
   );
 
-  assertSametrait(test,
+  assertSametrait(assert,
     override(
       trait({ a: 3, c: 4 }),
       trait({ a: 1, b: 2 })
     ),
     {
       a: Data(3),
       b: Data(2),
       c: Data(4)
     }
   );
 };
 
-exports['test:override is associative'] = function (test) {
-  assertSametrait(test,
+exports['test:override is associative'] = function (assert) {
+  assertSametrait(assert,
     override(
       override(
         trait({ a: 1, b: 2 }),
         trait({ a: 3, c: 4, d: 5 })
       ),
       trait({ a: 6, c: 7, e: 8 })
     ),
     override(
@@ -714,125 +718,133 @@ exports['test:override is associative'] 
       override(
         trait({ a: 3, c: 4, d: 5 }),
         trait({ a: 6, c: 7, e: 8 })
       )
     )
   );
 };
 
-exports['test:create simple'] = function(test) {
+exports['test:create simple'] = function(assert) {
   let o1 = create(
     Object.prototype,
     trait({ a: 1, b: function() { return this.a; } })
   );
 
-  test.assertEqual(
+  assert.equal(
     Object.prototype,
     Object.getPrototypeOf(o1),
     'o1 prototype'
   );
-  test.assertEqual(1, o1.a, 'o1.a');
-  test.assertEqual(1, o1.b(), 'o1.b()');
-  test.assertEqual(
+  assert.equal(1, o1.a, 'o1.a');
+  assert.equal(1, o1.b(), 'o1.b()');
+  assert.equal(
     2,
     Object.getOwnPropertyNames(o1).length,
     'Object.keys(o1).length === 2'
   );
 };
 
-exports['test:create with Array.prototype'] = function(test) {
+exports['test:create with Array.prototype'] = function(assert) {
   let o2 = create(Array.prototype, trait({}));
-  test.assertEqual(
+  assert.equal(
     Array.prototype,
     Object.getPrototypeOf(o2),
     "o2 prototype"
   );
 };
 
 exports['test:exception for incomplete required properties'] =
-function(test) {
+function(assert) {
   try {
     create(Object.prototype, trait({ foo: required }));
-    test.fail('expected create to complain about missing required props');
-  } catch(e) {
-    test.assertEqual(
+    assert.fail('expected create to complain about missing required props');
+  }
+  catch(e) {
+    assert.equal(
       'Error: Missing required property: foo',
       e.toString(),
       'required prop error'
     );
   }
 };
 
-exports['test:exception for unresolved conflicts'] = function(test) {
+exports['test:exception for unresolved conflicts'] = function(assert) {
   try {
     create({}, compose(trait({ a: 0 }), trait({ a: 1 })));
-    test.fail('expected create to complain about unresolved conflicts');
-  } catch(e) {
-    test.assertEqual(
+    assert.fail('expected create to complain about unresolved conflicts');
+  }
+  catch(e) {
+    assert.equal(
       'Error: Remaining conflicting property: a',
       e.toString(),
       'conflicting prop error'
     );
   }
 };
 
 exports['test:verify that required properties are present but undefined'] =
-function(test) {
+function(assert) {
   try {
     let o4 = Object.create(Object.prototype, trait({ foo: required }));
-    test.assertEqual(true, 'foo' in o4, 'required property present');
+    assert.equal(true, 'foo' in o4, 'required property present');
     try {
       let foo = o4.foo;
-      test.fail('access to required property must throw');
-    } catch(e) {
-      test.assertEqual(
+      assert.fail('access to required property must throw');
+    }
+    catch(e) {
+      assert.equal(
         'Error: Missing required property: foo',
         e.toString(),
         'required prop error'
       )
     }
-  } catch(e) {
-    test.fail('did not expect create to complain about required props');
+  }
+  catch(e) {
+    assert.fail('did not expect create to complain about required props');
   }
 };
 
 exports['test:verify that conflicting properties are present'] =
-function(test) {
+function(assert) {
   try {
     let o5 = Object.create(
       Object.prototype,
       compose(trait({ a: 0 }), trait({ a: 1 }))
     );
-    test.assertEqual(true, 'a' in o5, 'conflicting property present');
+    assert.equal(true, 'a' in o5, 'conflicting property present');
     try {
       let a = o5.a; // accessors or data prop
-      test.fail('expected conflicting prop to cause exception');
-    } catch (e) {
-      test.assertEqual(
+      assert.fail('expected conflicting prop to cause exception');
+    }
+    catch (e) {
+      assert.equal(
         'Error: Remaining conflicting property: a',
         e.toString(),
         'conflicting prop access error'
       );
     }
-  } catch(e) {
-    test.fail('did not expect create to complain about conflicting props');
+  }
+  catch(e) {
+    assert.fail('did not expect create to complain about conflicting props');
   }
 };
 
-exports['test diamond with conflicts'] = function(test) {
+exports['test diamond with conflicts'] = function(assert) {
   function makeT1(x) trait({ m: function() { return x; } })
   function makeT2(x) compose(trait({ t2: 'foo' }), makeT1(x))
   function makeT3(x) compose(trait({ t3: 'bar' }), makeT1(x))
 
   let T4 = compose(makeT2(5), makeT3(5));
   try {
     let o = create(Object.prototype, T4);
-    test.fail('expected diamond prop to cause exception');
-  } catch(e) {
-    test.assertEqual(
+    assert.fail('expected diamond prop to cause exception');
+  }
+  catch(e) {
+    assert.equal(
       'Error: Remaining conflicting property: m',
       e.toString(),
       'diamond prop conflict'
     );
   }
 };
 
+require('sdk/test').run(exports);
--- a/addon-sdk/source/test/test-unload.js
+++ b/addon-sdk/source/test/test-unload.js
@@ -1,69 +1,67 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* 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 unload = require("sdk/system/unload");
 var { Loader, LoaderWithHookedConsole } = require("sdk/test/loader");
 
-exports.testUnloading = function(test) {
+exports.testUnloading = function(assert) {
   let { loader, messages } = LoaderWithHookedConsole(module);
   var ul = loader.require("sdk/system/unload");
   var unloadCalled = 0;
   function unload() {
     unloadCalled++;
     throw new Error("error");
   }
   ul.when(unload);
 
   // This should be ignored, as we already registered it
   ul.when(unload);
 
   function unload2() { unloadCalled++; }
   ul.when(unload2);
   loader.unload();
-  test.assertEqual(unloadCalled, 2,
+  assert.equal(unloadCalled, 2,
                    "Unloader functions are called on unload.");
-  test.assertEqual(messages.length, 1,
+  assert.equal(messages.length, 1,
                    "One unload handler threw exception 1/2");
-  test.assertEqual(messages[0].type, "exception",
+  assert.equal(messages[0].type, "exception",
                    "One unload handler threw exception 2/2");
 };
 
-exports.testEnsure = function(test) {
-  test.assertRaises(function() { unload.ensure({}); },
-                    "object has no 'unload' property",
-                    "passing obj with no unload prop should fail");
-  test.assertRaises(function() { unload.ensure({}, "destroy"); },
-                    "object has no 'destroy' property",
-                    "passing obj with no custom unload prop should fail");
+exports.testEnsure = function(assert) {
+  assert.throws(function() { unload.ensure({}); },
+                /object has no 'unload' property/,
+                "passing obj with no unload prop should fail");
+  assert.throws(function() { unload.ensure({}, "destroy"); },
+                /object has no 'destroy' property/,
+                "passing obj with no custom unload prop should fail");
 
   var called = 0;
   var obj = {unload: function() { called++; }};
 
   unload.ensure(obj);
   obj.unload();
-  test.assertEqual(called, 1,
+  assert.equal(called, 1,
                    "unload() should be called");
   obj.unload();
-  test.assertEqual(called, 1,
+  assert.equal(called, 1,
                    "unload() should be called only once");
 };
 
 /**
  * Check that destructors are called only once with Traits.
  * - check that public API is calling the destructor and unregister it,
  * - check that composed traits with multiple ensure calls, leads to only
  * one destructor call.
  */
-exports.testEnsureWithTraits = function(test) {
-
+exports.testEnsureWithTraits = function(assert) {
   let { Trait } = require("sdk/deprecated/traits");
   let loader = Loader(module);
   let ul = loader.require("sdk/system/unload");
 
   let called = 0;
   let composedCalled = 0;
   let composedTrait = Trait.compose({
       constructor: function () {
@@ -74,52 +72,51 @@ exports.testEnsureWithTraits = function(
       },
       unload: function unload() {
         composedCalled++;
       }
     });
   let obj = Trait.compose(
     composedTrait.resolve({
       constructor: "_constructor",
-      unload : "_unload" 
+      unload : "_unload"
     }), {
       constructor: function constructor() {
         // Same thing applies here, we need to pass public interface
         ul.ensure(this._public);
         this._constructor();
       },
       unload: function unload() {
         called++;
         this._unload();
       }
     })();
 
   obj.unload();
-  test.assertEqual(called, 1,
+  assert.equal(called, 1,
                    "unload() should be called");
 
-  test.assertEqual(composedCalled, 1,
+  assert.equal(composedCalled, 1,
                    "composed object unload() should be called");
 
   obj.unload();
-  test.assertEqual(called, 1,
+  assert.equal(called, 1,
                    "unload() should be called only once");
-  test.assertEqual(composedCalled, 1,
+  assert.equal(composedCalled, 1,
                    "composed object unload() should be called only once");
 
   loader.unload();
-  test.assertEqual(called, 1,
+  assert.equal(called, 1,
                    "unload() should be called only once, after addon unload");
-  test.assertEqual(composedCalled, 1,
+  assert.equal(composedCalled, 1,
                    "composed object unload() should be called only once, " +
                    "after addon unload");
 };
 
-exports.testEnsureWithTraitsPrivate = function(test) {
-
+exports.testEnsureWithTraitsPrivate = function(assert) {
   let { Trait } = require("sdk/deprecated/traits");
   let loader = Loader(module);
   let ul = loader.require("sdk/system/unload");
 
   let called = 0;
   let privateObj = null;
   let obj = Trait.compose({
       constructor: function constructor() {
@@ -130,33 +127,35 @@ exports.testEnsureWithTraitsPrivate = fu
       },
       _unload: function unload() {
         called++;
         this._unload();
       }
     })();
 
   loader.unload();
-  test.assertEqual(called, 1,
+  assert.equal(called, 1,
                    "unload() should be called");
 
   privateObj._unload();
-  test.assertEqual(called, 1,
+  assert.equal(called, 1,
                    "_unload() should be called only once, after addon unload");
 };
 
-exports.testReason = function (test) {
+exports.testReason = function (assert) {
   var reason = "Reason doesn't actually have to be anything in particular.";
   var loader = Loader(module);
   var ul = loader.require("sdk/system/unload");
   ul.when(function (rsn) {
-    test.assertEqual(rsn, reason,
+    assert.equal(rsn, reason,
                      "when() reason should be reason given to loader");
   });
   var obj = {
     unload: function (rsn) {
-      test.assertEqual(rsn, reason,
+      assert.equal(rsn, reason,
                        "ensure() reason should be reason given to loader");
     }
   };
   ul.ensure(obj);
   loader.unload(reason);
 };
+
+require("sdk/test").run(exports);
--- a/addon-sdk/source/test/test-widget.js
+++ b/addon-sdk/source/test/test-widget.js
@@ -12,359 +12,359 @@ module.metadata = {
 const widgets = require("sdk/widget");
 const { Cc, Ci } = require("chrome");
 const { Loader } = require('sdk/test/loader');
 const url = require("sdk/url");
 const timer = require("sdk/timers");
 const self = require("sdk/self");
 const windowUtils = require("sdk/deprecated/window-utils");
 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
+const { close } = require("sdk/window/helpers");
 
 let jetpackID = "testID";
 try {
   jetpackID = require("sdk/self").id;
 } catch(e) {}
 
 const australis = !!require("sdk/window/utils").getMostRecentBrowserWindow().CustomizableUI;
 
-exports.testConstructor = function(test) {
-  test.waitUntilDone();
-
+exports.testConstructor = function(assert, done) {
   let browserWindow = windowUtils.activeBrowserWindow;
   let doc = browserWindow.document;
   let AddonsMgrListener;
   if (australis) {
     AddonsMgrListener = {
       onInstalling: () => {},
       onInstalled: () => {},
       onUninstalling: () => {},
       onUninstalled: () => {}
     };
-  } else {
+  }
+  else {
     AddonsMgrListener = browserWindow.AddonsMgrListener;
   }
 
   function container() australis ? doc.getElementById("nav-bar") : doc.getElementById("addon-bar");
   function getWidgets() container() ? container().querySelectorAll('[id^="widget\:"]') : [];
   function widgetCount() getWidgets().length;
   let widgetStartCount = widgetCount();
   function widgetNode(index) getWidgets()[index];
 
   // Test basic construct/destroy
   AddonsMgrListener.onInstalling();
   let w = widgets.Widget({ id: "fooID", label: "foo", content: "bar" });
   AddonsMgrListener.onInstalled();
-  test.assertEqual(widgetCount(), widgetStartCount + 1, "panel has correct number of child elements after widget construction");
+  assert.equal(widgetCount(), widgetStartCount + 1, "panel has correct number of child elements after widget construction");
 
   // test widget height
-  test.assertEqual(widgetNode(0).firstChild.boxObject.height, 16, "widget has correct default height");
+  assert.equal(widgetNode(0).firstChild.boxObject.height, 16, "widget has correct default height");
 
   AddonsMgrListener.onUninstalling();
   w.destroy();
   AddonsMgrListener.onUninstalled();
   w.destroy();
-  test.pass("Multiple destroys do not cause an error");
-  test.assertEqual(widgetCount(), widgetStartCount, "panel has correct number of child elements after destroy");
+  assert.pass("Multiple destroys do not cause an error");
+  assert.equal(widgetCount(), widgetStartCount, "panel has correct number of child elements after destroy");
 
   // Test automatic widget destroy on unload
   let loader = Loader(module);
   let widgetsFromLoader = loader.require("sdk/widget");
   let widgetStartCount = widgetCount();
   let w = widgetsFromLoader.Widget({ id: "fooID", label: "foo", content: "bar" });
-  test.assertEqual(widgetCount(), widgetStartCount + 1, "widget has been correctly added");
+  assert.equal(widgetCount(), widgetStartCount + 1, "widget has been correctly added");
   loader.unload();
-  test.assertEqual(widgetCount(), widgetStartCount, "widget has been destroyed on module unload");
+  assert.equal(widgetCount(), widgetStartCount, "widget has been destroyed on module unload");
 
   // Test nothing
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({}),
-    "The widget must have a non-empty label property.",
+    /^The widget must have a non-empty label property\.$/,
     "throws on no properties");
 
   // Test no label
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({content: "foo"}),
-    "The widget must have a non-empty label property.",
+    /^The widget must have a non-empty label property\.$/,
     "throws on no label");
 
   // Test empty label
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({label: "", content: "foo"}),
-    "The widget must have a non-empty label property.",
+    /^The widget must have a non-empty label property\.$/,
     "throws on empty label");
 
   // Test no content or image
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({id: "fooID", label: "foo"}),
-    "No content or contentURL property found. Widgets must have one or the other.",
+    /^No content or contentURL property found\. Widgets must have one or the other\.$/,
     "throws on no content");
 
   // Test empty content, no image
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({id:"fooID", label: "foo", content: ""}),
-    "No content or contentURL property found. Widgets must have one or the other.",
+    /^No content or contentURL property found\. Widgets must have one or the other\.$/,
     "throws on empty content");
 
   // Test empty image, no content
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({id:"fooID", label: "foo", image: ""}),
-    "No content or contentURL property found. Widgets must have one or the other.",
+    /^No content or contentURL property found\. Widgets must have one or the other\.$/,
     "throws on empty content");
 
   // Test empty content, empty image
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({id:"fooID", label: "foo", content: "", image: ""}),
-    "No content or contentURL property found. Widgets must have one or the other.",
+    /^No content or contentURL property found. Widgets must have one or the other\.$/,
     "throws on empty content");
 
   // Test duplicated ID
   let duplicateID = widgets.Widget({id: "foo", label: "foo", content: "bar"});
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({id: "foo", label: "bar", content: "bar"}),
-    /This widget ID is already used:/,
+    /^This widget ID is already used: foo$/,
     "throws on duplicated id");
   duplicateID.destroy();
 
   // Test Bug 652527
-  test.assertRaises(
+  assert.throws(
     function() widgets.Widget({id: "", label: "bar", content: "bar"}),
-    /You have to specify a unique value for the id property of/,
+    /^You have to specify a unique value for the id property of your widget in order for the application to remember its position\./,
     "throws on falsey id");
 
   // Test duplicate label, different ID
   let w1 = widgets.Widget({id: "id1", label: "foo", content: "bar"});
   let w2 = widgets.Widget({id: "id2", label: "foo", content: "bar"});
   w1.destroy();
   w2.destroy();
 
   // Test position restore on create/destroy/create
   // Create 3 ordered widgets
   let w1 = widgets.Widget({id: "first", label:"first", content: "bar"});
   let w2 = widgets.Widget({id: "second", label:"second", content: "bar"});
   let w3 = widgets.Widget({id: "third", label:"third", content: "bar"});
   // Remove the middle widget
-  test.assertEqual(widgetNode(1).getAttribute("label"), "second", "second widget is the second widget inserted");
+  assert.equal(widgetNode(1).getAttribute("label"), "second", "second widget is the second widget inserted");
   w2.destroy();
-  test.assertEqual(widgetNode(1).getAttribute("label"), "third", "second widget is removed, so second widget is now the third one");
+  assert.equal(widgetNode(1).getAttribute("label"), "third", "second widget is removed, so second widget is now the third one");
   w2 = widgets.Widget({id: "second", label:"second", content: "bar"});
-  test.assertEqual(widgetNode(1).getAttribute("label"), "second", "second widget is created again, at the same location");
+  assert.equal(widgetNode(1).getAttribute("label"), "second", "second widget is created again, at the same location");
   // Cleanup this testcase
   AddonsMgrListener.onUninstalling();
   w1.destroy();
   w2.destroy();
   w3.destroy();
   AddonsMgrListener.onUninstalled();
 
   // Test concurrent widget module instances on addon-bar hiding
   if (!australis) {
     let loader = Loader(module);
     let anotherWidgetsInstance = loader.require("sdk/widget");
-    test.assert(container().collapsed, "UI is hidden when no widgets");
+    assert.ok(container().collapsed, "UI is hidden when no widgets");
     AddonsMgrListener.onInstalling();
     let w1 = widgets.Widget({id: "foo", label: "foo", content: "bar"});
     // Ideally we would let AddonsMgrListener display the addon bar
     // But, for now, addon bar is immediatly displayed by sdk code
     // https://bugzilla.mozilla.org/show_bug.cgi?id=627484
-    test.assert(!container().collapsed, "UI is already visible when we just added the widget");
+    assert.ok(!container().collapsed, "UI is already visible when we just added the widget");
     AddonsMgrListener.onInstalled();
-    test.assert(!container().collapsed, "UI become visible when we notify AddonsMgrListener about end of addon installation");
+    assert.ok(!container().collapsed, "UI become visible when we notify AddonsMgrListener about end of addon installation");
     let w2 = anotherWidgetsInstance.Widget({id: "bar", label: "bar", content: "foo"});
-    test.assert(!container().collapsed, "UI still visible when we add a second widget");
+    assert.ok(!container().collapsed, "UI still visible when we add a second widget");
     AddonsMgrListener.onUninstalling();
     w1.destroy();
     AddonsMgrListener.onUninstalled();
-    test.assert(!container().collapsed, "UI still visible when we remove one of two widgets");
+    assert.ok(!container().collapsed, "UI still visible when we remove one of two widgets");
     AddonsMgrListener.onUninstalling();
     w2.destroy();
-    test.assert(!container().collapsed, "UI is still visible when we have removed all widget but still not called onUninstalled");
+    assert.ok(!container().collapsed, "UI is still visible when we have removed all widget but still not called onUninstalled");
     AddonsMgrListener.onUninstalled();
-    test.assert(container().collapsed, "UI is hidden when we have removed all widget and called onUninstalled");
+    assert.ok(container().collapsed, "UI is hidden when we have removed all widget and called onUninstalled");
   }
   // Helper for testing a single widget.
   // Confirms proper addition and content setup.
   function testSingleWidget(widgetOptions) {
     // We have to display which test is being run, because here we do not
     // use the regular test framework but rather a custom one that iterates
     // the `tests` array.
     console.info("executing: " + widgetOptions.id);
 
     let startCount = widgetCount();
     let widget = widgets.Widget(widgetOptions);
     let node = widgetNode(startCount);
-    test.assert(node, "widget node at index");
-    test.assertEqual(node.tagName, "toolbaritem", "widget element is correct");
-    test.assertEqual(widget.width + "px", node.style.minWidth, "widget width is correct");
-    test.assertEqual(widgetCount(), startCount + 1, "container has correct number of child elements");
+    assert.ok(node, "widget node at index");
+    assert.equal(node.tagName, "toolbaritem", "widget element is correct");
+    assert.equal(widget.width + "px", node.style.minWidth, "widget width is correct");
+    assert.equal(widgetCount(), startCount + 1, "container has correct number of child elements");
     let content = node.firstElementChild;
-    test.assert(content, "found content");
-    test.assertMatches(content.tagName, /iframe|image/, "content is iframe or image");
+    assert.ok(content, "found content");
+    assert.ok(/iframe|image/.test(content.tagName), "content is iframe or image");
     return widget;
   }
 
   // Array of widgets to test
   // and a function to test them.
   let tests = [];
   function nextTest() {
-    test.assertEqual(widgetCount(), 0, "widget in last test property cleaned itself up");
+    assert.equal(widgetCount(), 0, "widget in last test property cleaned itself up");
     if (!tests.length)
-      test.done();
+      done();
     else
       timer.setTimeout(tests.shift(), 0);
   }
   function doneTest() nextTest();
 
   // text widget
   tests.push(function testTextWidget() testSingleWidget({
     id: "text",
     label: "text widget",
     content: "oh yeah",
     contentScript: "self.postMessage(document.body.innerHTML);",
     contentScriptWhen: "end",
     onMessage: function (message) {
-      test.assertEqual(this.content, message, "content matches");
+      assert.equal(this.content, message, "content matches");
       this.destroy();
       doneTest();
     }
   }));
 
   // html widget
   tests.push(function testHTMLWidget() testSingleWidget({
     id: "html",
     label: "html widget",
     content: "<div>oh yeah</div>",
     contentScript: "self.postMessage(document.body.innerHTML);",
     contentScriptWhen: "end",
     onMessage: function (message) {
-      test.assertEqual(this.content, message, "content matches");
+      assert.equal(this.content, message, "content matches");
       this.destroy();
       doneTest();
     }
   }));
 
   // image url widget
   tests.push(function testImageURLWidget() testSingleWidget({
     id: "image",
     label: "image url widget",
     contentURL: require("sdk/self").data.url("test.html"),
     contentScript: "self.postMessage({title: document.title, " +
                    "tag: document.body.firstElementChild.tagName, " +
                    "content: document.body.firstElementChild.innerHTML});",
     contentScriptWhen: "end",
     onMessage: function (message) {
-      test.assertEqual(message.title, "foo", "title matches");
-      test.assertEqual(message.tag, "P", "element matches");
-      test.assertEqual(message.content, "bar", "element content matches");
+      assert.equal(message.title, "foo", "title matches");
+      assert.equal(message.tag, "P", "element matches");
+      assert.equal(message.content, "bar", "element content matches");
       this.destroy();
       doneTest();
     }
   }));
 
   // web uri widget
   tests.push(function testWebURIWidget() testSingleWidget({
     id: "web",
     label: "web uri widget",
     contentURL: require("sdk/self").data.url("test.html"),
     contentScript: "self.postMessage({title: document.title, " +
                    "tag: document.body.firstElementChild.tagName, " +
                    "content: document.body.firstElementChild.innerHTML});",
     contentScriptWhen: "end",
     onMessage: function (message) {
-      test.assertEqual(message.title, "foo", "title matches");
-      test.assertEqual(message.tag, "P", "element matches");
-      test.assertEqual(message.content, "bar", "element content matches");
+      assert.equal(message.title, "foo", "title matches");
+      assert.equal(message.tag, "P", "element matches");
+      assert.equal(message.content, "bar", "element content matches");
       this.destroy();
       doneTest();
     }
   }));
 
   // event: onclick + content
   tests.push(function testOnclickEventContent() testSingleWidget({
     id: "click",
     label: "click test widget - content",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = new MouseEvent('click', {button: 0});" +
                    "document.getElementById('me').dispatchEvent(evt);",
     contentScriptWhen: "end",
     onClick: function() {
-      test.pass("onClick called");
+      assert.pass("onClick called");
       this.destroy();
       doneTest();
     }
   }));
 
   // event: onmouseover + content
   tests.push(function testOnmouseoverEventContent() testSingleWidget({
     id: "mouseover",
     label: "mouseover test widget - content",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = new MouseEvent('mouseover'); " +
                    "document.getElementById('me').dispatchEvent(evt);",
     contentScriptWhen: "end",
     onMouseover: function() {
-      test.pass("onMouseover called");
+      assert.pass("onMouseover called");
       this.destroy();
       doneTest();
     }
   }));
 
   // event: onmouseout + content
   tests.push(function testOnmouseoutEventContent() testSingleWidget({
     id: "mouseout",
     label: "mouseout test widget - content",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = new MouseEvent('mouseout');" +
                    "document.getElementById('me').dispatchEvent(evt);",
     contentScriptWhen: "end",
     onMouseout: function() {
-      test.pass("onMouseout called");
+      assert.pass("onMouseout called");
       this.destroy();
       doneTest();
     }
   }));
 
   // event: onclick + image
   tests.push(function testOnclickEventImage() testSingleWidget({
     id: "click",
     label: "click test widget - image",
     contentURL: require("sdk/self").data.url("moz_favicon.ico"),
     contentScript: "var evt = new MouseEvent('click'); " +
                    "document.body.firstElementChild.dispatchEvent(evt);",
     contentScriptWhen: "end",
     onClick: function() {
-      test.pass("onClick called");
+      assert.pass("onClick called");
       this.destroy();
       doneTest();
     }
   }));
 
   // event: onmouseover + image
   tests.push(function testOnmouseoverEventImage() testSingleWidget({
     id: "mouseover",
     label: "mouseover test widget - image",
     contentURL: require("sdk/self").data.url("moz_favicon.ico"),
     contentScript: "var evt = new MouseEvent('mouseover');" +
                    "document.body.firstElementChild.dispatchEvent(evt);",
     contentScriptWhen: "end",
     onMouseover: function() {
-      test.pass("onMouseover called");
+      assert.pass("onMouseover called");
       this.destroy();
       doneTest();
     }
   }));
 
   // event: onmouseout + image
   tests.push(function testOnmouseoutEventImage() testSingleWidget({
     id: "mouseout",
     label: "mouseout test widget - image",
     contentURL: require("sdk/self").data.url("moz_favicon.ico"),
     contentScript: "var evt = new MouseEvent('mouseout'); " +
                    "document.body.firstElementChild.dispatchEvent(evt);",
     contentScriptWhen: "end",
     onMouseout: function() {
-      test.pass("onMouseout called");
+      assert.pass("onMouseout called");
       this.destroy();
       doneTest();
     }
   }));
 
   // test multiple widgets
   tests.push(function testMultipleWidgets() {
     let w1 = widgets.Widget({id: "first", label: "first widget", content: "first content"});
@@ -385,17 +385,17 @@ exports.testConstructor = function(test)
     contentScript: "self.postMessage(1)",
     contentScriptWhen: "ready",
     onMessage: function(message) {
       if (!this.flag) {
         this.content = "<div id='me'>bar</div>";
         this.flag = 1;
       }
       else {
-        test.assertEqual(this.content, "<div id='me'>bar</div>");
+        assert.equal(this.content, "<div id='me'>bar</div>", 'content is as expected');
         this.destroy();
         doneTest();
       }
     }
   }));
 
   // test updating widget contentURL
   let url1 = "data:text/html;charset=utf-8,<body>foodle</body>";
@@ -404,110 +404,110 @@ exports.testConstructor = function(test)
   tests.push(function testUpdatingContentURL() testSingleWidget({
     id: "content",
     label: "content update test widget",
     contentURL: url1,
     contentScript: "self.postMessage(document.location.href);",
     contentScriptWhen: "end",
     onMessage: function(message) {
       if (!this.flag) {
-        test.assertEqual(this.contentURL.toString(), url1);
-        test.assertEqual(message, url1);
+        assert.equal(this.contentURL.toString(), url1);
+        assert.equal(message, url1);
         this.contentURL = url2;
         this.flag = 1;
       }
       else {
-        test.assertEqual(this.contentURL.toString(), url2);
-        test.assertEqual(message, url2);
+        assert.equal(this.contentURL.toString(), url2);
+        assert.equal(message, url2);
         this.destroy();
         doneTest();
       }
     }
   }));
 
   // test tooltip
   tests.push(function testTooltip() testSingleWidget({
     id: "text",
     label: "text widget",
     content: "oh yeah",
     tooltip: "foo",
     contentScript: "self.postMessage(1)",
     contentScriptWhen: "ready",
     onMessage: function(message) {
-      test.assertEqual(this.tooltip, "foo", "tooltip matches");
+      assert.equal(this.tooltip, "foo", "tooltip matches");
       this.destroy();
       doneTest();
     }
   }));
 
   // test tooltip fallback to label
   tests.push(function testTooltipFallback() testSingleWidget({
     id: "fallback",
     label: "fallback",
     content: "oh yeah",
     contentScript: "self.postMessage(1)",
     contentScriptWhen: "ready",
     onMessage: function(message) {
-      test.assertEqual(this.tooltip, this.label, "tooltip fallbacks to label");
+      assert.equal(this.tooltip, this.label, "tooltip fallbacks to label");
       this.destroy();
       doneTest();
     }
   }));
 
   // test updating widget tooltip
   let updated = false;
   tests.push(function testUpdatingTooltip() testSingleWidget({
     id: "tooltip",
     label: "tooltip update test widget",
     tooltip: "foo",
     content: "<div id='me'>foo</div>",
     contentScript: "self.postMessage(1)",
     contentScriptWhen: "ready",
     onMessage: function(message) {
       this.tooltip = "bar";
-      test.assertEqual(this.tooltip, "bar", "tooltip gets updated");
+      assert.equal(this.tooltip, "bar", "tooltip gets updated");
       this.destroy();
       doneTest();
     }
   }));
 
   // test allow attribute
   tests.push(function testDefaultAllow() testSingleWidget({
     id: "allow",
     label: "allow.script attribute",
     content: "<script>document.title = 'ok';</script>",
     contentScript: "self.postMessage(document.title)",
     onMessage: function(message) {
-      test.assertEqual(message, "ok", "scripts are evaluated by default");
+      assert.equal(message, "ok", "scripts are evaluated by default");
       this.destroy();
       doneTest();
     }
   }));
 
   tests.push(function testExplicitAllow() testSingleWidget({
     id: "allow",
     label: "allow.script attribute",
     allow: {script: true},
     content: "<script>document.title = 'ok';</script>",
     contentScript: "self.postMessage(document.title)",
     onMessage: function(message) {
-      test.assertEqual(message, "ok", "scripts are evaluated when we want to");
+      assert.equal(message, "ok", "scripts are evaluated when we want to");
       this.destroy();
       doneTest();
     }
   }));
 
   tests.push(function testExplicitDisallow() testSingleWidget({
     id: "allow",
     label: "allow.script attribute",
     content: "<script>document.title = 'ok';</script>",
     allow: {script: false},
     contentScript: "self.postMessage(document.title)",
     onMessage: function(message) {
-      test.assertNotEqual(message, "ok", "scripts aren't evaluated when " +
+      assert.notEqual(message, "ok", "scripts aren't evaluated when " +
                                          "explicitly blocked it");
       this.destroy();
       doneTest();
     }
   }));
 
   // test multiple windows
   tests.push(function testMultipleWindows() {
@@ -517,30 +517,28 @@ exports.testConstructor = function(test)
       let browserWindow = e.target.defaultView;
       let doc = browserWindow.document;
       function container() australis ? doc.getElementById("nav-bar") : doc.getElementById("addon-bar");
       function widgetCount2() container() ? container().querySelectorAll('[id^="widget\:"]').length : 0;
       let widgetStartCount2 = widgetCount2();
 
       let w1Opts = {id:"first", label: "first widget", content: "first content"};
       let w1 = testSingleWidget(w1Opts);
-      test.assertEqual(widgetCount2(), widgetStartCount2 + 1, "2nd window has correct number of child elements after first widget");
+      assert.equal(widgetCount2(), widgetStartCount2 + 1, "2nd window has correct number of child elements after first widget");
 
       let w2Opts = {id:"second", label: "second widget", content: "second content"};
       let w2 = testSingleWidget(w2Opts);
-      test.assertEqual(widgetCount2(), widgetStartCount2 + 2, "2nd window has correct number of child elements after second widget");
+      assert.equal(widgetCount2(), widgetStartCount2 + 2, "2nd window has correct number of child elements after second widget");
 
       w1.destroy();
-      test.assertEqual(widgetCount2(), widgetStartCount2 + 1, "2nd window has correct number of child elements after first destroy");
+      assert.equal(widgetCount2(), widgetStartCount2 + 1, "2nd window has correct number of child elements after first destroy");
       w2.destroy();
-      test.assertEqual(widgetCount2(), widgetStartCount2, "2nd window has correct number of child elements after second destroy");
+      assert.equal(widgetCount2(), widgetStartCount2, "2nd window has correct number of child elements after second destroy");
 
-      closeBrowserWindow(browserWindow, function() {
-        doneTest();
-      });
+      close(browserWindow).then(doneTest);
     }});
   });
 
   // test window closing
   tests.push(function testWindowClosing() {
     // 1/ Create a new widget
     let w1Opts = {
       id:"first",
@@ -549,117 +547,115 @@ exports.testConstructor = function(test)
       contentScript: "self.port.on('event', function () self.port.emit('event'))"
     };
     let widget = testSingleWidget(w1Opts);
     let windows = require("sdk/windows").browserWindows;
 
     // 2/ Retrieve a WidgetView for the initial browser window
     let acceptDetach = false;
     let mainView = widget.getView(windows.activeWindow);
-    test.assert(mainView, "Got first widget view");
+    assert.ok(mainView, "Got first widget view");
     mainView.on("detach", function () {
       // 8/ End of our test. Accept detach event only when it occurs after
       // widget.destroy()
       if (acceptDetach)
         doneTest();
       else
-        test.fail("View on initial window should not be destroyed");
+        assert.fail("View on initial window should not be destroyed");
     });
     mainView.port.on("event", function () {
       // 7/ Receive event sent during 6/ and cleanup our test
       acceptDetach = true;
       widget.destroy();
     });
 
     // 3/ First: open a new browser window
     windows.open({
       url: "about:blank",
       onOpen: function(window) {
         // 4/ Retrieve a WidgetView for this new window
         let view = widget.getView(window);
-        test.assert(view, "Got second widget view");
+        assert.ok(view, "Got second widget view");
         view.port.on("event", function () {
-          test.fail("We should not receive event on the detach view");
+          assert.fail("We should not receive event on the detach view");
         });
         view.on("detach", function () {
           // The related view is destroyed
           // 6/ Send a custom event
-          test.assertRaises(function () {
+          assert.throws(function () {
               view.port.emit("event");
             },
-            /The widget has been destroyed and can no longer be used./,
+            /^The widget has been destroyed and can no longer be used.$/,
             "emit on a destroyed view should throw");
           widget.port.emit("event");
         });
 
         // 5/ Destroy this window
         window.close();
       }
     });
   });
 
   if (!australis) {
     tests.push(function testAddonBarHide() {
       const tabBrowser = require("sdk/deprecated/tab-browser");
 
       // Hide the addon-bar
       browserWindow.setToolbarVisibility(container(), false);
-      test.assert(container().collapsed,
-                  "1st window starts with an hidden addon-bar");
+      assert.ok(container().collapsed,
+                "1st window starts with an hidden addon-bar");
 
       // Then open a browser window and verify that the addon-bar remains hidden
       tabBrowser.addTab("about:blank", { inNewWindow: true, onLoad: function(e) {
         let browserWindow2 = e.target.defaultView;
         let doc2 = browserWindow2.document;
         function container2() doc2.getElementById("addon-bar");
         function widgetCount2() container2() ? container2().childNodes.length : 0;
         let widgetStartCount2 = widgetCount2();
-        test.assert(container2().collapsed,
-                    "2nd window starts with an hidden addon-bar");
+        assert.ok(container2().collapsed,
+                  "2nd window starts with an hidden addon-bar");
 
         let w1Opts = {id:"first", label: "first widget", content: "first content"};
         let w1 = testSingleWidget(w1Opts);
-        test.assertEqual(widgetCount2(), widgetStartCount2 + 1,
-                         "2nd window has correct number of child elements after" +
-                         "widget creation");
+        assert.equal(widgetCount2(), widgetStartCount2 + 1,
+                     "2nd window has correct number of child elements after" +
+                     "widget creation");
         w1.destroy();
-        test.assertEqual(widgetCount2(), widgetStartCount2,
-                         "2nd window has correct number of child elements after" +
-                         "widget destroy");
+        assert.equal(widgetCount2(), widgetStartCount2,
+                     "2nd window has correct number of child elements after" +
+                     "widget destroy");
 
-        test.assert(container().collapsed, "1st window has an hidden addon-bar");
-        test.assert(container2().collapsed, "2nd window has an hidden addon-bar");
+        assert.ok(container().collapsed, "1st window has an hidden addon-bar");
+        assert.ok(container2().collapsed, "2nd window has an hidden addon-bar");
 
         // Reset addon-bar visibility before exiting this test
         browserWindow.setToolbarVisibility(container(), true);
 
-        closeBrowserWindow(browserWindow2, function() {
-          doneTest();
-        });
+        close(browserWindow2).then(doneTest);
       }});
     });
   }
 
   // test widget.width
   tests.push(function testWidgetWidth() testSingleWidget({
     id: "text",
     label: "test widget.width",
     content: "test width",
     width: 200,
     contentScript: "self.postMessage(1)",
     contentScriptWhen: "ready",
     onMessage: function(message) {
-      test.assertEqual(this.width, 200);
+      assert.equal(this.width, 200, 'width is 200');
 
       let node = widgetNode(0);
-      test.assertEqual(this.width, node.style.minWidth.replace("px", ""));
-      test.assertEqual(this.width, node.firstElementChild.style.width.replace("px", ""));
+      assert.equal(this.width, node.style.minWidth.replace("px", ""));
+      assert.equal(this.width, node.firstElementChild.style.width.replace("px", ""));
       this.width = 300;
-      test.assertEqual(this.width, node.style.minWidth.replace("px", ""));
-      test.assertEqual(this.width, node.firstElementChild.style.width.replace("px", ""));
+      assert.equal(this.width, node.style.minWidth.replace("px", ""));
+      assert.equal(this.width, node.firstElementChild.style.width.replace("px", ""));
 
       this.destroy();
       doneTest();
     }
   }));
 
   // test click handler not respond to right-click
   let clickCount = 0;
@@ -677,218 +673,205 @@ exports.testConstructor = function(test)
                    "evt = new MouseEvent('click', {button: 2});" +
                    "document.getElementById('me').dispatchEvent(evt); " +
                    // Mouseover
                    "evt = new MouseEvent('mouseover');" +
                    "document.getElementById('me').dispatchEvent(evt);",
     contentScriptWhen: "end",
     onClick: function() clickCount++,
     onMouseover: function() {
-      test.assertEqual(clickCount, 1, "only left click was sent to click handler");
+      assert.equal(clickCount, 1, "only left click was sent to click handler");
       this.destroy();
       doneTest();
     }
   }));
 
   // kick off test execution
   doneTest();
 };
 
-exports.testWidgetWithValidPanel = function(test) {
+exports.testWidgetWithValidPanel = function(assert, done) {
   const widgets = require("sdk/widget");
 
   let widget1 = widgets.Widget({
     id: "panel1",
     label: "panel widget 1",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = new MouseEvent('click', {button: 0});" +
                    "document.body.dispatchEvent(evt);",
     contentScriptWhen: "end",
     panel: require("sdk/panel").Panel({
       contentURL: "data:text/html;charset=utf-8,<body>Look ma, a panel!</body>",
       onShow: function() {
         let { document } = getMostRecentBrowserWindow();
         let widgetEle = document.getElementById("widget:" + jetpackID + "-" + widget1.id);
         let panelEle = document.getElementById('mainPopupSet').lastChild;
         // See bug https://bugzilla.mozilla.org/show_bug.cgi?id=859592
-        test.assertEqual(panelEle.getAttribute("type"), "arrow", 'the panel is a arrow type');
-        test.assertStrictEqual(panelEle.anchorNode, widgetEle, 'the panel is properly anchored to the widget');
+        assert.equal(panelEle.getAttribute("type"), "arrow", 'the panel is a arrow type');
+        assert.strictEqual(panelEle.anchorNode, widgetEle, 'the panel is properly anchored to the widget');
 
         widget1.destroy();
-        test.pass("panel displayed on click");
-        test.done();
+        assert.pass("panel displayed on click");
+        done();
       }
     })
   });
-  test.waitUntilDone();
 };
 
-exports.testWidgetWithInvalidPanel = function(test) {
+exports.testWidgetWithInvalidPanel = function(assert) {
   const widgets = require("sdk/widget");
-  test.assertRaises(
+  assert.throws(
     function() {
       widgets.Widget({
         id: "panel2",
         label: "panel widget 2",
         panel: {}
       });
     },
-    "The option \"panel\" must be one of the following types: null, undefined, object",
-    "widget.panel must be a Panel object"
-  );
+    /^The option \"panel\" must be one of the following types: null, undefined, object$/,
+    "widget.panel must be a Panel object");
 };
 
-exports.testPanelWidget3 = function testPanelWidget3(test) {
+exports.testPanelWidget3 = function testPanelWidget3(assert, done) {
   const widgets = require("sdk/widget");
   let onClickCalled = false;
   let widget3 = widgets.Widget({
     id: "panel3",
     label: "panel widget 3",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = new MouseEvent('click', {button: 0});" +
                    "document.body.firstElementChild.dispatchEvent(evt);",
     contentScriptWhen: "end",
     onClick: function() {
       onClickCalled = true;
       this.panel.show();
     },
     panel: require("sdk/panel").Panel({
       contentURL: "data:text/html;charset=utf-8,<body>Look ma, a panel!</body>",
       onShow: function() {
-        test.assert(
+        assert.ok(
           onClickCalled,
-          "onClick called on click for widget with both panel and onClick"
-        );
+          "onClick called on click for widget with both panel and onClick");
         widget3.destroy();
-        test.done();
+        done();
       }
     })
   });
-  test.waitUntilDone();
 };
 
-exports.testWidgetMessaging = function testWidgetMessaging(test) {
-  test.waitUntilDone();
+exports.testWidgetMessaging = function testWidgetMessaging(assert, done) {
   let origMessage = "foo";
   const widgets = require("sdk/widget");
   let widget = widgets.Widget({
     id: "foo",
     label: "foo",
     content: "<bar>baz</bar>",
     contentScriptWhen: "end",
     contentScript: "self.on('message', function(data) { self.postMessage(data); }); self.postMessage('ready');",
     onMessage: function(message) {
       if (message == "ready")
         widget.postMessage(origMessage);
       else {
-        test.assertEqual(origMessage, message);
+        assert.equal(origMessage, message);
         widget.destroy();
-        test.done();
+        done();
       }
     }
   });
 };
 
-exports.testWidgetViews = function testWidgetViews(test) {
-  test.waitUntilDone();
+exports.testWidgetViews = function testWidgetViews(assert, done) {
   const widgets = require("sdk/widget");
   let widget = widgets.Widget({
     id: "foo",
     label: "foo",
     content: "<bar>baz</bar>",
     contentScriptWhen: "ready",
     contentScript: "self.on('message', function(data) self.postMessage(data)); self.postMessage('ready')",
     onAttach: function(view) {
-      test.pass("WidgetView created");
+      assert.pass("WidgetView created");
       view.on("message", function () {
-        test.pass("Got message in WidgetView");
+        assert.pass("Got message in WidgetView");
         widget.destroy();
       });
       view.on("detach", function () {
-        test.pass("WidgetView destroyed");
-        test.done();
+        assert.pass("WidgetView destroyed");
+        done();
       });
     }
   });
-
 };
 
-exports.testWidgetViewsUIEvents = function testWidgetViewsUIEvents(test) {
-  test.waitUntilDone();
+exports.testWidgetViewsUIEvents = function testWidgetViewsUIEvents(assert, done) {
   const widgets = require("sdk/widget");
   let view = null;
   let widget = widgets.Widget({
     id: "foo",
     label: "foo",
     content: "<div id='me'>foo</div>",
     contentScript: "var evt = new MouseEvent('click', {button: 0});" +
                    "document.getElementById('me').dispatchEvent(evt);",
     contentScriptWhen: "ready",
     onAttach: function(attachView) {
       view = attachView;
-      test.pass("Got attach event");
+      assert.pass("Got attach event");
     },
     onClick: function (eventView) {
-      test.assertEqual(view, eventView,
+      assert.equal(view, eventView,
                          "event first argument is equal to the WidgetView");
       let view2 = widget.getView(require("sdk/windows").browserWindows.activeWindow);
-      test.assertEqual(view, view2,
+      assert.equal(view, view2,
                          "widget.getView return the same WidgetView");
       widget.destroy();
-      test.done();
+      done();
     }
   });
 };
 
-exports.testWidgetViewsCustomEvents = function testWidgetViewsCustomEvents(test) {
-  test.waitUntilDone();
+exports.testWidgetViewsCustomEvents = function testWidgetViewsCustomEvents(assert, done) {
   const widgets = require("sdk/widget");
   let widget = widgets.Widget({
     id: "foo",
     label: "foo",
     content: "<div id='me'>foo</div>",
     contentScript: "self.port.emit('event', 'ok');",
     contentScriptWhen: "ready",
     onAttach: function(view) {
       view.port.on("event", function (data) {
-        test.assertEqual(data, "ok",
+        assert.equal(data, "ok",
                          "event argument is valid on WidgetView");
       });
     },
   });
   widget.port.on("event", function (data) {
-    test.assertEqual(data, "ok",
-                     "event argument is valid on Widget");
+    assert.equal(data, "ok", "event argument is valid on Widget");
     widget.destroy();
-    test.done();
+    done();
   });
 };
 
-exports.testWidgetViewsTooltip = function testWidgetViewsTooltip(test) {
-  test.waitUntilDone();
+exports.testWidgetViewsTooltip = function testWidgetViewsTooltip(assert, done) {
   const widgets = require("sdk/widget");
 
   let widget = new widgets.Widget({
     id: "foo",
     label: "foo",
     content: "foo"
   });
   let view = widget.getView(require("sdk/windows").browserWindows.activeWindow);
   widget.tooltip = null;
-  test.assertEqual(view.tooltip, "foo",
-                   "view tooltip defaults to base widget label");
-  test.assertEqual(widget.tooltip, "foo",
-                   "tooltip defaults to base widget label");
+  assert.equal(view.tooltip, "foo",
+               "view tooltip defaults to base widget label");
+  assert.equal(widget.tooltip, "foo",
+               "tooltip defaults to base widget label");
   widget.destroy();
-  test.done();
+  done();
 };
 
-exports.testWidgetMove = function testWidgetMove(test) {
-  test.waitUntilDone();
-
+exports.testWidgetMove = function testWidgetMove(assert, done) {
   let windowUtils = require("sdk/deprecated/window-utils");
   let widgets = require("sdk/widget");
 
   let browserWindow = windowUtils.activeBrowserWindow;
   let doc = browserWindow.document;
 
   let label = "unique-widget-label";
   let origMessage = "message after node move";
@@ -898,137 +881,128 @@ exports.testWidgetMove = function testWi
     id: "foo",
     label: label,
     content: "<bar>baz</bar>",
     contentScriptWhen: "ready",
     contentScript: "self.on('message', function(data) { self.postMessage(data); }); self.postMessage('ready');",
     onMessage: function(message) {
       if (message == "ready") {
         if (!gotFirstReady) {
-          test.pass("Got first ready event");
+          assert.pass("Got first ready event");
           let widgetNode = doc.querySelector('toolbaritem[label="' + label + '"]');
           let parent = widgetNode.parentNode;
           parent.insertBefore(widgetNode, parent.firstChild);
           gotFirstReady = true;
-        } else {
-          test.pass("Got second ready event");
+        }
+        else {
+          assert.pass("Got second ready event");
           widget.postMessage(origMessage);
         }
       }
       else {
-        test.assertEqual(origMessage, message, "Got message after node move");
+        assert.equal(origMessage, message, "Got message after node move");
         widget.destroy();
-        test.done();
+        done();
       }
     }
   });
 };
 
 /*
 The bug is exhibited when a widget with HTML content has it's content
 changed to new HTML content with a pound in it. Because the src of HTML
 content is converted to a data URI, the underlying iframe doesn't
 consider the content change a navigation change, so doesn't load
 the new content.
 */
-exports.testWidgetWithPound = function testWidgetWithPound(test) {
-  test.waitUntilDone();
-
+exports.testWidgetWithPound = function testWidgetWithPound(assert, done) {
   function getWidgetContent(widget) {
     let windowUtils = require("sdk/deprecated/window-utils");
     let browserWindow = windowUtils.activeBrowserWindow;
     let doc = browserWindow.document;
     let widgetNode = doc.querySelector('toolbaritem[label="' + widget.label + '"]');
-    test.assert(widgetNode, 'found widget node in the front-end');
+    assert.ok(widgetNode, 'found widget node in the front-end');
     return widgetNode.firstChild.contentDocument.body.innerHTML;
   }
 
   let widgets = require("sdk/widget");
   let count = 0;
   let widget = widgets.Widget({
     id: "1",
     label: "foo",
     content: "foo",
     contentScript: "window.addEventListener('load', self.postMessage, false);",
     onMessage: function() {
       count++;
       if (count == 1) {
         widget.content = "foo#";
       }
       else {
-        test.assertEqual(getWidgetContent(widget), "foo#", "content updated to pound?");
+        assert.equal(getWidgetContent(widget), "foo#", "content updated to pound?");
         widget.destroy();
-        test.done();
+        done();
       }
     }
   });
 };
 
-exports.testContentScriptOptionsOption = function(test) {
-  test.waitUntilDone();
-
+exports.testContentScriptOptionsOption = function(assert, done) {
   let widget = require("sdk/widget").Widget({
       id: "fooz",
       label: "fooz",
       content: "fooz",
       contentScript: "self.postMessage( [typeof self.options.d, self.options] );",
       contentScriptWhen: "end",
       contentScriptOptions: {a: true, b: [1,2,3], c: "string", d: function(){ return 'test'}},
       onMessage: function(msg) {
-        test.assertEqual( msg[0], 'undefined', 'functions are stripped from contentScriptOptions' );
-        test.assertEqual( typeof msg[1], 'object', 'object as contentScriptOptions' );
-        test.assertEqual( msg[1].a, true, 'boolean in contentScriptOptions' );
-        test.assertEqual( msg[1].b.join(), '1,2,3', 'array and numbers in contentScriptOptions' );
-        test.assertEqual( msg[1].c, 'string', 'string in contentScriptOptions' );
+        assert.equal( msg[0], 'undefined', 'functions are stripped from contentScriptOptions' );
+        assert.equal( typeof msg[1], 'object', 'object as contentScriptOptions' );
+        assert.equal( msg[1].a, true, 'boolean in contentScriptOptions' );
+        assert.equal( msg[1].b.join(), '1,2,3', 'array and numbers in contentScriptOptions' );
+        assert.equal( msg[1].c, 'string', 'string in contentScriptOptions' );
         widget.destroy();
-        test.done();
+        done();
       }
     });
 };
 
-exports.testOnAttachWithoutContentScript = function(test) {
-  test.waitUntilDone();
-
+exports.testOnAttachWithoutContentScript = function(assert, done) {
   let widget = require("sdk/widget").Widget({
       id: "onAttachNoCS",
       label: "onAttachNoCS",
       content: "onAttachNoCS",
       onAttach: function (view) {
-        test.pass("received attach event");
+        assert.pass("received attach event");
         widget.destroy();
-        test.done();
+        done();
       }
     });
 };
 
-exports.testPostMessageOnAttach = function(test) {
-  test.waitUntilDone();
-
+exports.testPostMessageOnAttach = function(assert, done) {
   let widget = require("sdk/widget").Widget({
       id: "onAttach",
       label: "onAttach",
       content: "onAttach",
       // 1) Send a message immediatly after `attach` event
       onAttach: function (view) {
         view.postMessage("ok");
       },
       // 2) Listen to it and forward it back to the widget
       contentScript: "self.on('message', self.postMessage);",
       // 3) Listen to this forwarded message
       onMessage: function (msg) {
-        test.assertEqual( msg, "ok", "postMessage works on `attach` event");
+        assert.equal( msg, "ok", "postMessage works on `attach` event");
         widget.destroy();
-        test.done();
+        done();
       }
     });
 };
 
-exports.testPostMessageOnLocationChange = function(test) {
-  test.waitUntilDone();
-
+exports.testPostMessageOnLocationChange = function(assert, done) {
   let attachEventCount = 0;
   let messagesCount = 0;
   let widget = require("sdk/widget").Widget({
       id: "onLocationChange",
       label: "onLocationChange",
       content: "onLocationChange",
       contentScript: "new " + function ContentScriptScope() {
         // Emit an event when content script is applied in order to know when
@@ -1036,57 +1010,53 @@ exports.testPostMessageOnLocationChange 
         self.postMessage("ready");
         // And forward any incoming message back to the widget to see if
         // messaging is working on 2nd document
         self.on("message", self.postMessage);
       },
       onMessage: function (msg) {
         messagesCount++;
         if (messagesCount == 1) {
-          test.assertEqual(msg, "ready", "First document is loaded");
+          assert.equal(msg, "ready", "First document is loaded");
           widget.content = "location changed";
         }
         else if (messagesCount == 2) {
-          test.assertEqual(msg, "ready", "Second document is loaded");
+          assert.equal(msg, "ready", "Second document is loaded");
           widget.postMessage("ok");
         }
         else if (messagesCount == 3) {
-          test.assertEqual(msg, "ok",
-                           "We receive the message sent to the 2nd document");
+          assert.equal(msg, "ok",
+                       "We receive the message sent to the 2nd document");
           widget.destroy();
-          test.done();
+          done();
         }
       }
     });
 };
 
-exports.testSVGWidget = function(test) {
-  test.waitUntilDone();
-
+exports.testSVGWidget = function(assert, done) {
   // use of capital SVG here is intended, that was failing..
   let SVG_URL = self.data.url("mofo_logo.SVG");
 
   let widget = require("sdk/widget").Widget({
     id: "mozilla-svg-logo",
     label: "moz foundation logo",
     contentURL: SVG_URL,
     contentScript: "self.postMessage({count: window.document.images.length, src: window.document.images[0].src});",
     onMessage: function(data) {
       widget.destroy();
-      test.assertEqual(data.count, 1, 'only one image');
-      test.assertEqual(data.src, SVG_URL, 'only one image');
-      test.done();
+      assert.equal(data.count, 1, 'only one image');
+      assert.equal(data.src, SVG_URL, 'only one image');
+      done();
     }
   });
 };
 
 if (!australis) {
-  exports.testNavigationBarWidgets = function testNavigationBarWidgets(test) {
-    test.waitUntilDone();
-
+  exports.testNavigationBarWidgets = function testNavigationBarWidgets(assert, done) {
     let w1 = widgets.Widget({id: "1st", label: "1st widget", content: "1"});
     let w2 = widgets.Widget({id: "2nd", label: "2nd widget", content: "2"});
     let w3 = widgets.Widget({id: "3rd", label: "3rd widget", content: "3"});
 
     // First wait for all 3 widgets to be added to the current browser window
     let firstAttachCount = 0;
     function onAttachFirstWindow(widget) {
       if (++firstAttachCount<3)
@@ -1141,43 +1111,30 @@ if (!australis) {
       function onAttach(widget) {
         if (++attachCount < 3)
           return;
         let doc = browserWindow2.document;
         let addonBar = doc.getElementById("addon-bar");
         let searchBox = doc.getElementById("search-container");
 
         // Ensure that 1st is in addon bar
-        test.assertEqual(getWidgetNode(addonBar, 0).getAttribute("label"), w1.label);
+        assert.equal(getWidgetNode(addonBar, 0).getAttribute("label"), w1.label);
         // And that 2nd and 3rd keep their original positions in navigation bar,
         // i.e. right after search box
-        test.assertEqual(searchBox.nextSibling.getAttribute("label"), w2.label);
-        test.assertEqual(searchBox.nextSibling.nextSibling.getAttribute("label"), w3.label);
+        assert.equal(searchBox.nextSibling.getAttribute("label"), w2.label);
+        assert.equal(searchBox.nextSibling.nextSibling.getAttribute("label"), w3.label);
 
         w1.destroy();
         w2.destroy();
         w3.destroy();
 
-        closeBrowserWindow(browserWindow2, function() {
-          test.done();
-        });
+        close(browserWindow2).then(done);
       }
       w1.on("attach", onAttach);
       w2.on("attach", onAttach);
       w3.on("attach", onAttach);
 
       browserWindow2 = openBrowserWindow(browserWindow);
     }
   };
 }
 
-/******************* helpers *********************/
-
-// Helper for calling code at window close
-function closeBrowserWindow(window, callback) {
-  timer.setTimeout(function() {
-    window.addEventListener("unload", function onUnload() {
-      window.removeEventListener("unload", onUnload, false);
-      callback();
-    }, false);
-    window.close();
-  }, 0);
-}
+require("sdk/test").run(exports);
--- a/addon-sdk/source/test/test-window-events.js
+++ b/addon-sdk/source/test/test-window-events.js
@@ -16,18 +16,29 @@ const { open, getMostRecentBrowserWindow
 exports["test browser events"] = function(assert, done) {
   let loader = Loader(module);
   let { events } = loader.require("sdk/window/events");
   let { on, off } = loader.require("sdk/event/core");
   let actual = [];
 
   on(events, "data", function handler(e) {
     actual.push(e);
-    if (e.type === "load") window.close();
-    if (e.type === "close") {
+
+    if (e.type === "open") {
+      assert.pass("window open has occured");
+    }
+    else if (e.type === "DOMContentLoaded") {
+      assert.pass("window DOMContentLoaded has occured");
+    }
+    else if (e.type === "load") {
+      assert.pass("window load has occured");
+      window.close();
+    }
+    else if (e.type === "close") {
+      // confirm the ordering of events
       let [ open, ready, load, close ] = actual;
       assert.equal(open.type, "open")
       assert.equal(open.target, window, "window is open")
 
       assert.equal(ready.type, "DOMContentLoaded")
       assert.equal(ready.target, window, "window ready")
 
       assert.equal(load.type, "load")
--- a/addon-sdk/source/test/test-window-loader.js
+++ b/addon-sdk/source/test/test-window-loader.js
@@ -1,12 +1,12 @@
 /* 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';
 
 // Opening new windows in Fennec causes issues
 module.metadata = {
   engines: {
     'Firefox': '*'
   }
 };
 
@@ -26,101 +26,88 @@ const Loader = Trait.compose(
     },
     window: null,
     _onLoad: null,
     _onUnload: null,
     _tabOptions: []
   }
 );
 
-exports['test compositions with missing required properties'] = function(test) {
-  test.assertRaises(
+exports['test compositions with missing required properties'] = function(assert) {
+  assert.throws(
     function() WindowLoader.compose({})(),
-    'Missing required property: _onLoad',
+    /Missing required property: _onLoad/,
     'should throw missing required property exception'
   );
-  test.assertRaises(
+  assert.throws(
     function() WindowLoader.compose({ _onLoad: null, _tabOptions: null })(),
-    'Missing required property: _onUnload',
+    /Missing required property: _onUnload/,
     'should throw missing required property `_onUnload`'
   );
-  test.assertRaises(
+  assert.throws(
     function() WindowLoader.compose({ _onUnload: null, _tabOptions: null })(),
-    'Missing required property: _onLoad',
+    /Missing required property: _onLoad/,
     'should throw missing required property `_onLoad`'
   );
-  test.assertRaises(
+  assert.throws(
     function() WindowLoader.compose({ _onUnload: null, _onLoad: null })(),
-    'Missing required property: _tabOptions',
+    /Missing required property: _tabOptions/,
     'should throw missing required property `_tabOptions`'
   );
 };
 
-exports['test `load` events'] = function(test) {
-  test.waitUntilDone();
+exports['test `load` events'] = function(assert, done) {
   let onLoadCalled = false;
   Loader({
     onLoad: function(window) {
       onLoadCalled = true;
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
-      test.assertEqual(
+      assert.equal(window, this._window, 'windows should match');
+      assert.equal(
         window.document.readyState, 'complete', 'window must be fully loaded'
       );
       window.close();
     },
     onUnload: function(window) {
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
-      test.assertEqual(
+      assert.equal(window, this._window, 'windows should match');
+      assert.equal(
         window.document.readyState, 'complete', 'window must be fully loaded'
       );
-      test.assert(onLoadCalled, 'load callback is supposed to be called');
-      test.done();
+      assert.ok(onLoadCalled, 'load callback is supposed to be called');
+      done();
     }
   });
 };
 
-exports['test removeing listeners'] = function(test) {
-  test.waitUntilDone();
+exports['test removeing listeners'] = function(assert, done) {
   Loader({
     onLoad: function(window) {
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
+      assert.equal(window, this._window, 'windows should match');
       window.close();
     },
-    onUnload: function(window) {
-      test.done();
-    }
+    onUnload: done
   });
 };
 
-exports['test create loader from opened window'] = function(test) {
-  test.waitUntilDone();
+exports['test create loader from opened window'] = function(assert, done) {
   let onUnloadCalled = false;
   Loader({
     onLoad: function(window) {
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
-      test.assertEqual(
-        window.document.readyState, 'complete', 'window must be fully loaded'
-      );
+      assert.equal(window, this._window, 'windows should match');
+      assert.equal(window.document.readyState, 'complete', 'window must be fully loaded');
       Loader({
         window: window,
         onLoad: function(win) {
-          test.assertEqual(win, window, 'windows should match');
+          assert.equal(win, window, 'windows should match');
           window.close();
         },
         onUnload: function(window) {
-          test.assert(onUnloadCalled, 'first handler should be called already');
-          test.done();
+          assert.ok(onUnloadCalled, 'first handler should be called already');
+          done();
         }
       });
     },
     onUnload: function(window) {
       onUnloadCalled = true;
     }
   });
 };
+
+require('sdk/test').run(exports);
--- a/addon-sdk/source/test/test-window-observer.js
+++ b/addon-sdk/source/test/test-window-observer.js
@@ -53,9 +53,9 @@ exports["test unload window observer"] =
   function onClose(window) {
     // Ignore non-browser windows & already opened `activeWindow` (unload will
     // emit close on it even though it is not actually closed).
     if (isBrowser(window))
       closed++;
   }
 };
 
-require("test").run(exports);
+require("sdk/test").run(exports);
--- a/addon-sdk/source/test/windows/test-firefox-windows.js
+++ b/addon-sdk/source/test/windows/test-firefox-windows.js
@@ -11,400 +11,403 @@ const { open, close, focus } = require('
 const { browserWindows } = require("sdk/windows");
 const tabs = require("sdk/tabs");
 const winUtils = require("sdk/deprecated/window-utils");
 const { WindowTracker } = winUtils;
 const { isPrivate } = require('sdk/private-browsing');
 const { isWindowPBSupported } = require('sdk/private-browsing/utils');
 
 // TEST: open & close window
-exports.testOpenAndCloseWindow = function(test) {
-  test.waitUntilDone();
-
-  test.assertEqual(browserWindows.length, 1, "Only one window open");
+exports.testOpenAndCloseWindow = function(assert, done) {
+  assert.equal(browserWindows.length, 1, "Only one window open");
+  let title = 'testOpenAndCloseWindow';
 
   browserWindows.open({
-    url: "data:text/html;charset=utf-8,<title>windows API test</title>",
+    url: "data:text/html;charset=utf-8,<title>" + title + "</title>",
     onOpen: function(window) {
-      test.assertEqual(this, browserWindows,
-                       "The 'this' object is the windows object.");
-      test.assertEqual(window.tabs.length, 1, "Only one tab open");
-      test.assertEqual(browserWindows.length, 2, "Two windows open");
-      window.tabs.activeTab.on('ready', function onReady(tab) {
-        tab.removeListener('ready', onReady);
-        test.assert(window.title.indexOf("windows API test") != -1,
-                    "URL correctly loaded");
+      assert.equal(this, browserWindows, "The 'this' object is the windows object.");
+      assert.equal(window.tabs.length, 1, "Only one tab open");
+      assert.equal(browserWindows.length, 2, "Two windows open");
+
+      window.tabs.activeTab.once('ready', function onReady(tab) {
+        assert.pass(RegExp(title).test(window.title), "URL correctly loaded");
         window.close();
       });
     },
     onClose: function(window) {
-      test.assertEqual(window.tabs.length, 0, "Tabs were cleared");
-      test.assertEqual(browserWindows.length, 1, "Only one window open");
-      test.done();
+      assert.equal(window.tabs.length, 0, "Tabs were cleared");
+      assert.equal(browserWindows.length, 1, "Only one window open");
+      done();
     }
   });
 };
 
-exports.testAutomaticDestroy = function(test) {
-  test.waitUntilDone();
-
+exports.testAutomaticDestroy = function(assert, done) {
   let windows = browserWindows;
 
   // Create a second windows instance that we will unload
   let called = false;
   let loader = Loader(module);
   let windows2 = loader.require("sdk/windows").browserWindows;
+
   windows2.on("open", function() {
     called = true;
   });
 
   loader.unload();
 
   // Fire a windows event and check that this unloaded instance is inactive
   windows.open({
     url: "data:text/html;charset=utf-8,foo",
     onOpen: function(window) {
       setTimeout(function () {
-        test.assert(!called,
-          "Unloaded windows instance is destroyed and inactive");
-        window.close(function () {
-          test.done();
-        });
+        assert.ok(!called, "Unloaded windows instance is destroyed and inactive");
+
+        window.close(done);
       });
     }
   });
 };
 
-exports.testWindowTabsObject = function(test) {
-  test.waitUntilDone();
-
-  let count = 0;
-  let window;
+exports.testWindowTabsObject = function(assert, done) {
+  let window, count = 0;
   function runTest() {
     if (++count != 2)
       return;
 
-    test.assertEqual(window.tabs.length, 1, "Only 1 tab open");
-    test.assertEqual(window.tabs.activeTab.title, "tab 1", "Correct active tab");
+    assert.equal(window.tabs.length, 1, "Only 1 tab open");
+    assert.equal(window.tabs.activeTab.title, "tab 1", "Correct active tab");
 
     window.tabs.open({
       url: "data:text/html;charset=utf-8,<title>tab 2</title>",
       inBackground: true,
       onReady: function onReady(newTab) {
-        test.assertEqual(window.tabs.length, 2, "New tab open");
-        test.assertEqual(newTab.title, "tab 2", "Correct new tab title");
-        test.assertEqual(window.tabs.activeTab.title, "tab 1", "Correct active tab");
+        assert.equal(window.tabs.length, 2, "New tab open");
+        assert.equal(newTab.title, "tab 2", "Correct new tab title");
+        assert.equal(window.tabs.activeTab.title, "tab 1", "Correct active tab");
 
         let i = 1;
-        for each (let tab in window.tabs)
-          test.assertEqual(tab.title, "tab " + i++, "Correct title");
+        for (let tab of window.tabs)
+          assert.equal(tab.title, "tab " + i++, "Correct title");
 
         window.close();
       }
     });
   }
+
+  tabs.once("ready", runTest);
+
   browserWindows.open({
     url: "data:text/html;charset=utf-8,<title>tab 1</title>",
     onActivate: function onActivate(win) {
       window = win;
       runTest();
     },
     onClose: function onClose(window) {
-      test.assertEqual(window.tabs.length, 0, "No more tabs on closed window");
-      test.done();
+      assert.equal(window.tabs.length, 0, "No more tabs on closed window");
+      done();
     }
   });
-  tabs.once("ready", runTest);
 };
 
-exports.testOnOpenOnCloseListeners = function(test) {
-  test.waitUntilDone();
+exports.testOnOpenOnCloseListeners = function(assert, done) {
   let windows = browserWindows;
 
-  test.assertEqual(browserWindows.length, 1, "Only one window open");
+  assert.equal(browserWindows.length, 1, "Only one window open");
 
   let received = {
     listener1: false,
     listener2: false,
     listener3: false,
     listener4: false
   }
 
-   function listener1() {
-    test.assertEqual(this, windows, "The 'this' object is the windows object.");
+  function listener1() {
+    assert.equal(this, windows, "The 'this' object is the windows object.");
+
     if (received.listener1)
-      test.fail("Event received twice");
+      assert.fail("Event received twice");
     received.listener1 = true;
   }
 
   function listener2() {
     if (received.listener2)
-      test.fail("Event received twice");
+      assert.fail("Event received twice");
     received.listener2 = true;
   }
 
   function listener3() {
-    test.assertEqual(this, windows, "The 'this' object is the windows object.");
+    assert.equal(this, windows, "The 'this' object is the windows object.");
     if (received.listener3)
-      test.fail("Event received twice");
+      assert.fail("Event received twice");
     received.listener3 = true;
   }
 
   function listener4() {
     if (received.listener4)
-      test.fail("Event received twice");
+      assert.fail("Event received twice");
     received.listener4 = true;
   }
 
   windows.on('open', listener1);
   windows.on('open', listener2);
   windows.on('close', listener3);
   windows.on('close', listener4);
 
-  function verify() {
-    test.assert(received.listener1, "onOpen handler called");
-    test.assert(received.listener2, "onOpen handler called");
-    test.assert(received.listener3, "onClose handler called");
-    test.assert(received.listener4, "onClose handler called");
-
-    windows.removeListener('open', listener1);
-    windows.removeListener('open', listener2);
-    windows.removeListener('close', listener3);
-    windows.removeListener('close', listener4);
-    test.done();
-  }
-
-
   windows.open({
     url: "data:text/html;charset=utf-8,foo",
     onOpen: function(window) {
-      window.close(verify);
+      window.close(function() {
+        assert.ok(received.listener1, "onOpen handler called");
+        assert.ok(received.listener2, "onOpen handler called");
+        assert.ok(received.listener3, "onClose handler called");
+        assert.ok(received.listener4, "onClose handler called");
+
+        windows.removeListener('open', listener1);
+        windows.removeListener('open', listener2);
+        windows.removeListener('close', listener3);
+        windows.removeListener('close', listener4);
+
+        done();
+      });
     }
   });
 };
 
-/*
-Disabled due to all of the Win8 PGO bustage in bug 873007.
-exports.testActiveWindow = function(test) {
+exports.testActiveWindow = function(assert, done) {
   let windows = browserWindows;
 
   // API window objects
   let window2, window3;
 
   // Raw window objects
   let rawWindow2, rawWindow3;
 
-  test.waitUntilDone();
-
   let testSteps = [
     function() {
-      test.assertEqual(windows.length, 3, "Correct number of browser windows");
+      assert.equal(windows.length, 3, "Correct number of browser windows");
+
       let count = 0;
       for (let window in windows)
         count++;
-      test.assertEqual(count, 3, "Correct number of windows returned by iterator");
+      assert.equal(count, 3, "Correct number of windows returned by iterator");
 
-      test.assertEqual(windows.activeWindow.title, window3.title, "Correct active window - 3");
+      assert.equal(windows.activeWindow.title, window3.title, "Correct active window - 3");
 
       continueAfterFocus(rawWindow2);
       rawWindow2.focus();
     },
     function() {
-      nextStep();
-    },
-    function() {
-      test.assertEqual(windows.activeWindow.title, window2.title, "Correct active window - 2");
+      assert.equal(windows.activeWindow.title, window2.title, "Correct active window - 2");
 
       continueAfterFocus(rawWindow2);
       window2.activate();
     },
     function() {
-      test.assertEqual(windows.activeWindow.title, window2.title, "Correct active window - 2");
+      assert.equal(windows.activeWindow.title, window2.title, "Correct active window - 2");
+
       continueAfterFocus(rawWindow3);
       window3.activate();
     },
     function() {
-      test.assertEqual(windows.activeWindow.title, window3.title, "Correct active window - 3");
+      assert.equal(windows.activeWindow.title, window3.title, "Correct active window - 3");
       finishTest();
     }
   ];
 
   let newWindow = null;
   let tracker = new WindowTracker({
     onTrack: function(window) {
       newWindow = window;
     }
   });
 
   windows.open({
     url: "data:text/html;charset=utf-8,<title>window 2</title>",
     onOpen: function(window) {
+      assert.pass('window 2 open');
+
       window.tabs.activeTab.on('ready', function() {
+        assert.pass('window 2 tab activated');
+
         window2 = window;
-        test.assert(newWindow, "A new window was opened");
+        assert.ok(newWindow, "A new window was opened");
         rawWindow2 = newWindow;
         newWindow = null;
-        test.assertEqual(rawWindow2.content.document.title, "window 2", "Got correct raw window 2");
-        test.assertEqual(rawWindow2.document.title, window2.title, "Saw correct title on window 2");
+
+        assert.equal(rawWindow2.content.document.title, "window 2", "Got correct raw window 2");
+        assert.equal(rawWindow2.document.title, window2.title, "Saw correct title on window 2");
 
         windows.open({
           url: "data:text/html;charset=utf-8,<title>window 3</title>",
           onOpen: function(window) {
+            assert.pass('window 3 open');
+
             window.tabs.activeTab.on('ready', function onReady() {
+              assert.pass('window 3 tab activated');
+
               window3 = window;
-              test.assert(newWindow, "A new window was opened");
+              assert.ok(newWindow, "A new window was opened");
               rawWindow3 = newWindow;
               tracker.unload();
-              test.assertEqual(rawWindow3.content.document.title, "window 3", "Got correct raw window 3");
-              test.assertEqual(rawWindow3.document.title, window3.title, "Saw correct title on window 3");
+
+              assert.equal(rawWindow3.content.document.title, "window 3", "Got correct raw window 3");
+              assert.equal(rawWindow3.document.title, window3.title, "Saw correct title on window 3");
+
               continueAfterFocus(rawWindow3);
               rawWindow3.focus();
             });
           }
         });
       });
     }
   });
 
   function nextStep() {
-    if (testSteps.length)
-      testSteps.shift()();
+    if (testSteps.length) {
+      setTimeout(testSteps.shift())
+    }
   }
 
   let continueAfterFocus = function(w) onFocus(w).then(nextStep);
 
   function finishTest() {
-    window3.close(function() {
-      window2.close(function() {
-        test.done();
+    // close unactive window first to avoid unnecessary focus changing
+    window2.close(function() {
+      window3.close(function() {
+        assert.equal(rawWindow2.closed, true, 'window 2 is closed');
+        assert.equal(rawWindow3.closed, true, 'window 3 is closed');
+
+        done();
       });
     });
   }
 };
-*/
 
-exports.testTrackWindows = function(test) {
-  test.waitUntilDone();
-
+exports.testTrackWindows = function(assert, done) {
   let windows = [];
   let actions = [];
 
   let expects = [
     "activate 0", "global activate 0", "deactivate 0", "global deactivate 0",
     "activate 1", "global activate 1", "deactivate 1", "global deactivate 1",
     "activate 2", "global activate 2"
   ];
 
+  function windowsActivation(window) {
+    let index = windows.indexOf(window);
+    // only concerned with windows opened for this test
+    if (index < 0)
+      return;
+
+    assert.equal(actions.join(), expects.slice(0, index*4 + 1).join(), expects[index*4 + 1]);
+    actions.push("global activate " + index)
+  }
+
+  function windowsDeactivation(window) {
+    let index = windows.indexOf(window);
+    // only concerned with windows opened for this test
+    if (index < 0)
+      return;
+
+    assert.equal(actions.join(), expects.slice(0, index*4 + 3).join(), expects[index*4 + 3]);
+    actions.push("global deactivate " + index)
+  }
+
+  // listen to global activate events
+  browserWindows.on("activate", windowsActivation);
+
+  // listen to global deactivate events
+  browserWindows.on("deactivate", windowsDeactivation);
+
+
   function openWindow() {
     windows.push(browserWindows.open({
       url: "data:text/html;charset=utf-8,<i>testTrackWindows</i>",
-
       onActivate: function(window) {
         let index = windows.indexOf(window);
 
-        test.assertEqual(actions.join(), expects.slice(0, index*4).join(), expects[index*4]);
+        assert.equal(actions.join(),
+                     expects.slice(0, index*4).join(),
+                     "expecting " + expects[index*4]);
         actions.push("activate " + index);
 
         if (windows.length < 3) {
           openWindow()
         }
         else {
           (function closeWindows(windows) {
-            if (!windows.length)
-              return test.done();
+            if (!windows.length) {
+              browserWindows.removeListener("activate", windowsActivation);
+              browserWindows.removeListener("deactivate", windowsDeactivation);
+              return done();
+            }
 
             return windows.pop().close(function() {
-              test.pass('window was closed');
+              assert.pass('window was closed');
               closeWindows(windows);
             });
           })(windows)
         }
       },
-
       onDeactivate: function(window) {
         let index = windows.indexOf(window);
 
-        test.assertEqual(actions.join(), expects.slice(0, index*4 + 2).join(), expects[index*4 + 2]);
+        assert.equal(actions.join(),
+                     expects.slice(0, index*4 + 2).join(),
+                     "expecting " + expects[index*4 + 2]);
         actions.push("deactivate " + index)
       }
     }));
   }
-
-  browserWindows.on("activate", function (window) {
-    let index = windows.indexOf(window);
-    // only concerned with windows opened for this test
-    if (index < 0)
-      return;
-
-    test.assertEqual(actions.join(), expects.slice(0, index*4 + 1).join(), expects[index*4 + 1]);
-    actions.push("global activate " + index)
-  })
-
-  browserWindows.on("deactivate", function (window) {
-    let index = windows.indexOf(window);
-    // only concerned with windows opened for this test
-    if (index < 0)
-      return;
-
-    test.assertEqual(actions.join(), expects.slice(0, index*4 + 3).join(), expects[index*4 + 3]);
-    actions.push("global deactivate " + index)
-  })
-
   openWindow();
 }
 
 // test that it is not possible to open a private window by default
-exports.testWindowOpenPrivateDefault = function(test) {
-  test.waitUntilDone();
-
+exports.testWindowOpenPrivateDefault = function(assert, done) {
   browserWindows.open({
     url: 'about:mozilla',
     isPrivate: true,
     onOpen: function(window) {
       let tab = window.tabs[0];
+
       tab.once('ready', function() {
-        test.assertEqual(tab.url, 'about:mozilla', 'opened correct tab');
-        test.assertEqual(isPrivate(tab), false, 'tab is not private');
+        assert.equal(tab.url, 'about:mozilla', 'opened correct tab');
+        assert.equal(isPrivate(tab), false, 'tab is not private');
 
-        window.close(test.done.bind(test));
+        window.close(done);
       });
     }
   });
 }
 
 // test that it is not possible to find a private window in
 // windows module's iterator
-exports.testWindowIteratorPrivateDefault = function(test) {
-  test.waitUntilDone();
-
-  test.assertEqual(browserWindows.length, 1, 'only one window open');
+exports.testWindowIteratorPrivateDefault = function(assert, done) {
+  assert.equal(browserWindows.length, 1, 'only one window open');
 
   open('chrome://browser/content/browser.xul', {
     features: {
       private: true,
       chrome: true
     }
-  }).then(function(window) focus(window).then(function() {
+  }).then(focus).then(function(window) {
     // test that there is a private window opened
-    test.assertEqual(isPrivate(window), isWindowPBSupported, 'there is a private window open');
-    test.assertStrictEqual(window, winUtils.activeWindow);
-    test.assertStrictEqual(window, getMostRecentWindow());
+    assert.equal(isPrivate(window), isWindowPBSupported, 'there is a private window open');
+    assert.strictEqual(window, winUtils.activeWindow);
+    assert.strictEqual(window, getMostRecentWindow());
 
-    test.assert(!isPrivate(browserWindows.activeWindow));
+    assert.ok(!isPrivate(browserWindows.activeWindow));
+
+    assert.equal(browserWindows.length, 1, 'only one window in browserWindows');
+    assert.equal(windows().length, 1, 'only one window in windows()');
 
-    if (isWindowPBSupported) {
-      test.assertEqual(browserWindows.length, 1, 'only one window in browserWindows');
-      test.assertEqual(windows().length, 1, 'only one window in windows()');
-    }
-    else {
-      test.assertEqual(browserWindows.length, 2, 'two windows open');
-      test.assertEqual(windows().length, 2, 'two windows in windows()');
-    }
-    test.assertEqual(windows(null, { includePrivate: true }).length, 2);
+    assert.equal(windows(null, { includePrivate: true }).length, 2);
+
+    // test that all windows in iterator are not private
+    for (let window of browserWindows)
+      assert.ok(!isPrivate(window), 'no window in browserWindows is private');
 
-    for each(let window in browserWindows) {
-      // test that all windows in iterator are not private
-      test.assert(!isPrivate(window), 'no window in browserWindows is private');
-    }
+    close(window).then(done);
+  });
+}
 
-    close(window).then(test.done.bind(test));
-  }));
-}
+require('sdk/test').run(exports);