525 lines
13 KiB
HTML
525 lines
13 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>Debug Plug-in Test</TITLE>
|
|
</HEAD>
|
|
|
|
|
|
|
|
<BODY>
|
|
|
|
<center>
|
|
<h2> Example XPConnect Scriptable Debug Plug-in Regression Page</h2>
|
|
</center>
|
|
|
|
<embed type="application/debug-plugin" width=1 height=1 hidden="true"><br>
|
|
|
|
<script>
|
|
var embed = document.embeds[0];
|
|
var started = false;
|
|
var theWindow;
|
|
var fileDirectory;
|
|
var baseExt;
|
|
var verExt;
|
|
var baseDir;
|
|
var verDir;
|
|
var testType;
|
|
var changed = false;
|
|
var lb,mb,pb,sb,stb,tb;
|
|
var origLeft;
|
|
var origTop;
|
|
var origWidth;
|
|
var origHeight;
|
|
var dirType;
|
|
var curIndex;
|
|
var dumpStyle;
|
|
|
|
|
|
var myArray = new Array(9);
|
|
myArray[0] = "file:///S|/mozilla/layout/html/tests/table/dom";
|
|
myArray[1] = "s:/regressiontests/";
|
|
myArray[2] = "s:/regressiontests/";
|
|
|
|
myArray[3] = "file:///S|/mozilla/layout/html/tests/table/core";
|
|
myArray[4] = "s:/regressiontests/";
|
|
myArray[5] = "s:/regressiontests/";
|
|
|
|
myArray[6] = "file:///S|/mozilla/layout/html/tests/table/images";
|
|
myArray[7] = "s:/regressiontests/";
|
|
myArray[8] = "s:/regressiontests/";
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
function CompareFiles(aBaseDir,aVerDir,aBaselineFile,aVerFile)
|
|
{
|
|
err = embed.CompareLayoutFiles(aBaseDir,aVerDir,aBaselineFile,aVerFile,1);
|
|
|
|
if(err == 0) {
|
|
WriteOutput("File \" "+aVerFile + "\" PASSED",false,"success",true,true );
|
|
} else {
|
|
WriteOutput("File \" "+aVerFile + "\" FAILED ",false,"failure",true,true );
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function ClearOutput()
|
|
{
|
|
textarea = document.getElementById('output');
|
|
textarea.innerHTML = "";
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function WriteOutput( aText, aReplace, aTextColor,aToStatus, aToOutPut )
|
|
{
|
|
|
|
textarea = document.getElementById('output');
|
|
statusarea = document.getElementById('status');
|
|
|
|
thecolor = "<font color=black>";
|
|
if(aTextColor == "failure")
|
|
thecolor = "<font color=red>";
|
|
if(aTextColor == "success")
|
|
thecolor = "<font color=green>";
|
|
|
|
if ( aToStatus ) {
|
|
statusarea.innerHTML = thecolor + aText +"</font>";
|
|
}
|
|
|
|
if (aToOutPut) {
|
|
if( aReplace ) {
|
|
textarea.innerHTML = thecolor + aText +"</font>";
|
|
} else {
|
|
textarea.innerHTML = thecolor + textarea.innerHTML + "<br>" + aText +"</font>";
|
|
}
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function RestoreWindow()
|
|
{
|
|
|
|
if (changed) {
|
|
window.moveTo(origLeft,origTop);
|
|
window.resizeTo(origWidth,origHeight);
|
|
window.locationbar.visible = lb;
|
|
window.menubar.visible = mb;
|
|
window.personalbar.visible = pb;
|
|
window.scrollbars.visible = sb;
|
|
window.statusbar.visible = stb;
|
|
window.toolbar.visible = tb;
|
|
outputWindow.moveTo(origLeft,origTop);
|
|
outputWindow.resizeTo(origWidth,origHeight);
|
|
|
|
changed = false;
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function placeWindows(aOutputWindow,aTestWindow)
|
|
{
|
|
// save old values, get rid of chrome and move and resize the windows
|
|
if ( changed == false ) {
|
|
lb = aOutputWindow.locationbar.visible;
|
|
mb = aOutputWindow.menubar.visible;
|
|
pb = aOutputWindow.personalbar.visible;
|
|
sb = aOutputWindow.scrollbars.visible;
|
|
stb = aOutputWindow.statusbar.visible;
|
|
tb = aOutputWindow.toolbar.visible;
|
|
aOutputWindow.focus();
|
|
origLeft = aOutputWindow.screen.left;
|
|
origTop = aOutputWindow.screen.top;
|
|
origWidth = aOutputWindow.outerWidth;
|
|
origHeight = aOutputWindow.outerHeight;
|
|
changed = true;
|
|
}
|
|
|
|
aOutputWindow.locationbar.visible = false;
|
|
aOutputWindow.menubar.visible = false;
|
|
aOutputWindow.personalbar.visible = false;
|
|
aOutputWindow.scrollbars.visible = false;
|
|
aOutputWindow.statusbar.visible = false;
|
|
aOutputWindow.toolbar.visible = false;
|
|
aTestWindow.locationbar.visible = false;
|
|
aTestWindow.menubar.visible = false;
|
|
aTestWindow.personalbar.visible = false;
|
|
aTestWindow.scrollbars.visible = false;
|
|
aTestWindow.statusbar.visible = false;
|
|
aTestWindow.toolbar.visible = false;
|
|
|
|
|
|
top = window.screen.availTop;
|
|
left = window.screen.availLeft;
|
|
height = window.screen.availHeight;
|
|
width = window.screen.availWidth;
|
|
if (height > 1000) {
|
|
height = 800;
|
|
} else {
|
|
height = height - 200;
|
|
}
|
|
if (width > 800) {
|
|
width = 800;
|
|
}
|
|
|
|
// size the window to the largest possible
|
|
aTestWindow.moveTo(left,200);
|
|
aTestWindow.resizeTo(width,height);
|
|
|
|
aOutputWindow.focus();
|
|
|
|
aOutputWindow.moveTo(left,top);
|
|
aOutputWindow.resizeTo(width,200);
|
|
aOutputWindow.scroll(0,1000);
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function DumpFrames1(aFirstTime,aLastFile)
|
|
{
|
|
|
|
outputWindow = window;
|
|
newWindow = window.open();
|
|
placeWindows(outputWindow,newWindow);
|
|
|
|
|
|
WriteOutput( "Starting Tests",true,"normal",true,false );
|
|
WriteOutput( "1",false,"normal",false,true );
|
|
WriteOutput( "2",false,"normal" ,false,true );
|
|
WriteOutput( "3",false,"failure" ,false,true );
|
|
WriteOutput( "4",false,"success" ,false,true );
|
|
WriteOutput( "5",false,"normal" ,false,true );
|
|
WriteOutput( "6",false,"success" ,false,true );
|
|
WriteOutput( "7",false,"success" ,false,true );
|
|
WriteOutput( "asf",false,"normal" ,false,true );
|
|
WriteOutput( "7",false,"failure" ,false,true );
|
|
WriteOutput( "asdf",false,"success" ,false,true );
|
|
WriteOutput( "wre",false,"normal" ,false,true );
|
|
WriteOutput( "wfw",false,"success" ,false,true );
|
|
WriteOutput( "jhgj",false,"success" ,false,true );
|
|
WriteOutput( "gjghj",false,"normal" ,false,true );
|
|
WriteOutput( "rtj",false,"failure" ,false,true );
|
|
|
|
RestoreWindow();
|
|
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function ShowDirectories()
|
|
{
|
|
for(i=0;i<(myArray.length);i+=3){
|
|
WriteOutput( myArray[i], false, "normal" ,false,true );
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function runTests()
|
|
{
|
|
|
|
if (document.getElementById('sd').checked ) {
|
|
// single directory
|
|
dirType = 1;
|
|
} else {
|
|
// directory list
|
|
dirType = 2;
|
|
}
|
|
|
|
// three buttons we use to check the kind of test we run (rb rv rvc)
|
|
if (document.getElementById('rb').checked ) {
|
|
// baseline
|
|
testType = 1;
|
|
} else if (document.getElementById('rv').checked ) {
|
|
// verify
|
|
testType = 2;
|
|
} else if (document.getElementById('rvc').checked ) {
|
|
// verify and compare
|
|
testType = 3;
|
|
} else if (document.getElementById('rc').checked ) {
|
|
testType = 4;
|
|
}
|
|
|
|
|
|
if ( dirType == 1 ) {
|
|
ClearOutput();
|
|
WriteOutput( "Starting Single Directory Tests",true,"normal",true,false );
|
|
|
|
// first verify all the fields are set up correctly
|
|
fileDirectory = document.TestForm.RegTestDir.value;
|
|
baseExt = document.TestForm.baseExt.value;
|
|
verExt = document.TestForm.verExt.value;
|
|
baseDir = document.TestForm.baseDir.value;
|
|
verDir = document.TestForm.verDir.value;
|
|
|
|
// create the output directories
|
|
if ( testType == 1 ) {
|
|
dirURL = "file:///"+ baseDir;
|
|
err = embed.CreateDirectory(dirURL,0);
|
|
}
|
|
|
|
if ( (testType == 1) || (testType == 2) ) {
|
|
dirURL = "file:///"+ verDir;
|
|
err = embed.CreateDirectory(dirURL,0);
|
|
}
|
|
|
|
DumpFrames(true,0,testType);
|
|
} else if (dirType == 2) {
|
|
ClearOutput();
|
|
WriteOutput( "Starting Directory Tests",true,"normal",true,false );
|
|
curIndex = 0;
|
|
DumpDirectoryies(testType);
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function DumpDirectoryies(aTestType)
|
|
{
|
|
|
|
if ( curIndex == 0) {
|
|
WriteOutput( "Starting Tests",true,"normal",true,false );
|
|
}
|
|
|
|
if ( curIndex < myArray.length ) {
|
|
fileDirectory = myArray[curIndex];
|
|
baseDir = myArray[curIndex+1];
|
|
verDir = myArray[curIndex+2];
|
|
baseExt = document.TestForm.baseExt.value;
|
|
verExt = document.TestForm.verExt.value;
|
|
|
|
// create the output directories
|
|
if ( testType == 1 ) {
|
|
dirURL = "file:///"+ baseDir;
|
|
err = embed.CreateDirectory(dirURL,0);
|
|
}
|
|
|
|
if ( (testType == 1) || (testType == 2) ) {
|
|
dirURL = "file:///"+ verDir;
|
|
err = embed.CreateDirectory(dirURL,0);
|
|
}
|
|
|
|
|
|
WriteOutput( "New Directory" , false, "normal" ,true, true );
|
|
DumpFrames(true,0,aTestType);
|
|
} else {
|
|
// all completed
|
|
theWindow.close();
|
|
RestoreWindow();
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
function DumpFrames(firstTime,lastFile,aTestType)
|
|
{
|
|
var loadingFlag;
|
|
|
|
if (firstTime == true) {
|
|
ClearOutput();
|
|
WriteOutput( "Starting Tests",true,"normal",true,false );
|
|
|
|
embed.StartDirectorySearch(fileDirectory);
|
|
filename=embed.GetNextFileInDirectory();
|
|
if ( filename != null) {
|
|
outputWindow = window;
|
|
theWindow = window.open(filename,0);
|
|
placeWindows(outputWindow,theWindow);
|
|
}
|
|
if ( document.getElementById('ds').checked ) {
|
|
dumpStyle = 1;
|
|
} else {
|
|
dumpStyle = 0;
|
|
}
|
|
started = true;
|
|
} else {
|
|
filename = lastFile;
|
|
}
|
|
|
|
while ( filename != null) {
|
|
// take off the file path.. so we just have the file name for the output
|
|
var startindex = filename.lastIndexOf("/");
|
|
var outputfilename = filename.slice(startindex+1,filename.length);
|
|
|
|
if (aTestType==1) {
|
|
// baseline
|
|
outputfilename = outputfilename.replace (".html",baseExt);
|
|
loading = embed.DumpLayout(theWindow,baseDir,outputfilename,dumpStyle);
|
|
} else if ((aTestType==2)|| (aTestType==3) ) {
|
|
// verify
|
|
outputfilename = outputfilename.replace (".html",verExt);
|
|
loading = embed.DumpLayout(theWindow,verDir,outputfilename,dumpStyle);
|
|
} else if (aTestType==4) {
|
|
// just compare
|
|
outputfilename = outputfilename.replace (".html",verExt);
|
|
loading = 0;
|
|
}
|
|
|
|
if (loading == 1) {
|
|
// page was not loaded
|
|
testtype = aTestType;
|
|
setTimeout("DumpFrames(false,filename,testtype,dumpStyle)",250);
|
|
break;
|
|
} else if (loading == 0) {
|
|
// successful in loading the page
|
|
if ( aTestType<4 ){
|
|
WriteOutput("Writing File " + "\""+outputfilename+"\"",false,"success",true,true );
|
|
}
|
|
|
|
if ( (aTestType==3) || (aTestType==4) ){
|
|
baseline = outputfilename.replace (verExt,baseExt);
|
|
CompareFiles(baseDir,verDir,baseline,outputfilename);
|
|
}
|
|
|
|
filename=embed.GetNextFileInDirectory();
|
|
if ( filename != null) {
|
|
theWindow.location = filename;
|
|
} else {
|
|
// all complete
|
|
if (dirType == 1) {
|
|
theWindow.close();
|
|
RestoreWindow();
|
|
} else {
|
|
curIndex+=3;
|
|
DumpDirectoryies(aTestType);
|
|
}
|
|
}
|
|
} else {
|
|
// fatal error.. break
|
|
WriteOutput("FATAL ERROR" + "\""+outputfilename+"\"",false,"failure",true,true );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//=============================================================================
|
|
|
|
|
|
</script>
|
|
|
|
<center>
|
|
<form name="TestForm">
|
|
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
<table bgcolor="#FFECFE" width=800>
|
|
<tr>
|
|
<td colspan="4" border>
|
|
<input id="sd" type="radio" name="dirTypes" value="runSingleDir" checked >
|
|
Run Regression on a Single Directory
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
Regression Directory
|
|
</td>
|
|
<td>
|
|
<input type="text" name="RegTestDir" value="file:///S|/mozilla/layout/html/tests/table/dom" size=50>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
BaseLine Extension
|
|
</td>
|
|
<td>
|
|
<input type="text" name="baseExt" value=".bas">
|
|
</td>
|
|
<td>
|
|
Verify Extension
|
|
</td>
|
|
<td>
|
|
<input type="text" name="verExt" value=".ver">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
BaseLine Output Directory
|
|
</td>
|
|
<td>
|
|
<input type="text" name="baseDir" value = "s:/regressiontests/">
|
|
</td>
|
|
<td>
|
|
Verify Output Directory
|
|
</td>
|
|
<td>
|
|
<input type="text" name="verDir" value = "s:/regressiontests/">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<table bgcolor="#FDFEDA" width=800>
|
|
<tr>
|
|
<td colspan="4">
|
|
<input id="dl" type="radio" name="dirTypes" value="runDirList" >
|
|
Run Regression using the directory list
|
|
</td>
|
|
<td>
|
|
<input type=button value="ShowDirectories" onclick='ShowDirectories()'>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<table width=800>
|
|
<tr>
|
|
<td>
|
|
Run Baseline
|
|
<input id="rb" type="radio" name="testType" value="runbaseline" checked >
|
|
</td>
|
|
<td>
|
|
Run Verify
|
|
<input id="rv" type="radio" name="testType" value="runverify" >
|
|
</td>
|
|
<td>
|
|
Run Verify with Compare
|
|
<input id="rvc" type="radio" name="testType" value="runvercomp" >
|
|
</td)
|
|
<td>
|
|
Run Compare
|
|
<input id="rc" type="radio" name="testType" value="runcomp" >
|
|
</td)
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
Dump Style
|
|
<input id="ds" type="checkbox" name="styleDump" value="dumpStyle" checked >
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<input type=button value="Run Tests" onclick='runTests()'>
|
|
</td>
|
|
<td>
|
|
<input type=button value="RestoreBars" onclick='RestoreWindow()'>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<table>
|
|
</form>
|
|
</center>
|
|
|
|
<h4 id="status"> OUTPUT IDLE </h4>
|
|
<div id="output" align="left" style="overflow:auto; width:700; height:100; border:solid red">
|
|
</div>
|
|
|
|
|
|
</BODY>
|
|
</HTML>
|