Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,14 @@
[
{
"id": "definitions-1",
"original_id": "definitions-1"
},
{
"id": "processing-model-3",
"original_id": "processing-model-3"
},
{
"id": "generic-task-sources",
"original_id": "generic-task-sources"
}
]

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<title>HTMLBodyElement.onload</title>
<link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu">
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#handler-window-onload">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test("body.onload should set the window.onload handler")
window.onload = t.step_func(function() {
assert_unreached("This handler should be overwritten.")
})
var b = document.createElement("body")
b.onload = t.step_func(function(e) {
assert_equals(e.currentTarget, window,
"The event should be fired at the window.")
t.done()
})
</script>

View file

@ -0,0 +1,18 @@
[
{
"id": "event-handler-attributes",
"original_id": "event-handler-attributes"
},
{
"id": "event-handlers-on-elements-document-objects-and-window-objects",
"original_id": "event-handlers-on-elements,-document-objects,-and-window-objects"
},
{
"id": "event-firing",
"original_id": "event-firing"
},
{
"id": "events-and-the-window-object",
"original_id": "events-and-the-window-object"
}
]

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<title>Event handler with labels</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body onload="javascript:
for (var i = 0; i < 2; ++i) {
for (var j = 0; j < 2; ++j) {
t.step(function() {
assert_equals(i, 0);
assert_equals(j, 0);
});
break javascript;
}
}
t.done();
">
<div id="log"></div>
<script>
var t = async_test("Event handlers starting with 'javascript:' should treat that as a label.");
</script>

View file

@ -0,0 +1,65 @@
<!DOCTYPE html>
<title>Event handler invocation order</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var objects = [{}, function() {}, new Number(42), new String()];
var primitives = [42, null, undefined, ""];
objects.forEach(function(object) {
var t = async_test("Event handler listeners should be registered when they " +
"are first set to an object value (" +
format_value(object) + ").");
t.step(function() {
var i = 0;
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
var button = document.createElement('button');
button.onclick = object; // event handler listener is registered here
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 2) }), false);
button.setAttribute('onclick', uncalled);
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
button.onclick = t.step_func(function () { assert_equals(++i, 1); });
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
button.click()
assert_equals(button.getAttribute("onclick"), uncalled)
assert_equals(i, 4);
t.done()
});
});
primitives.forEach(function(primitive) {
var t = async_test("Event handler listeners should be registered when they " +
"are first set to an object value (" +
format_value(primitive) + ").");
t.step(function() {
var i = 0;
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
var button = document.createElement('button');
button.onclick = primitive;
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false);
button.setAttribute('onclick', uncalled); // event handler listener is registered here
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
button.onclick = t.step_func(function () { assert_equals(++i, 2); });
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
button.click()
assert_equals(button.getAttribute("onclick"), uncalled)
assert_equals(i, 4);
t.done()
});
});
var t = async_test("Event handler listeners should be registered when they " +
"are first set to an object value.");
t.step(function() {
var i = 0;
var uncalled = "t.step(function() { assert_unreached('First event handler.') })"
var button = document.createElement('button');
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 1) }), false);
button.setAttribute('onclick', uncalled); // event handler listener is registered here
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 3) }), false);
button.onclick = t.step_func(function () { assert_equals(++i, 2); });
button.addEventListener('click', t.step_func(function () { assert_equals(++i, 4) }), false);
button.click()
assert_equals(button.getAttribute("onclick"), uncalled)
assert_equals(i, 4);
t.done()
});
</script>

View file

