diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/events/test/test_error_events.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/events/test/test_error_events.html')
-rw-r--r-- | dom/events/test/test_error_events.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dom/events/test/test_error_events.html b/dom/events/test/test_error_events.html new file mode 100644 index 0000000000..1d47e5398b --- /dev/null +++ b/dom/events/test/test_error_events.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Test for error events being ErrorEvent</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + setup({allow_uncaught_exception:true}); + var errorEvent; + var file; + var line; + var msg; + var column; + var error; + window.addEventListener("error", function(e) { + errorEvent = e; + }, {once: true}); + var oldOnerror = window.onerror; + window.onerror = function(message, filename, lineno, columnno, errorObject) { + window.onerror = oldOnerror; + file = filename; + line = lineno; + msg = message; + column = columnno; + error = errorObject; + } + var thrown = new Error("hello"); + throw thrown; +</script> +<script> + generate_tests(assert_equals, [ + [ "Event filename", errorEvent.filename, location.href ], + [ "Callback filename", file, location.href ], + [ "Event line number", errorEvent.lineno, 27 ], + [ "Callback line number", line, 27 ], + [ "Event message", errorEvent.message, "Error: hello" ], + [ "Callback message", msg, "Error: hello" ], + [ "Event error-object", errorEvent.error, thrown], + [ "Callback error-object", error, thrown ], + [ "Event column", errorEvent.colno, 16 ], + [ "Callback column", column, 16 ] + ]); +</script> +<script> + var workerLocation = location.protocol + "//" + location.host + + location.pathname.replace("test_error_events.html", "error_event_worker.js"); + var eventFileTest = async_test("Worker event filename"); + var eventLineTest = async_test("Worker event line number"); + var eventMessageTest = async_test("Worker event message"); + var callbackFileTest = async_test("Worker callback filename"); + var callbackLineTest = async_test("Worker callback line number"); + var callbackMessageTest = async_test("Worker callback message"); + var w = new Worker("error_event_worker.js"); + w.addEventListener("message", function(msg) { + if (msg.data.type == "event") { + eventFileTest.step(function() { assert_equals(msg.data.filename, workerLocation); }); + eventFileTest.done(); + eventLineTest.step(function() { assert_equals(msg.data.lineno, 19); }); + eventLineTest.done(); + eventMessageTest.step(function() { assert_equals(msg.data.message, "Error: workerhello"); }); + eventMessageTest.done(); + } else { + callbackFileTest.step(function() { assert_equals(msg.data.filename, workerLocation); }); + callbackFileTest.done(); + callbackLineTest.step(function() { assert_equals(msg.data.lineno, 19); }); + callbackLineTest.done(); + callbackMessageTest.step(function() { assert_equals(msg.data.message, "Error: workerhello"); }); + callbackMessageTest.done(); + } + }); +</script> |