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/tests/mochitest/bugs/test_onerror_message.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 '')
-rw-r--r-- | dom/tests/mochitest/bugs/test_onerror_message.html | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/dom/tests/mochitest/bugs/test_onerror_message.html b/dom/tests/mochitest/bugs/test_onerror_message.html new file mode 100644 index 0000000000..476c02d978 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_onerror_message.html @@ -0,0 +1,97 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=743049 +--> +<head> + <meta charset="UTF-8"> + <title>Test for Bug 743049</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=743049">Mozilla Bug 743049</a> +<p id="display"></p> +<div id="content" style="display: none"> + <iframe id="frame"></iframe> +</div> +<pre id="test"> +<script type="application/javascript"> +"use strict"; + +/** Test for Bug 743049 **/ + +var expected = [ +{ name: "Error", message: "foo", filename: String(location), lineNumber: 45 }, +{ name: "Error", message: "foo", filename: "bar", lineNumber: 123 }, +{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 }, +{ name: "DuckError", message: "foo", filename: "bar", lineNumber: 123 }, +{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 }, +{ name: "", message: "foo", filename: "baz", lineNumber: 123 }, +{ name: "", message: "uncaught exception: [object Object]", filename: location.href, lineNumber: 80 }, +{ name: "InvalidStateError", message: "XMLHttpRequest.responseType setter: Cannot set 'responseType' property on XMLHttpRequest after 'send()' (when its state is LOADING or DONE).", filename: String(location), lineNumber: 62 }, +{ name: "ReferenceError", message: "xxx is not defined", filename: String(location), lineNumber: 64 }, +{ name: "ReferenceError", message: "xxx is not defined", filename: String(location), lineNumber: 66 } +]; + +var counter = 0; +var origin = location.protocol + "//" + location.host; +postMessage(counter, origin); +window.onmessage = function(e) { + if (e.origin !== origin) + return; + try { + if (e.data == 0) { + throw new Error("foo"); + } else if (e.data == 1) { + throw new Error("foo","bar",123); + } else if (e.data == 2) { + throw {}; + } else if (e.data == 3) { + throw {name:"DuckError",message:"foo",filename:"bar",lineNumber:123}; + } else if (e.data == 4) { + throw {name:"DuckError",filename:"bar",lineNumber:123}; + } else if (e.data == 5) { + throw {message:"foo",fileName:"baz",lineNumber:123}; + } else if (e.data == 6) { + throw {name:3,message:4,lineNumber:123}; + } else if (e.data == 7) { + var x = new XMLHttpRequest(); + x.open("GET", location, false); + var a = x.send(); + x.responseType = "arraybuffer"; + } else if (e.data == 8) { + throw new ReferenceError("xxx is not defined"); + } else if (e.data == 9) { + new xxx; + } else { + SimpleTest.finish(); + return; + } + } catch (e) { + if (e instanceof Error || typeof e.message=="string" && + ("filename" in e || "fileName" in e) && "lineNumber" in e) { + is(e.message, expected[counter].message, counter + " catch message"); + is(e.filename || e.fileName, expected[counter].filename, counter + " catch filename"); + is(e.lineNumber, expected[counter].lineNumber, counter + " catch lineno"); + } else { + is("uncaught exception: " + e, expected[counter].message, counter + " catch message"); + } + throw e; + } + ok(false, counter + " Error should be thrown or test should finish"); +}; +window.onerror = function(message, filename, lineno) { + is(message, Error.prototype.toString.call(expected[counter]), counter + " onerror message"); + is(filename, expected[counter].filename, counter + " onerror filename"); + is(lineno, expected[counter].lineNumber, counter + " onerror lineno"); + postMessage(++counter, origin); + return true; +}; + +SimpleTest.waitForExplicitFinish(); + +</script> +</pre> +</body> +</html> |