Force the test to complete after 1 sec to avoid hang if the window isn't focused. b=564413

This commit is contained in:
Mats Palmgren 2010-05-12 14:14:48 +02:00
parent 6b28186055
commit 73489238b0
2 changed files with 10 additions and 2 deletions

View File

@ -15,17 +15,21 @@
}
</style>
<script>
var done = false;
function runTest(p) {
if (done)
return;
try {
var r = window.getSelection().getRangeAt(0);
r.setStart(p.childNodes[1],1);
r.setEnd(p.childNodes[1],1);
} catch (e) {}
document.documentElement.removeAttribute('class');
done = true;
}
</script>
</head>
<body onload="setTimeout(function(){window.focus();document.getElementsByTagName('p')[0].focus()},400)">
<body onload="var p = document.getElementsByTagName('p')[0]; p.focus(); setTimeout(function(){runTest(p)},1000)">
<p onfocus="runTest(this)" contentEditable="true"
style="text-align:justify"><span>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</span>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;</p>

View File

@ -15,17 +15,21 @@
}
</style>
<script>
var done = false;
function runTest(p) {
if (done)
return;
try {
var r = window.getSelection().getRangeAt(0);
r.setStart(p.childNodes[0],14);
r.setEnd(p.childNodes[0],14);
} catch (e) {}
document.documentElement.removeAttribute('class');
done = true;
}
</script>
</head>
<body onload="setTimeout(function(){window.focus();document.getElementsByTagName('p')[0].focus()},400)">
<body onload="var p = document.getElementsByTagName('p')[0]; p.focus(); setTimeout(function(){runTest(p)},1000)">
<p onfocus="runTest(this)" contentEditable="true"
style="text-align:justify">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;</p>