1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/test/test_error_on_404.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=476731 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 476731</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 + <script type="text/javascript" src="manifest.js"></script> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=476731">Mozilla Bug </a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script type="application/javascript"> 1.22 +/** Test for Bug 476731 **/ 1.23 + 1.24 +var videos = []; 1.25 + 1.26 +function FinishedLoads() { 1.27 + if (videos.length == 0) 1.28 + return false; 1.29 + for (var i=0; i<videos.length; ++i) { 1.30 + if (videos[i]._loadedData) { 1.31 + // A video loadeddata, it should have 404'd. Signal the end of the test 1.32 + // so the error will be reported. 1.33 + return true; 1.34 + } 1.35 + if (!videos[i]._loadError) { 1.36 + return false; 1.37 + } 1.38 + } 1.39 + return true; 1.40 +} 1.41 + 1.42 +function loadError(evt) { 1.43 + var v = evt.target; 1.44 + is(v._loadError, false, "Shouldn't receive multiple error events for " + v.src); 1.45 + v._loadError = true; 1.46 + is(v._loadStart, true, "Receive loadstart for " + v.src); 1.47 + is(v._loadedData, false, "Shouldn't receive loadeddata for " + v.src); 1.48 + if (FinishedLoads(videos)) 1.49 + SimpleTest.finish(); 1.50 +} 1.51 + 1.52 +function loadedData(evt) { 1.53 + evt.target._loadedData = true; 1.54 +} 1.55 + 1.56 +function loadStart(evt) { 1.57 + evt.target._loadStart = true; 1.58 +} 1.59 + 1.60 +// Create all video objects. 1.61 +for (var i=0; i<g404Tests.length; ++i) { 1.62 + var v = document.createElement("video"); 1.63 + v.preload = "auto"; 1.64 + var test = g404Tests[i]; 1.65 + if (!v.canPlayType(test.type)) { 1.66 + continue; 1.67 + } 1.68 + v.src = test.name; 1.69 + v._loadedData = false; 1.70 + v._loadStart = false; 1.71 + v._loadError = false; 1.72 + v.addEventListener("error", loadError, false); 1.73 + v.addEventListener("loadstart", loadStart, false); 1.74 + v.addEventListener("loadeddata", loadedData, false); 1.75 + document.body.appendChild(v); // Will start load. 1.76 + videos.push(v); 1.77 +} 1.78 + 1.79 +if (videos.length == 0) { 1.80 + todo(false, "No types supported"); 1.81 +} else { 1.82 + SimpleTest.waitForExplicitFinish(); 1.83 +} 1.84 +</script> 1.85 +</pre> 1.86 +</body> 1.87 +</html>