| Index: LayoutTests/fast/dom/HTMLImageElement/image-innerHTML.html
 | 
| diff --git a/LayoutTests/fast/dom/HTMLImageElement/image-innerHTML.html b/LayoutTests/fast/dom/HTMLImageElement/image-innerHTML.html
 | 
| index 8ab8575df473fdb9880b29e0a052e95b78311d34..a5b4c4ab6266fe0ea3f995369048e9f2644823f3 100644
 | 
| --- a/LayoutTests/fast/dom/HTMLImageElement/image-innerHTML.html
 | 
| +++ b/LayoutTests/fast/dom/HTMLImageElement/image-innerHTML.html
 | 
| @@ -10,14 +10,31 @@ var div = document.createElement('div');
 | 
|  var div2 = document.createElement('div');
 | 
|  var attemptedLoadDirect = false;
 | 
|  var attemptedLoadIndirect = false;
 | 
| +var numEventsOutsanding = 3;
 | 
|  
 | 
| -div.innerHTML = '<img src="../resources/abe.png" onload="attemptedLoadDirect = true;">';
 | 
| -div2.innerHTML = '<div><img src="../resources/abe.png" onload="attemptedLoadIndirect = true;"></div>';
 | 
| -document.body.onload = function() {
 | 
| -    shouldBeTrue('attemptedLoadDirect');
 | 
| -    shouldBeTrue('attemptedLoadIndirect');
 | 
| -    finishJSTest();
 | 
| -};
 | 
| +function maybeCheckResults() {
 | 
| +    numEventsOutsanding--;
 | 
| +    if (numEventsOutsanding == 0) {
 | 
| +        shouldBeTrue('attemptedLoadDirect');
 | 
| +        shouldBeTrue('attemptedLoadIndirect');
 | 
| +        finishJSTest();
 | 
| +    }
 | 
| +}
 | 
| +
 | 
| +function onDirect() {
 | 
| +    attemptedLoadDirect = true;
 | 
| +    maybeCheckResults();
 | 
| +}
 | 
| +
 | 
| +function onIndirect() {
 | 
| +    attemptedLoadIndirect = true;
 | 
| +    maybeCheckResults();
 | 
| +}
 | 
| +
 | 
| +// The order in which these three events occur is undefined, and shouldn't matter for this test.
 | 
| +div.innerHTML = '<img src="../resources/abe.png" onload="onDirect();">';
 | 
| +div2.innerHTML = '<div><img src="../resources/abe.png" onload="onIndirect();"></div>';
 | 
| +document.body.onload = maybeCheckResults;
 | 
|  </script>
 | 
|  </body>
 | 
|  </html>
 | 
| 
 |