Skip to content

Commit

Permalink
Add test for OnErrorEventHandler special case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm authored and Ms2ger committed Nov 17, 2015
1 parent 5b042b7 commit 8ee5fef
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
56 changes: 56 additions & 0 deletions html/webappapis/scripting/events/onerroreventhandler-frame.html
@@ -0,0 +1,56 @@
<body></body>
<script>
function check1(args, callee) {
parent.t.step(function() {
parent.assert_equals(callee.length, 5);
parent.assert_equals(args.length, 5);
parent.assert_equals(args[0], reference_error.message);
parent.assert_equals(args[1], reference_error.filename);
parent.assert_equals(args[2], reference_error.lineno);
parent.assert_equals(args[3], reference_error.colno);
parent.assert_equals(args[4], reference_error.error);
parent.t.done();
});
}

var reference_error = new ErrorEvent("error", {
filename: "error_file.js",
lineno: 333,
colno: 999,
message: "there was an error",
error: {nondefault: 'some unusual object'},
});

parent.t.step(function() {
document.body.outerHTML = "<body onerror='check1(arguments, arguments.callee)'></body>"
window.dispatchEvent(reference_error);
});

function check2(args, callee) {
parent.t2.step(function() {
parent.assert_equals(callee.length, 5);
parent.assert_equals(args.length, 1);
parent.assert_false(args[0] instanceof ErrorEvent);
parent.t2.done()
});
}

parent.t2.step(function() {
document.body.outerHTML = "<body onerror='check2(arguments, arguments.callee)'></body>"
window.dispatchEvent(new Event("error"));
});

function check3(args, callee) {
parent.t3.step(function() {
parent.assert_equals(args.length, 1);
parent.assert_equals(callee.length, 1);
});
}

parent.t3.step(function() {
document.body.outerHTML = "<body><span onerror='check3(arguments, arguments.callee)'></span></body>"
document.body.firstChild.dispatchEvent(reference_error);
document.body.firstChild.dispatchEvent(new Event("error"));
parent.t3.done();
});
</script>
11 changes: 11 additions & 0 deletions html/webappapis/scripting/events/onerroreventhandler.html
@@ -0,0 +1,11 @@
<!doctype html>
<meta charset=utf-8>
<title>OnErrorEventHandler + ErrorEvent is treated differently</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
var t = async_test("onerror + ErrorEvent + Window");
var t2 = async_test("onerror + !ErrorEvent + Window");
var t3 = async_test("onerror + Document");
</script>
<iframe src="onerroreventhandler-frame.html"></iframe>

0 comments on commit 8ee5fef

Please sign in to comment.