Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/content/index.html

Issue 5745141503492096: Issue 1561 - Move unit tests out of the browser`s content area (Closed)
Patch Set: Created Nov. 14, 2014, 11:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <link rel="stylesheet" href="qunit.css"/> 4 <link rel="stylesheet" href="qunit.css"/>
5 <script src="jquery-1.7.1.min.js"></script> 5 <script src="jquery-1.7.1.min.js"></script>
6 <script src="qunit.js"></script> 6 <script src="qunit.js"></script>
7 <script src="common.js" type="text/javascript;version=1.7"></script> 7 <script src="common.js" type="text/javascript;version=1.7"></script>
8 <script src="httpd.js" type="text/javascript;version=1.7"></script> 8 <script src="httpd.js" type="text/javascript;version=1.7"></script>
9 <script type="text/javascript;version=1.7"> 9 <script type="text/javascript;version=1.7">
10 Cu.import("resource://gre/modules/Services.jsm"); 10 Cu.import("resource://gre/modules/Services.jsm");
11 11
12 function getTestFiles() 12 function getTestFiles()
13 { 13 {
14 let module = {}; 14 function require(module)
15 module.wrappedJSObject = module; 15 {
16 Services.obs.notifyObservers(module, "adblockplustests-require", "info") ; 16 let result = {};
17 result.wrappedJSObject = result;
18 Services.obs.notifyObservers(result, "adblockplustests-require", modul e);
19 return result.exports;
20 }
17 21
18 let {addonRoot} = module.exports; 22 let result;
19 let uri = Services.io.newURI(addonRoot, null, null).QueryInterface(Compo nents.interfaces.nsIJARURI);
20
21 let result = [];
22 if ("test" in QUnit.urlParams) 23 if ("test" in QUnit.urlParams)
23 result.push("tests/" + QUnit.urlParams.test + ".js"); 24 result = ["tests/" + QUnit.urlParams.test + ".js"];
24 else 25 else
25 { 26 {
26 let zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance( Ci.nsIZipReader); 27 let {getTests} = require("main");
27 zipReader.open(uri.JARFile.QueryInterface(Ci.nsIFileURL).file); 28 result = ["tests/" + test + ".js" for (test of getTests())];
28
29 let enumerator = zipReader.findEntries(null);
30 let prefix = "chrome/content/tests/";
31 while (enumerator.hasMore())
32 {
33 let name = enumerator.getNext();
34 if (name.indexOf(prefix) == 0 && /\.js$/.test(name))
35 result.push("tests/" + name.replace(prefix, ""));
36 }
37
38 zipReader.close();
39 } 29 }
40 30
41 result.sort(); 31 result.sort();
42 return result; 32 return result;
43 } 33 }
44 34
45 let files = getTestFiles(); 35 let files = getTestFiles();
46 for (let file of files) 36 for (let file of files)
47 { 37 {
48 let script = document.createElement("script"); 38 let script = document.createElement("script");
49 script.setAttribute("src", file); 39 script.setAttribute("src", file);
50 script.setAttribute("type", "text/javascript;version=1.7"); 40 script.setAttribute("type", "text/javascript;version=1.7");
51 document.documentElement.appendChild(script); 41 document.documentElement.appendChild(script);
52 } 42 }
43
44 window.addEventListener("unload", function()
45 {
46 if (QUnit.config.current)
47 QUnit.config.current.testEnvironment.teardown();
48 }, false);
53 </script> 49 </script>
54 </head> 50 </head>
55 <body> 51 <body>
56 <h1 id="qunit-header">Adblock Plus unit tests</h1> 52 <h1 id="qunit-header">Adblock Plus unit tests</h1>
57 <h2 id="qunit-banner"></h2> 53 <h2 id="qunit-banner"></h2>
58 <div id="qunit-testrunner-toolbar"></div> 54 <div id="qunit-testrunner-toolbar"></div>
59 <h2 id="qunit-userAgent"></h2> 55 <h2 id="qunit-userAgent"></h2>
60 <ol id="qunit-tests"></ol> 56 <ol id="qunit-tests"></ol>
61 </body> 57 </body>
62 </html> 58 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld