2014-02-22 21:01:12 -08:00
|
|
|
<!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>
|
|
|
|
var errorEvent;
|
|
|
|
var file;
|
|
|
|
var line;
|
|
|
|
var msg;
|
2014-03-20 08:46:29 -07:00
|
|
|
var column;
|
|
|
|
var error;
|
2014-02-22 21:01:12 -08:00
|
|
|
window.addEventListener("error", function errorListener(e) {
|
|
|
|
window.removeEventListener("error", errorListener);
|
|
|
|
errorEvent = e;
|
|
|
|
});
|
|
|
|
var oldOnerror = window.onerror;
|
2014-03-20 08:46:29 -07:00
|
|
|
window.onerror = function(message, filename, lineno, columnno, errorObject) {
|
2014-02-22 21:01:12 -08:00
|
|
|
window.onerror = oldOnerror;
|
|
|
|
file = filename;
|
|
|
|
line = lineno;
|
|
|
|
msg = message;
|
2014-03-20 08:46:29 -07:00
|
|
|
column = columnno;
|
|
|
|
error = errorObject;
|
2014-02-22 21:01:12 -08:00
|
|
|
}
|
2014-03-20 08:46:29 -07:00
|
|
|
var thrown = new Error("hello");
|
|
|
|
throw thrown;
|
2014-02-22 21:01:12 -08:00
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
generate_tests(assert_equals, [
|
|
|
|
[ "Event filename", errorEvent.filename, location.href ],
|
|
|
|
[ "Callback filename", file, location.href ],
|
2014-03-20 08:46:29 -07:00
|
|
|
[ "Event line number", errorEvent.lineno, 27 ],
|
|
|
|
[ "Callback line number", line, 27 ],
|
2014-02-22 21:01:12 -08:00
|
|
|
[ "Event message", errorEvent.message, "Error: hello" ],
|
2014-03-20 08:46:29 -07:00
|
|
|
[ "Callback message", msg, "Error: hello" ],
|
|
|
|
[ "Event error-object", errorEvent.error, thrown],
|
|
|
|
[ "Callback error-object", error, thrown ],
|
2014-06-20 10:09:00 -07:00
|
|
|
[ "Event column", errorEvent.colno, 15 ],
|
|
|
|
[ "Callback column", column, 15 ]
|
2014-02-22 21:01:12 -08:00
|
|
|
]);
|
|
|
|
</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, 15); });
|
|
|
|
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, 15); });
|
|
|
|
callbackLineTest.done();
|
|
|
|
callbackMessageTest.step(function() { assert_equals(msg.data.message, "Error: workerhello"); });
|
|
|
|
callbackMessageTest.done();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|