JavaScript Test Library - add support for browser tests which complete after page load, bug 341550, a=bsmedberg for checkin to closed tree

This commit is contained in:
bclary%bclary.com 2006-06-14 18:52:00 +00:00
Родитель 6ffc7a26f1
Коммит ff0e8dc4a3
17 изменённых файлов: 251 добавлений и 36 удалений

Просмотреть файл

@ -49,14 +49,26 @@ printStatus('This test runs in the browser only');
function init()
{
var sel = document.getElementsByTagName("select")[0];
sel.add(document.createElement('foo'), <bar/>);
try
{
var sel = document.getElementsByTagName("select")[0];
sel.add(document.createElement('foo'), <bar/>);
}
catch(ex)
{
printStatus(ex + '');
}
TEST(1, expect, actual);
END();
gDelayTestDriverEnd = false;
jsTestDriverEnd();
}
if (typeof window != 'undefined')
{
// delay test driver end
gDelayTestDriverEnd = true;
document.write('<select></select>');
window.addEventListener("load", init, false);
}

Просмотреть файл

@ -59,10 +59,25 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
function print( string ) {

Просмотреть файл

@ -62,16 +62,32 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
function writeHeaderToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( "<h2>" + string + "</h2>" );
DocumentWrite( "<h2>" + string + "</h2>" );
}
function writeFormattedResult( expect, actual, string, passed ) {
@ -81,7 +97,7 @@ function writeFormattedResult( expect, actual, string, passed ) {
s += "<b>" ;
s += ( passed ) ? "<font color=#009900> &nbsp;" + PASSED
: "<font color=#aa0000>&nbsp;" + FAILED + expect + "</tt>";
document.write( s + "</font></b></tt><br>" );
DocumentWrite( s + "</font></b></tt><br>" );
return passed;
}

Просмотреть файл

@ -62,15 +62,30 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
function writeHeaderToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( "<h2>" + string + "</h2>" );
DocumentWrite( "<h2>" + string + "</h2>" );
}
function writeFormattedResult( expect, actual, string, passed ) {
@ -80,7 +95,7 @@ function writeFormattedResult( expect, actual, string, passed ) {
s += "<b>" ;
s += ( passed ) ? "<font color=#009900> &nbsp;" + PASSED
: "<font color=#aa0000>&nbsp;" + FAILED + expect + "</tt>";
document.write( s + "</font></b></tt><br>" );
DocumentWrite( s + "</font></b></tt><br>" );
return passed;
}

Просмотреть файл

@ -60,10 +60,25 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
var testcases = new Array();

Просмотреть файл

@ -2,6 +2,7 @@
var gVersion = 150;
var gTestName = '';
var gTestPath = '';
var gDelayTestDriverEnd = false;
function init()
{

Просмотреть файл

@ -1,14 +1,32 @@
if (window.opener && window.opener.runNextTest)
function jsTestDriverEnd()
{
if (window.opener.reportCallBack)
// gDelayTestDriverEnd is used to
// delay collection of the test result and
// signal to Spider so that tests can continue
// to run after page load has fired. They are
// responsible for setting gDelayTestDriverEnd = true
// then when completed, setting gDelayTestDriverEnd = false
// then calling jsTestDriverEnd()
if (gDelayTestDriverEnd)
{
window.opener.reportCallBack(window.opener.gWindow);
return;
}
if (window.opener && window.opener.runNextTest)
{
if (window.opener.reportCallBack)
{
window.opener.reportCallBack(window.opener.gWindow);
}
setTimeout('window.opener.runNextTest()', 250);
}
else
{
gPageCompleted = true;
}
setTimeout('window.opener.runNextTest()', 250);
}
else
{
gPageCompleted = true;
}
jsTestDriverEnd();

Просмотреть файл

@ -62,13 +62,28 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
function writeHeaderToLog( string ) {
string = string.replace(/[<>&]/g, htmlesc);
document.write( "<h2>" + string + "</h2>" );
DocumentWrite( "<h2>" + string + "</h2>" );
}
function writeFormattedResult( expect, actual, string, passed ) {
@ -77,7 +92,7 @@ function writeFormattedResult( expect, actual, string, passed ) {
s += "<b>" ;
s += ( passed ) ? "<font color=#009900> &nbsp;" + PASSED
: "<font color=#aa0000>&nbsp;" + FAILED + expect + "</tt>";
document.write( s + "</font></b></tt><br>" );
DocumentWrite( s + "</font></b></tt><br>" );
return passed;
}

Просмотреть файл

@ -62,16 +62,31 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
function writeHeaderToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( "<h2>" + string + "</h2>" );
DocumentWrite( "<h2>" + string + "</h2>" );
}
function writeFormattedResult( expect, actual, string, passed ) {
@ -81,7 +96,7 @@ function writeFormattedResult( expect, actual, string, passed ) {
s += "<b>" ;
s += ( passed ) ? "<font color=#009900> &nbsp;" + PASSED
: "<font color=#aa0000>&nbsp;" + FAILED + expect + "</tt>";
document.write( s + "</font></b></tt><br>" );
DocumentWrite( s + "</font></b></tt><br>" );
return passed;
}

Просмотреть файл

@ -62,15 +62,31 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
}
function writeHeaderToLog( string ) {
string = String(string);
document.write( "<h2>" + string + "</h2>" );
DocumentWrite( "<h2>" + string + "</h2>" );
}
function writeFormattedResult( expect, actual, string, passed ) {
string = String(string);
@ -79,7 +95,7 @@ function writeFormattedResult( expect, actual, string, passed ) {
s += "<b>" ;
s += ( passed ) ? "<font color=#009900> &nbsp;" + PASSED
: "<font color=#aa0000>&nbsp;" + FAILED + expect + "</tt>";
document.write( s + "</font></b></tt><br>" );
DocumentWrite( s + "</font></b></tt><br>" );
return passed;
}

Просмотреть файл

@ -62,15 +62,30 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
function writeHeaderToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( "<h2>" + string + "</h2>" );
DocumentWrite( "<h2>" + string + "</h2>" );
}
function writeFormattedResult( expect, actual, string, passed ) {
@ -80,7 +95,7 @@ function writeFormattedResult( expect, actual, string, passed ) {
s += "<b>" ;
s += ( passed ) ? "<font color=#009900> &nbsp;" + PASSED
: "<font color=#aa0000>&nbsp;" + FAILED + expect + "</tt>";
document.write( s + "</font></b></tt><br>" );
DocumentWrite( s + "</font></b></tt><br>" );
return passed;
}

Просмотреть файл

@ -46,14 +46,16 @@ printStatus (summary);
if (typeof window != 'undefined' && typeof document != 'undefined')
{
// delay test driver end
gDelayTestDriverEnd = true;
window.addEventListener('load', handleLoad, false);
}
else
{
printStatus('This test must be run in the browser');
}
reportCompare(expect, actual, summary);
reportCompare(expect, actual, summary);
}
var div;
@ -76,7 +78,7 @@ function handleLoad()
div.watch('scrollTop', wee);
setTimeout('div.scrollTop = 42', 1000);
setTimeout('setScrollTop()', 1000);
}
function wee(id, oldval, newval)
@ -92,3 +94,13 @@ function wee(id, oldval, newval)
return newval;
}
function setScrollTop()
{
div.scrollTop = 42;
reportCompare(expect, actual, summary);
gDelayTestDriverEnd = false;
jsTestDriverEnd();
}

