Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | load( "build/js/writeFile.js", "build/js/parse.js" ); |
michael@0 | 2 | |
michael@0 | 3 | function addParams(name, params) { |
michael@0 | 4 | if(params.length > 0) { |
michael@0 | 5 | name += "("; |
michael@0 | 6 | for ( var i = 0; i < params.length; i++) { |
michael@0 | 7 | name += params[i].type + ", "; |
michael@0 | 8 | } |
michael@0 | 9 | return name.substring(0, name.length - 2) + ")"; |
michael@0 | 10 | } else { |
michael@0 | 11 | return name + "()"; |
michael@0 | 12 | } |
michael@0 | 13 | } |
michael@0 | 14 | function addTestWrapper(name, test) { |
michael@0 | 15 | return 'test("' + name + '", function() {\n' + test + '\n});'; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | var dir = arguments[1]; |
michael@0 | 19 | var jq = parse( read(arguments[0]) ); |
michael@0 | 20 | |
michael@0 | 21 | var testFile = []; |
michael@0 | 22 | |
michael@0 | 23 | String.prototype.decode = function() { |
michael@0 | 24 | return this.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | for ( var i = 0; i < jq.length; i++ ) { |
michael@0 | 28 | if ( jq[i].tests.length > 0 ) { |
michael@0 | 29 | var method = jq[i]; |
michael@0 | 30 | var name = addParams(method.name, method.params); |
michael@0 | 31 | for(var j = 0; j < method.tests.length; j++) { |
michael@0 | 32 | if(j > 0) { |
michael@0 | 33 | name += "x"; |
michael@0 | 34 | } |
michael@0 | 35 | testFile[testFile.length] = addTestWrapper(name, method.tests[j].decode()) + "\n"; |
michael@0 | 36 | } |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | var indexFile = readFile( "build/test/index.html" ); |
michael@0 | 41 | writeFile( dir + "/index.html", indexFile.replace( /{TESTS}/g, testFile.join("\n") ) ); |