2012-04-03 03:52:35 +04:00
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public License,
|
|
|
|
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
|
* obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file defines the commonly-used functionality needed by a stone ridge
|
|
|
|
* test suite. This must be run under xpcshell running in JS v1.8 mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var OUT_FILE = null;
|
|
|
|
|
|
|
|
var Cc = Components.classes;
|
|
|
|
var Ci = Components.interfaces;
|
|
|
|
var Cr = Components.results;
|
|
|
|
|
2012-04-04 00:30:58 +04:00
|
|
|
var STONERIDGE_FINISHED = false;
|
|
|
|
|
2012-04-03 03:52:35 +04:00
|
|
|
/*
|
|
|
|
* Write some JSON object to the file named in OUT_FILE.
|
|
|
|
*/
|
|
|
|
function writeTestLog(json_obj) {
|
|
|
|
var ofile = Cc["@mozilla.org/file/directory_service;1"].
|
|
|
|
getService(Ci.nsIProperties).
|
2012-04-04 00:30:58 +04:00
|
|
|
get("TmpD", Ci.nsILocalFile);
|
2012-04-03 03:52:35 +04:00
|
|
|
|
|
|
|
// And use the file determined by our caller
|
|
|
|
ofile.append(OUT_FILE);
|
|
|
|
|
|
|
|
// Now get an output stream for our file
|
|
|
|
var ostream = Cc["@mozilla.org/network/file-output-stream;1"].
|
|
|
|
createInstance(Ci.nsIFileOutputStream);
|
|
|
|
ostream.init(ofile, -1, -1, 0);
|
|
|
|
|
|
|
|
var jstring = JSON.stringify(json_obj);
|
|
|
|
ostream.write(jstring, jstring.length);
|
|
|
|
ostream.close();
|
2012-04-04 00:30:58 +04:00
|
|
|
|
|
|
|
STONERIDGE_FINISHED = true;
|
2012-04-03 03:52:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The main entry point for all stone ridge tests
|
|
|
|
*/
|
|
|
|
function stoneRidge(output_filename) {
|
|
|
|
OUT_FILE = output_filename;
|
2012-04-04 00:30:58 +04:00
|
|
|
STONERIDGE_FINISHED = false;
|
2012-04-03 03:52:35 +04:00
|
|
|
run_test();
|
2012-04-04 00:30:58 +04:00
|
|
|
|
|
|
|
// Pump the event loop until we're told to stop
|
|
|
|
var thread = Cc["@mozilla.org/thread-manager;1"].
|
|
|
|
getService().currentThread;
|
|
|
|
while (!STONERIDGE_FINISHED)
|
|
|
|
thread.processNextEvent(true);
|
|
|
|
while (thread.hasPendingEvents())
|
|
|
|
thread.processNextEvent(true);
|
2012-04-03 03:52:35 +04:00
|
|
|
}
|