Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1329 from Gozala/bug/test-runner@787390
Browse files Browse the repository at this point in the history
Bug 787390 - Stop creating loaders than are never unloaded. r=@jsantell
  • Loading branch information
Gozala committed Dec 19, 2013
2 parents 7eee510 + 60c2d7f commit 0cc808f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/sdk/deprecated/unit-test-finder.js
Expand Up @@ -14,6 +14,7 @@ const suites = require('@test/options').allTestModules;
const { Loader } = require("sdk/test/loader");
const cuddlefish = require("sdk/loader/cuddlefish");

let loader = Loader(module);
const NOT_TESTS = ['setup', 'teardown'];

var TestFinder = exports.TestFinder = function TestFinder(options) {
Expand Down Expand Up @@ -51,11 +52,10 @@ TestFinder.prototype = {
} else
filter = function() {return true};

suites.forEach(
function(suite) {
suites.forEach(function(suite) {
// Load each test file as a main module in its own loader instance
// `suite` is defined by cuddlefish/manifest.py:ManifestBuilder.build
let loader = Loader(module);

let suiteModule;

try {
Expand Down
11 changes: 7 additions & 4 deletions test/test-tab.js
Expand Up @@ -9,6 +9,7 @@ const { getTabForWindow } = require('sdk/tabs/helpers');
const app = require("sdk/system/xul-app");
const { viewFor } = require("sdk/view/core");
const { getTabId } = require("sdk/tabs/utils");
const { defer } = require("sdk/lang/functional");

// The primary test tab
var primaryTab;
Expand Down Expand Up @@ -139,14 +140,16 @@ exports["test behavior on close"] = function(assert, done) {
};

exports["test viewFor(tab)"] = (assert, done) => {
tabs.once("open", tab => {
// Note we defer handlers as length collection is updated after
// handler is invoked, so if test is finished before counnts are
// updated wrong length will show up in followup tests.
tabs.once("open", defer(tab => {
const view = viewFor(tab);
assert.ok(view, "view is returned");
assert.equal(getTabId(view), tab.id, "tab has a same id");

tab.close();
done();
});
tab.close(defer(done));
}));

tabs.open({ url: "about:mozilla" });
}
Expand Down
12 changes: 9 additions & 3 deletions test/test-windows-common.js
Expand Up @@ -8,6 +8,8 @@ const { browserWindows } = require('sdk/windows');
const { viewFor } = require('sdk/view/core');
const { Ci } = require("chrome");
const { isBrowser, getWindowTitle } = require("sdk/window/utils");
const { defer } = require("sdk/lang/functional");


// TEST: browserWindows Iterator
exports.testBrowserWindowsIterator = function(assert) {
Expand All @@ -30,6 +32,7 @@ exports.testBrowserWindowsIterator = function(assert) {
}
};


exports.testWindowTabsObject_alt = function(assert, done) {
let window = browserWindows.activeWindow;
window.tabs.open({
Expand Down Expand Up @@ -58,6 +61,7 @@ exports.testWindowActivateMethod_simple = function(assert) {
'Active tab is active after window.activate() call');
};


exports["test getView(window)"] = function(assert, done) {
browserWindows.once("open", window => {
const view = viewFor(window);
Expand All @@ -68,9 +72,11 @@ exports["test getView(window)"] = function(assert, done) {
"window has a right title");

window.close();
window.destroy();
assert.equal(viewFor(window), null, "window view is gone");
done();
// Defer handler cause window is destroyed after event is dispatched.
browserWindows.once("close", defer(_ => {
assert.equal(viewFor(window), null, "window view is gone");
done();
}));
});


Expand Down

0 comments on commit 0cc808f

Please sign in to comment.