1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/test/mochitest/test_error_events.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=715308 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 715308 comment 93</title> 1.11 + <script type="application/javascript" src="/MochiKit/MochiKit.js"></script> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 + 1.17 +<!-- Test for Bug 715308 comment 93: 1.18 + 1.19 + - For a valid image, onload is fired and onerror is never fired. 1.20 + - For an image with errors, onerror is fired, but onload is never fired. 1.21 + - For any image, either onload or onerror is fired, but never both. 1.22 + 1.23 + --> 1.24 +<script type="text/javascript;version=1.8"> 1.25 +"use strict"; 1.26 + 1.27 +SimpleTest.waitForExplicitFinish(); 1.28 + 1.29 +var numCallbacks = 0; 1.30 + 1.31 +function image_error(name) 1.32 +{ 1.33 + numCallbacks++; 1.34 + ok(name == 'error-early', "Got onerror for " + name); 1.35 +} 1.36 + 1.37 +function image_load(name) 1.38 +{ 1.39 + numCallbacks++; 1.40 + ok(name == 'shaver', "Got onload for " + name); 1.41 +} 1.42 + 1.43 +function page_load() 1.44 +{ 1.45 + ok(numCallbacks == 2, 'Got page load before all onload/onerror callbacks?'); 1.46 + 1.47 + // Spin the event loop a few times to let image_error run if it's going to, 1.48 + // then finish the test. 1.49 + SimpleTest.executeSoon(function() { 1.50 + SimpleTest.executeSoon(function() { 1.51 + SimpleTest.executeSoon(function() { 1.52 + SimpleTest.finish(); 1.53 + }); 1.54 + }); 1.55 + }); 1.56 +} 1.57 + 1.58 +addEventListener('load', page_load); 1.59 + 1.60 +</script> 1.61 + 1.62 +<div id="content"> 1.63 + <img src='shaver.png' onerror='image_error("shaver")' onload='image_load("shaver")'> 1.64 + <img src='error-early.png' onerror='image_error("error-early")' onload='image_load("error-early")'> 1.65 +</div> 1.66 + 1.67 +</pre> 1.68 +</body> 1.69 +</html> 1.70 +