diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /image/test/mochitest/test_net_failedtoprocess.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'image/test/mochitest/test_net_failedtoprocess.html')
-rw-r--r-- | image/test/mochitest/test_net_failedtoprocess.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/image/test/mochitest/test_net_failedtoprocess.html b/image/test/mochitest/test_net_failedtoprocess.html new file mode 100644 index 0000000000..470f3f5b31 --- /dev/null +++ b/image/test/mochitest/test_net_failedtoprocess.html @@ -0,0 +1,52 @@ +<!DOCTYPE HTML> +<html> +<!-- +Test that a image decoding error producs a net:failed-to-process-uri-content +observer event with the nsIURI of the failed image as the subject +--> +<head> + <title>Test for image net:failed-to-process-uri-content</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<p id="display"></p> +<pre id="test"> +</pre> +<script type="application/javascript"> + +SimpleTest.waitForExplicitFinish(); + +const Ci = SpecialPowers.Ci; +const Cc = SpecialPowers.Cc; +var obs = Cc["@mozilla.org/observer-service;1"].getService(); +obs = obs.QueryInterface(Ci.nsIObserverService); + +var observer = { + /* eslint-disable-next-line mozilla/use-chromeutils-generateqi */ + QueryInterface (aIID) { + if (aIID.equals(Ci.nsISupports) || + aIID.equals(Ci.nsIObserver)) + return this; + throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); + }, + + observe(subject, topic, data) { + ok(topic == "net:failed-to-process-uri-content", "wrong topic"); + subject = subject.QueryInterface(Ci.nsIURI); + is(subject.asciiSpec, `${location.origin}/tests/image/test/mochitest/invalid.jpg`, "wrong subject"); + + obs.removeObserver(this, "net:failed-to-process-uri-content"); + + SimpleTest.finish(); + } +}; + +obs.addObserver(SpecialPowers.wrapCallbackObject(observer), "net:failed-to-process-uri-content"); + +document.write('<img src="damon.jpg">'); +document.write('<img src="invalid.jpg">'); + +</script> +</body> +</html> |