test_net_failedtoprocess.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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="/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. SimpleTest.waitForExplicitFinish();
  18. const Ci = SpecialPowers.Ci;
  19. const Cc = SpecialPowers.Cc;
  20. var obs = Cc["@mozilla.org/observer-service;1"].getService();
  21. obs = obs.QueryInterface(Ci.nsIObserverService);
  22. var observer = {
  23. QueryInterface: function (aIID) {
  24. if (aIID.equals(Ci.nsISupports) ||
  25. aIID.equals(Ci.nsIObserver))
  26. return this;
  27. throw Cr.NS_ERROR_NO_INTERFACE;
  28. },
  29. observe: function(subject, topic, data) {
  30. ok(topic == "net:failed-to-process-uri-content", "wrong topic");
  31. subject = subject.QueryInterface(Ci.nsIURI);
  32. is(subject.asciiSpec, "http://mochi.test:8888/tests/image/test/mochitest/invalid.jpg", "wrong subject");
  33. obs.removeObserver(this, "net:failed-to-process-uri-content");
  34. SimpleTest.finish();
  35. }
  36. };
  37. obs.addObserver(SpecialPowers.wrapCallbackObject(observer), "net:failed-to-process-uri-content", false);
  38. document.write('<img src="damon.jpg">');
  39. document.write('<img src="invalid.jpg">');
  40. </script>
  41. </body>
  42. </html>