Index: chrome/content/index.html |
=================================================================== |
--- a/chrome/content/index.html |
+++ b/chrome/content/index.html |
@@ -6,55 +6,51 @@ |
<script src="qunit.js"></script> |
<script src="common.js" type="text/javascript;version=1.7"></script> |
<script src="httpd.js" type="text/javascript;version=1.7"></script> |
<script type="text/javascript;version=1.7"> |
Cu.import("resource://gre/modules/Services.jsm"); |
function getTestFiles() |
{ |
- let module = {}; |
- module.wrappedJSObject = module; |
- Services.obs.notifyObservers(module, "adblockplustests-require", "info"); |
+ function require(module) |
+ { |
+ let result = {}; |
+ result.wrappedJSObject = result; |
+ Services.obs.notifyObservers(result, "adblockplustests-require", module); |
+ return result.exports; |
+ } |
- let {addonRoot} = module.exports; |
- let uri = Services.io.newURI(addonRoot, null, null).QueryInterface(Components.interfaces.nsIJARURI); |
- |
- let result = []; |
+ let result; |
if ("test" in QUnit.urlParams) |
- result.push("tests/" + QUnit.urlParams.test + ".js"); |
+ result = ["tests/" + QUnit.urlParams.test + ".js"]; |
else |
{ |
- let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance(Ci.nsIZipReader); |
- zipReader.open(uri.JARFile.QueryInterface(Ci.nsIFileURL).file); |
- |
- let enumerator = zipReader.findEntries(null); |
- let prefix = "chrome/content/tests/"; |
- while (enumerator.hasMore()) |
- { |
- let name = enumerator.getNext(); |
- if (name.indexOf(prefix) == 0 && /\.js$/.test(name)) |
- result.push("tests/" + name.replace(prefix, "")); |
- } |
- |
- zipReader.close(); |
+ let {getTests} = require("main"); |
+ result = ["tests/" + test + ".js" for (test of getTests())]; |
} |
result.sort(); |
return result; |
} |
let files = getTestFiles(); |
for (let file of files) |
{ |
let script = document.createElement("script"); |
script.setAttribute("src", file); |
script.setAttribute("type", "text/javascript;version=1.7"); |
document.documentElement.appendChild(script); |
} |
+ |
+ window.addEventListener("unload", function() |
+ { |
+ if (QUnit.config.current) |
+ QUnit.config.current.testEnvironment.teardown(); |
+ }, false); |
</script> |
</head> |
<body> |
<h1 id="qunit-header">Adblock Plus unit tests</h1> |
<h2 id="qunit-banner"></h2> |
<div id="qunit-testrunner-toolbar"></div> |
<h2 id="qunit-userAgent"></h2> |
<ol id="qunit-tests"></ol> |