pjs/extensions/layout-debug/plugin/tableRegression.html

427 строки
11 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 startIndex;
var endIndex;
var dumpStyle;
var myArray = new Array(15);
// table
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/other";
myArray[7] = "s:/regressiontests/";
myArray[8] = "s:/regressiontests/";
myArray[9] = "file:///S|/mozilla/layout/html/tests/table/dom";
myArray[10] = "s:/regressiontests/";
myArray[11] = "s:/regressiontests/";
myArray[12] = "file:///S|/mozilla/layout/html/tests/table/printing";
myArray[13] = "s:/regressiontests/";
myArray[14] = "s:/regressiontests/";
// block
myArray[15] = "file:///S|/mozilla/layout/html/tests/block/base";
myArray[16] = "s:/regressiontests/";
myArray[17] = "s:/regressiontests/";
myArray[18] = "file:///S|/mozilla/layout/html/tests/block/bugs";
myArray[19] = "s:/regressiontests/";
myArray[20] = "s:/regressiontests/";
// form controls
myArray[21] = "file:///S|/mozilla/layout/html/tests/formctls/base";
myArray[22] = "s:/regressiontests/";
myArray[23] = "s:/regressiontests/";
myArray[24] = "file:///S|/mozilla/layout/html/tests/formctls/bugs";
myArray[25] = "s:/regressiontests/";
myArray[26] = "s:/regressiontests/";
//=============================================================================
function CompareFiles(aBaseDir,aVerDir,aBaselineFile,aVerFile)
{
var 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()
{
var textarea = document.getElementById('output');
textarea.innerHTML = "";
}
//=============================================================================
function WriteOutput( aText, aReplace, aTextColor,aToStatus, aToOutPut )
{
var textarea = document.getElementById('output');
var statusarea = document.getElementById('status');
var 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 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;
var top = window.screen.availTop;
var left = window.screen.availLeft;
var height = window.screen.availHeight;
var 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 ShowDirectories()
{
for(i=0;i<(myArray.length);i+=3){
WriteOutput( myArray[i], false, "normal" ,false,true );
}
}
//=============================================================================
function runTests()
{
if (document.getElementById('ar').checked ) {
// all
startIndex = 0; endIndex = myArray.length;
} else if (document.getElementById('tr').checked ) {
// table
startIndex = 0; endIndex = 15;
} else if (document.getElementById('br').checked ) {
// base
startIndex = 15; endIndex = 21;
} else if (document.getElementById('fcr').checked ) {
// form controls
startIndex = 21; endIndex = 27;
}
// 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;
}
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 < endIndex ) {
fileDirectory = myArray[curIndex];
baseDir = myArray[curIndex+1];
verDir = myArray[curIndex+2];
baseExt = ".bas";
verExt = ".ver";
var dirURL;
var err;
// 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="#FDFEDA" width=800>
<tr>
<td colspan="4">
<input id="ar" type="radio" name="dirTypes" value="runDirList" checked>
All Regression
</td>
</tr>
<tr>
<td colspan="4">
<input id="tr" type="radio" name="dirTypes" value="runDirList" >
Table Regression
</td>
</tr>
<tr>
<td colspan="4">
<input id="br" type="radio" name="dirTypes" value="runDirList" >
Block Regression
</td>
</tr>
<tr>
<td colspan="4">
<input id="fcr" type="radio" name="dirTypes" value="runDirList" >
Form Controls Regression
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width=800>
<tr>
<td>
Generate Baseline
<input id="rb" type="radio" name="testType" value="runbaseline" checked >
</td>
<td>
Verify and Compare
<input id="rv" type="radio" name="testType" value="runverify" >
</td>
</tr>
<tr>
<td>
Dump Style
<input id="ds" type="checkbox" name="styleDump" value="dumpStyle" checked >
</td>
</tr>
<tr>
<td>
<input type=button value="Execute" onclick='runTests()'>
</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>