@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<title>window.onerror - addEventListener</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var ran = false;
// spec doesn't say to fire an event so this should do nothing
window.addEventListener('error', t.step_func(function(e){
ran = true;
}), false);
</script>
<script>
undefined_variable;
</script>
<script>
for (;) {}
</script>
<script>
t.step(function(){
assert_false(ran, 'ran');
t.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,37 @@
<!doctype html>
<html>
<head>
<title>&lt;body onerror> - compile error in &lt;script src=data:...></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
</script>
<body onerror="
t.step(function(){
ran = true;
assert_equals(typeof event, 'string', 'first arg');
assert_equals(source, 'data:text/javascript,for(;){}', 'second arg');
assert_equals(typeof lineno, 'number', 'third arg');
});
t_col.step(function() {
assert_equals(typeof column, 'number', 'fourth arg');
});
">
<div id=log></div>
<script src="data:text/javascript,for(;){}"></script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>&lt;body onerror> - compile error in &lt;script></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
</script>
<body onerror="
t.step(function(){
ran = true;
assert_equals(typeof event, 'string', 'first arg');
assert_equals(source, location.href, 'second arg');
assert_equals(typeof lineno, 'number', 'third arg');
});
t_col.step(function() {
assert_equals(typeof column, 'number', 'fourth arg');
});
">
<div id=log></div>
<script>
for(;) {}
</script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>&lt;body onerror> - runtime error in &lt;script></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
</script>
<body onerror="
t.step(function(){
ran = true;
assert_equals(typeof event, 'string', 'first arg');
assert_equals(source, location.href, 'second arg');
assert_equals(typeof lineno, 'number', 'third arg');
});
t_col.step(function(){
assert_equals(typeof column, 'number', 'fourth arg');
});
">
<div id=log></div>
<script>
undefined_variable;
</script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in cross-origin setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
var interval;
window.onerror = t.step_func(function(a, b, c, d){
clearInterval(interval);
ran = true;
col_value = d;
assert_equals(a, 'Script error.', 'first arg');
assert_equals(b, '', 'second arg');
assert_equals(c, 0, 'third arg');
});
function col_check() {
assert_equals(col_value, 0, 'fourth arg');
t_col.done();
}
var script = document.createElement('script');
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/syntax-error-in-setInterval.js');
document.body.appendChild(script);
</script>
</body>
</html>

View file

@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in cross-origin setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(a, 'Script error.', 'first arg');
assert_equals(b, '', 'second arg');
assert_equals(c, 0, 'third arg');
});
function col_check() {
assert_equals(col_value, 0, 'fourth arg');
t_col.done();
}
var script = document.createElement('script');
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/syntax-error-in-setTimeout.js');
document.body.appendChild(script);
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in &lt;script src=//www1...></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(a, 'Script error.', 'first arg');
assert_equals(b, '', 'second arg');
assert_equals(c, 0, 'third arg');
});
var script = document.createElement('script');
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/syntax-error.js');
document.body.appendChild(script);
onload = function(){
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(col_value, 0, 'fourth arg');
t_col.done();
});
};
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in &lt;script src=data:...></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, 'data:text/javascript,for(;) {}', 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<script src="data:text/javascript,for(;) {}"></script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<p onclick="{"></p>
<script>
t.step(function(){
var ev = document.createEvent('Event');
ev.initEvent('click', false, false);
document.querySelector('p').dispatchEvent(ev);
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in &lt;body onerror></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var ran = false;
window.onerror = t.step_func(function(){
ran = true;
});
</script>
</head>
<body onerror="{"><!-- sets the event handler to null before compiling -->
<div id=log></div>
<script>
for(;) {}
</script>
<script>
t.step(function(){
assert_false(ran, 'ran');
t.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
var interval;
window.onerror = t.step_func(function(a, b, c, d){
clearInterval(interval);
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
interval = setInterval("{", 10);
setTimeout(function(){
t.step(function(){
clearInterval(interval);
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
}, 20);
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
setTimeout("{", 10);
setTimeout(function(){
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
}, 20);
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in &lt;script src=...></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, document.querySelector('script[src="support/syntax-error.js"]').src, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<script src="support/syntax-error.js"></script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>window.onerror - compile error in &lt;script></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<script>
for(;) {}
</script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
[
{
"id": "definitions-0",
"original_id": "definitions-0"
},
{
"id": "calling-scripts",
"original_id": "calling-scripts"
},
{
"id": "creating-scripts",
"original_id": "creating-scripts"
},
{
"id": "killing-scripts",
"original_id": "killing-scripts"
},
{
"id": "runtime-script-errors",
"original_id": "runtime-script-errors",
"children": [
{
"id": "runtime-script-errors-in-documents",
"original_id": "runtime-script-errors-in-documents"
}
]
}
]

View file

@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in cross-origin setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
var interval;
window.onerror = t.step_func(function(a, b, c, d){
clearInterval(interval);
ran = true;
col_value = d;
assert_equals(a, 'Script error.', 'first arg');
assert_equals(b, '', 'second arg');
assert_equals(c, 0, 'third arg');
});
function col_check() {
assert_equals(col_value, 0, 'fourth arg');
t_col.done();
}
var script = document.createElement('script');
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/undefined-variable-in-setInterval.js');
document.body.appendChild(script);
</script>
</body>
</html>

View file

@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in cross-origin setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(a, 'Script error.', 'first arg');
assert_equals(b, '', 'second arg');
assert_equals(c, 0, 'third arg');
});
function col_check() {
assert_equals(col_value, 0, 'fourth arg');
t_col.done();
}
var script = document.createElement('script');
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/undefined-variable-in-setTimeout.js');
document.body.appendChild(script);
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in &lt;script src=//www1...></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(a, 'Script error.', 'first arg');
assert_equals(b, '', 'second arg');
assert_equals(c, 0, 'third arg');
});
var script = document.createElement('script');
script.src = location.href.replace('://', '://www1.').replace(/\/[^\/]+$/, '/support/undefined-variable.js');
document.body.appendChild(script);
onload = function(){
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(col_value, 0, 'fourth arg');
t_col.done();
});
};
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in &lt;script src=data:...></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, 'data:text/javascript,undefined_variable;', 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<script src="data:text/javascript,undefined_variable;"></script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, number, 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<p onclick="undefined_variable;"></p>
<script>
t.step(function(){
var ev = document.createEvent('Event');
ev.initEvent('click', false, false);
document.querySelector('p').dispatchEvent(ev);
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,25 @@
<!doctype html>
<html>
<head>
<title>runtime error in &lt;body onerror></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var ran = 0;
</script>
</head>
<body onerror="ran++; undefined_variable_in_onerror;">
<div id=log></div>
<script>
undefined_variable;
</script>
<script>
t.step(function(){
assert_equals(ran, 1, 'ran');
t.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
var interval;
window.onerror = t.step_func(function(a, b, c, d){
clearInterval(interval);
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
interval = setInterval("undefined_variable;", 10);
setTimeout(function(){
clearInterval(interval);
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
}, 20);
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
setTimeout("undefined_variable;", 10);
setTimeout(function(){
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
}, 20);
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!doctype html>
<html>
<head>
<title>runtime error in window.onerror</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var ran = 0;
window.onerror = function(){
ran++;
undefined_variable_in_onerror;
};
</script>
<script>
undefined_variable;
</script>
<script>
t.step(function(){
assert_equals(ran, 1, 'ran');
t.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in &lt;script src=...></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, document.querySelector('script[src="support/undefined-variable.js"]').src, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<script src="support/undefined-variable.js"></script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>window.onerror - runtime error in &lt;script></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id=log></div>
<script>
setup({allow_uncaught_exception:true});
var t = async_test();
var t_col = async_test(document.title+' (column)');
var ran = false;
var col_value;
window.onerror = t.step_func(function(a, b, c, d){
ran = true;
col_value = d;
assert_equals(typeof a, 'string', 'first arg');
assert_equals(b, location.href, 'second arg');
assert_equals(typeof c, 'number', 'third arg');
});
</script>
<script>
undefined_variable;
</script>
<script>
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(function(){
assert_equals(typeof col_value, 'number', 'fourth arg');
t_col.done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,9 @@
interval = setInterval('{', 10);
setTimeout(function(){
clearInterval(interval);
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(col_check);
}, 20);

View file

@ -0,0 +1,8 @@
setTimeout('{', 10);
setTimeout(function(){
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(col_check);
}, 20);

View file

@ -0,0 +1,9 @@
interval = setInterval('undefined_variable;', 10);
setTimeout(function(){
clearInterval(interval);
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(col_check);
}, 20);

View file

@ -0,0 +1,8 @@
setTimeout('undefined_variable;', 10);
setTimeout(function(){
t.step(function(){
assert_true(ran, 'ran');
t.done();
});
t_col.step(col_check);
}, 20);

View file

@ -0,0 +1,40 @@
<!doctype html>
<html>
<head>
<title>window.onerror: parse errors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!--
In https://html.spec.whatwg.org/multipage/#creating-scripts ,
step 3 describes parsing the script, and step 5 says:
# Otherwise, report the error using the onerror event handler of
# the script's global object. If the error is still not handled
# after this, then the error may be reported to the user.
which links to
https://html.spec.whatwg.org/multipage/#report-the-error ,
which describes what to do when onerror is a Function.
-->
</head>
<body>
<div id="log"></div>
<script>
setup({allow_uncaught_exception:true});
var error_count = 0;
window.onerror = function(msg, url, lineno) {
++error_count;
test(function() {assert_equals(url, window.location.href)},
"correct url passed to window.onerror");
test(function() {assert_equals(lineno, 34)},
"correct line number passed to window.onerror");
};
</script>
<script>This script does not parse correctly.</script>
<script>
test(function() {assert_equals(error_count, 1)},
"correct number of calls to window.onerror");
</script>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>window.onerror: runtime scripterrors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!--
https://html.spec.whatwg.org/multipage/#runtime-script-errors
says what to do for uncaught runtime script errors, and just below
describes what to do when onerror is a Function.
-->
</head>
<body>
<div id="log"></div>
<script>
setup({allow_uncaught_exception:true});
var error_count = 0;
window.onerror = function(msg, url, lineno) {
++error_count;
};
</script>
<script>
try {
// This error is caught, so it should NOT trigger onerror.
throw "foo";
} catch (ex) {
}
// This error is NOT caught, so it should trigger onerror.
throw "bar";
</script>
<script>
test(function() {assert_equals(error_count, 1)},
"correct number of calls to window.onerror");
</script>
</body>
</html>

View file

@ -0,0 +1,43 @@
<!doctype html>
<html>
<head>
<title>window.onerror: runtime scripterrors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!--
https://html.spec.whatwg.org/multipage/#runtime-script-errors
says what to do for uncaught runtime script errors, and just below
describes what to do when onerror is a Function.
-->
</head>
<body>
<div id="log"></div>
<script>
setup({allow_uncaught_exception:true});
var error_count = 0;
window.onerror = function(msg, url, lineno) {
++error_count;
test(function() {assert_equals(url, window.location.href)},
"correct url passed to window.onerror");
test(function() {assert_equals(lineno, 36)},
"correct line number passed to window.onerror");
};
</script>
<script>
try {
// This error is caught, so it should NOT trigger onerror.
window.nonexistentproperty.oops();
} catch (ex) {
}
// This error is NOT caught, so it should trigger onerror.
window.nonexistentproperty.oops();
</script>
<script>
test(function() {assert_equals(error_count, 1)},
"correct number of calls to window.onerror");
</script>
</body>
</html>