image/test/mochitest/test_net_failedtoprocess.html

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:6b560265f630
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Test that a image decoding error producs a net:failed-to-process-uri-content
5 observer event with the nsIURI of the failed image as the subject
6 -->
7 <head>
8 <title>Test for image net:failed-to-process-uri-content</title>
9 <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
12 </head>
13 <body>
14 <p id="display"></p>
15 <pre id="test">
16 <script type="application/javascript">
17
18 SimpleTest.waitForExplicitFinish();
19
20 const Ci = Components.interfaces;
21 const Cc = Components.classes;
22 var obs = Cc["@mozilla.org/observer-service;1"].getService();
23 obs = obs.QueryInterface(Ci.nsIObserverService);
24
25 var observer = {
26 QueryInterface: function (aIID) {
27 if (aIID.equals(Ci.nsISupports) ||
28 aIID.equals(Ci.nsIObserver))
29 return this;
30 throw Cr.NS_ERROR_NO_INTERFACE;
31 },
32
33 observe: function(subject, topic, data) {
34 ok(topic == "net:failed-to-process-uri-content", "wrong topic");
35 subject = subject.QueryInterface(Ci.nsIURI);
36 ok(subject.asciiSpec == "chrome://mochitests/content/chrome/image/test/mochitest/invalid.jpg", "wrong subject");
37
38 obs.removeObserver(this, "net:failed-to-process-uri-content");
39
40 SimpleTest.finish();
41 }
42 };
43
44 obs.addObserver(observer, "net:failed-to-process-uri-content", false);
45
46 </script>
47 </pre>
48 <img src="damon.jpg">
49 <img src="invalid.jpg">
50 </body>
51 </html>

mercurial