OLD | NEW |
(Empty) | |
| 1 jsTestIsAsync = true; |
| 2 |
| 3 var imgOnLoadCalled = false; |
| 4 var img2OnLoadCalled = false; |
| 5 var bodyOnLoadCalled = false; |
| 6 |
| 7 var img = document.createElement('img'); |
| 8 var img2 = document.createElement('img'); |
| 9 |
| 10 img.onload = imgOnLoad; |
| 11 img.src = url; |
| 12 document.body.appendChild(img); |
| 13 shouldBeFalse("bodyOnLoadCalled"); |
| 14 shouldBeFalse("imgOnLoadCalled"); |
| 15 shouldBeFalse("img.complete"); |
| 16 |
| 17 function imgOnLoad() { |
| 18 imgOnLoadCalled = true; |
| 19 debug("img's onload"); |
| 20 |
| 21 shouldBeFalse("bodyOnLoadCalled"); |
| 22 shouldBeTrue("imgOnLoadCalled"); |
| 23 shouldBeTrue("img.complete"); |
| 24 |
| 25 img2.onload = img2OnLoad; |
| 26 img2.src = url; |
| 27 document.body.appendChild(img2); |
| 28 shouldBeFalse("bodyOnLoadCalled"); |
| 29 shouldBeFalse("img2OnLoadCalled"); |
| 30 shouldBeFalse("img2.complete"); |
| 31 } |
| 32 |
| 33 function img2OnLoad() { |
| 34 img2OnLoadCalled = true; |
| 35 debug("img2's onload"); |
| 36 |
| 37 shouldBeFalse("bodyOnLoadCalled"); |
| 38 shouldBeTrue("img2OnLoadCalled"); |
| 39 shouldBeTrue("img2.complete"); |
| 40 } |
| 41 |
| 42 function bodyOnLoad() { |
| 43 bodyOnLoadCalled = true; |
| 44 debug("body's onload"); |
| 45 shouldBeTrue("imgOnLoadCalled"); |
| 46 shouldBeTrue("img.complete"); |
| 47 shouldBeTrue("img2OnLoadCalled"); |
| 48 shouldBeTrue("img2.complete"); |
| 49 finishJSTest(); |
| 50 } |
OLD | NEW |