test_net_failedtoprocess.html (1459B)
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 src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <p id="display"></p> 14 <pre id="test"> 15 </pre> 16 <script type="application/javascript"> 17 18 SimpleTest.waitForExplicitFinish(); 19 20 const Ci = SpecialPowers.Ci; 21 const Cc = SpecialPowers.Cc; 22 var obs = Cc["@mozilla.org/observer-service;1"].getService(); 23 obs = obs.QueryInterface(Ci.nsIObserverService); 24 25 var observer = { 26 QueryInterface (aIID) { 27 if (aIID.equals(Ci.nsISupports) || 28 aIID.equals(Ci.nsIObserver)) 29 return this; 30 throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); 31 }, 32 33 observe(subject, topic) { 34 ok(topic == "net:failed-to-process-uri-content", "wrong topic"); 35 subject = subject.QueryInterface(Ci.nsIURI); 36 is(subject.asciiSpec, `${location.origin}/tests/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(SpecialPowers.wrapCallbackObject(observer), "net:failed-to-process-uri-content"); 45 46 document.write('<img src="damon.jpg">'); 47 document.write('<img src="invalid.jpg">'); 48 49 </script> 50 </body> 51 </html>