Bug 720985 - Report a failure when a test leaks a global variable. r=gavin

This commit is contained in:
Dão Gottwald 2012-02-03 10:10:52 +01:00
Родитель 52352be580
Коммит c8a073a2a2
1 изменённых файлов: 12 добавлений и 1 удалений

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

@ -88,11 +88,14 @@ Tester.prototype = {
start: function Tester_start() {
//if testOnLoad was not called, then gConfig is not defined
if(!gConfig)
if (!gConfig)
gConfig = readConfig();
this.repeat = gConfig.repeat;
this.dumper.dump("*** Start BrowserChrome Test Results ***\n");
this._cs.registerListener(this);
this._globalProperties = Object.keys(window);
this._globalPropertyWhitelist = ["navigator", "constructor", "Application",
"__SS_tabsToRestore", "webConsoleCommandController"];
if (this.tests.length)
this.nextTest();
@ -214,6 +217,14 @@ Tester.prototype = {
this.currentTest.addResult(new testResult(false, "expectUncaughtException was called but no uncaught exception was detected!", "", false));
}
Object.keys(window).forEach(function (prop) {
if (this._globalProperties.indexOf(prop) == -1) {
this._globalProperties.push(prop);
if (this._globalPropertyWhitelist.indexOf(prop) == -1)
this.currentTest.addResult(new testResult(false, "leaked window property: " + prop, "", false));
}
}, this);
// Clear document.popupNode. The test could have set it to a custom value
// for its own purposes, nulling it out it will go back to the default
// behavior of returning the last opened popup.