I am just getting started with crosscheck and I got some basic tests
to run, but what I got stuck with is how to set up a DOM to test on.
Ideally, I would like to have crosscheck load a html page from a file
or a url - is that possible? The test scripts I saw create DOM
elements to test on using DOM methods.
Ingo
Ex.
var elem = crosscheck.Host.parse("<strong>some html</strong>");
document.body.appendChild(elem);
You could also use innerHTML, but that will be subject to the same
quirks as using innerHTML in a browser.
Also, it should be possible to use Java classes to load a string from
a file or a URL, which you can then pass to the Host.parse function.
Ex.
var io = Packages.java.io;
try {
var file = new io.File("snippet.html");
var reader = new io.BufferedReader(new io.FileReader(file));
var text = "";
var line = "";
while( (line = reader.readLine()) != null ) { text += line; }
} finally {
if (reader) reader.close();
}
var elem = crosscheck.Host.parse(text);
document.body.appendChild(elem);
But, in any of these cases, remember that Crosscheck will not execute
any of the javascript in the text that you parse. You still need to
use crosscheck.load() to initialize your javascript library.