Просмотреть файл

@ -51,6 +51,9 @@ if (typeof document == 'undefined')
}
else
{
// delay test driver end
gDelayTestDriverEnd = true;
actual = 'Crash';
window.onload = onLoad;
}
@ -75,6 +78,9 @@ function onLoad()
actual = 'No Crash';
reportCompare(expect, actual, summary);
gDelayTestDriverEnd = false;
jsTestDriverEnd();
}
function setform()

Просмотреть файл

@ -47,8 +47,15 @@ printStatus (summary);
if (typeof document != 'undefined')
{
// delay test driver end
gDelayTestDriverEnd = true;
window.onload = onLoad;
}
else
{
actual = 'No Crash';
reportCompare(expect, actual, summary);
}
function onLoad() {
setform();
@ -60,6 +67,8 @@ function onLoad() {
actual = 'No Crash';
reportCompare(expect, actual, summary);
gDelayTestDriverEnd = false;
jsTestDriverEnd();
}

Просмотреть файл

@ -42,7 +42,7 @@ var expect = 'No Crash';
printBugNumber (bug);
printStatus (summary);
printStatus('This test runs only in the browser');
writeLineToLog('This test runs only in the browser');
function countProps(obj)
{
@ -56,15 +56,20 @@ function init()
{
var inp = document.getElementsByTagName("input")[0];
countProps(inp);
window.open().close(); // force gc?
gc();
var blurfun = inp.blur;
blurfun.__proto__ = null;
countProps(blurfun);
reportCompare(expect, actual, summary);
gDelayTestDriverEnd = false;
jsTestDriverEnd();
}
if (typeof window != 'undefined')
{
// delay test driver end
gDelayTestDriverEnd = true;
document.write('<input>');
window.addEventListener("load", init, false);
}

Просмотреть файл

@ -59,10 +59,25 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite(string);
}
var testcases = new Array();

Просмотреть файл

@ -60,10 +60,25 @@ function htmlesc(str) {
return str;
}
function DocumentWrite(s)
{
try
{
var msgDiv = document.createElement('div');
msgDiv.innerHTML = s;
document.body.appendChild(msgDiv);
msgDiv = null;
}
catch(excp)
{
document.write(s + "<br>\n");
}
}
function writeLineToLog( string ) {
string = String(string);
string = string.replace(/[<>&]/g, htmlesc);
document.write( string + "<br>\n");
DocumentWrite( string + "<br>\n");
}
var testcases = new Array();