1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/test/mochitest/test_net_failedtoprocess.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +Test that a image decoding error producs a net:failed-to-process-uri-content 1.8 +observer event with the nsIURI of the failed image as the subject 1.9 +--> 1.10 +<head> 1.11 + <title>Test for image net:failed-to-process-uri-content</title> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.15 +</head> 1.16 +<body> 1.17 +<p id="display"></p> 1.18 +<pre id="test"> 1.19 +<script type="application/javascript"> 1.20 + 1.21 +SimpleTest.waitForExplicitFinish(); 1.22 + 1.23 +const Ci = Components.interfaces; 1.24 +const Cc = Components.classes; 1.25 +var obs = Cc["@mozilla.org/observer-service;1"].getService(); 1.26 +obs = obs.QueryInterface(Ci.nsIObserverService); 1.27 + 1.28 +var observer = { 1.29 + QueryInterface: function (aIID) { 1.30 + if (aIID.equals(Ci.nsISupports) || 1.31 + aIID.equals(Ci.nsIObserver)) 1.32 + return this; 1.33 + throw Cr.NS_ERROR_NO_INTERFACE; 1.34 + }, 1.35 + 1.36 + observe: function(subject, topic, data) { 1.37 + ok(topic == "net:failed-to-process-uri-content", "wrong topic"); 1.38 + subject = subject.QueryInterface(Ci.nsIURI); 1.39 + ok(subject.asciiSpec == "chrome://mochitests/content/chrome/image/test/mochitest/invalid.jpg", "wrong subject"); 1.40 + 1.41 + obs.removeObserver(this, "net:failed-to-process-uri-content"); 1.42 + 1.43 + SimpleTest.finish(); 1.44 + } 1.45 +}; 1.46 + 1.47 +obs.addObserver(observer, "net:failed-to-process-uri-content", false); 1.48 + 1.49 +</script> 1.50 +</pre> 1.51 +<img src="damon.jpg"> 1.52 +<img src="invalid.jpg"> 1.53 +</body> 1.54 +</html>