Bug 995266 - Prevent mochitest-browser harness from leaking due to SimpleTest overrides. r=ted

CLOSED TREE
This commit is contained in:
Tim Taubert 2014-04-11 17:57:59 +02:00
Родитель d76581cee3
Коммит 617920f1c0
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -20,6 +20,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "BrowserNewTabPreloader",
XPCOMUtils.defineLazyModuleGetter(this, "CustomizationTabPreloader",
"resource:///modules/CustomizationTabPreloader.jsm", "CustomizationTabPreloader");
const SIMPLETEST_OVERRIDES =
["ok", "is", "isnot", "ise", "todo", "todo_is", "todo_isnot", "info", "expectAssertions"];
window.addEventListener("load", testOnLoad, false);
function testOnLoad() {
@ -88,6 +91,11 @@ function Tester(aTests, aDumper, aCallback) {
this.Task = Components.utils.import("resource://gre/modules/Task.jsm", null).Task;
this.Promise = Components.utils.import("resource://gre/modules/Promise.jsm", null).Promise;
this.Assert = Components.utils.import("resource://testing-common/Assert.jsm", null).Assert;
this.SimpleTestOriginal = {};
SIMPLETEST_OVERRIDES.forEach(m => {
this.SimpleTestOriginal[m] = this.SimpleTest[m];
});
}
Tester.prototype = {
EventUtils: {},
@ -388,6 +396,11 @@ Tester.prototype = {
this.haltTests();
}
// Restore original SimpleTest methods to avoid leaks.
SIMPLETEST_OVERRIDES.forEach(m => {
this.SimpleTest[m] = this.SimpleTestOriginal[m];
});
testScope.destroy();
this.currentTest.scope = null;
}
@ -525,7 +538,7 @@ Tester.prototype = {
};
// Override SimpleTest methods with ours.
["ok", "is", "isnot", "ise", "todo", "todo_is", "todo_isnot", "info", "expectAssertions"].forEach(function(m) {
SIMPLETEST_OVERRIDES.forEach(function(m) {
this.SimpleTest[m] = this[m];
}, this.currentTest.scope);