Bug 476731 - Media element should fire error event when src is a 404; missing test_error_on_404.html; r=chris.double sr=roc
authorChris Pearce <chris@pearce.org.nz>
Sun, 15 Feb 2009 18:14:49 +0100
changeset 23456 6f6d5aace10ed652b38b96639c924f8825c17fa6
parent 23455 9a4041b5740eb3aeba99bc500a2290c9442854a9
child 23457 1ca66ced33f5e31f37a0267752b513999f9b2d71
push id778
push userrocallahan@mozilla.com
push dateThu, 26 Feb 2009 09:56:42 +0000
reviewerschris.double, roc
bugs476731
milestone1.9.1b3pre
Bug 476731 - Media element should fire error event when src is a 404; missing test_error_on_404.html; r=chris.double sr=roc
content/media/video/test/test_error_on_404.html
new file mode 100644
--- /dev/null
+++ b/content/media/video/test/test_error_on_404.html
@@ -0,0 +1,80 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=476731
+-->
+<head>
+  <title>Test for Bug 476731</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=476731">Mozilla Bug </a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+
+
+
+<script type="application/javascript">
+
+/** Test for Bug  **/
+
+var gLoadedData = new Object();
+var gLoadStart = new Object();
+var gLoadError = new Object();
+
+gLoadedData['v'] = false;
+gLoadedData['a'] = false;
+
+gLoadStart['v'] = false;
+gLoadStart['a'] = false;
+
+gLoadError['v'] = false;
+gLoadError['a'] = false;
+
+function loadError(evt, id) {
+  // Prevent mochitest's onerror handler catching the 'error' event on bubble.
+  evt.stopPropagation();
+  is(gLoadError[id], false, "Shouldn't have more than one error for each media element");
+  gLoadError[id] = true;
+  is(gLoadStart[id], true, "Should have started load");
+  is(gLoadedData[id], false, "Shouldn't have finished load.");
+  if (gLoadError['a'] && gLoadError['v'])
+    SimpleTest.finish();
+}
+
+function loadedData(evt, id) {
+  gLoadedData[id] = true;
+}
+
+function loadStart(evt, id) {
+  gLoadStart[id] = true;
+}
+
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+
+<video id="v"
+       onerror="loadError(event, 'v');"
+       onloadstart="loadStart(event, 'v');"
+       onloadeddata="loadedData(event, 'v');"
+       src="404.ogg">
+</video>
+
+
+<audio id="a"
+       onerror="loadError(event, 'a');"
+       onloadstart="loadStart(event, 'a');"
+       onloadeddata="loadedData(event, 'a');"
+       src="404.wav">
+</audio>
+
+</body>
+</html>