|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=715308 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 715308 comment 93</title> |
|
8 <script type="application/javascript" src="/MochiKit/MochiKit.js"></script> |
|
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
11 </head> |
|
12 <body> |
|
13 |
|
14 <!-- Test for Bug 715308 comment 93: |
|
15 |
|
16 - For a valid image, onload is fired and onerror is never fired. |
|
17 - For an image with errors, onerror is fired, but onload is never fired. |
|
18 - For any image, either onload or onerror is fired, but never both. |
|
19 |
|
20 --> |
|
21 <script type="text/javascript;version=1.8"> |
|
22 "use strict"; |
|
23 |
|
24 SimpleTest.waitForExplicitFinish(); |
|
25 |
|
26 var numCallbacks = 0; |
|
27 |
|
28 function image_error(name) |
|
29 { |
|
30 numCallbacks++; |
|
31 ok(name == 'error-early', "Got onerror for " + name); |
|
32 } |
|
33 |
|
34 function image_load(name) |
|
35 { |
|
36 numCallbacks++; |
|
37 ok(name == 'shaver', "Got onload for " + name); |
|
38 } |
|
39 |
|
40 function page_load() |
|
41 { |
|
42 ok(numCallbacks == 2, 'Got page load before all onload/onerror callbacks?'); |
|
43 |
|
44 // Spin the event loop a few times to let image_error run if it's going to, |
|
45 // then finish the test. |
|
46 SimpleTest.executeSoon(function() { |
|
47 SimpleTest.executeSoon(function() { |
|
48 SimpleTest.executeSoon(function() { |
|
49 SimpleTest.finish(); |
|
50 }); |
|
51 }); |
|
52 }); |
|
53 } |
|
54 |
|
55 addEventListener('load', page_load); |
|
56 |
|
57 </script> |
|
58 |
|
59 <div id="content"> |
|
60 <img src='shaver.png' onerror='image_error("shaver")' onload='image_load("shaver")'> |
|
61 <img src='error-early.png' onerror='image_error("error-early")' onload='image_load("error-early")'> |
|
62 </div> |
|
63 |
|
64 </pre> |
|
65 </body> |
|
66 </html> |
|
67 |