Truly independent web browser
Tests/LibWeb: Import WPT tests for script compile error reporting
Andreas Kling7c35595a6d33
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error-data-url.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error-data-url.txtnew file mode 100644index 00000000000..ab24c0fb7f4--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error-data-url.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail <body onerror> - compile error in <script src=data:...>+Pass <body onerror> - compile error in <script src=data:...> (column)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error.txtnew file mode 100644index 00000000000..469c186fef2--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail <body onerror> - compile error in <script>+Pass <body onerror> - compile error in <script> (column)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-data-url.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-data-url.txtnew file mode 100644index 00000000000..9ff6b63f945--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-data-url.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail window.onerror - compile error in <script src=data:...>+Pass window.onerror - compile error in <script src=data:...> (column)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setInterval.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setInterval.txtnew file mode 100644index 00000000000..7058c0b38c5--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setInterval.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail window.onerror - compile error in setInterval+Pass window.onerror - compile error in setInterval (column)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setTimeout.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setTimeout.txtnew file mode 100644index 00000000000..b8095cd0266--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setTimeout.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail window.onerror - compile error in setTimeout+Pass window.onerror - compile error in setTimeout (column)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-same-origin.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-same-origin.txtnew file mode 100644index 00000000000..ec2aebb68dd--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-same-origin.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail window.onerror - compile error in <script src=...>+Pass window.onerror - compile error in <script src=...> (column)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error.txtnew file mode 100644index 00000000000..5ad2bbac6dc--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/compile-error.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Fail window.onerror - compile error in <script>+Pass window.onerror - compile error in <script> (column)\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/window-onerror-parse-error.txt b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/window-onerror-parse-error.txtnew file mode 100644index 00000000000..fd30cf00c80--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/webappapis/scripting/processing-model-2/window-onerror-parse-error.txt@@ -0,0 +1,9 @@+Harness status: OK++Found 3 tests++1 Pass+2 Fail+Fail correct url passed to window.onerror+Fail correct line number passed to window.onerror+Pass correct number of calls to window.onerror\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error-data-url.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error-data-url.htmlnew file mode 100644index 00000000000..087666101c4--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error-data-url.html@@ -0,0 +1,37 @@+<!doctype html>+<html>+ <head>+ <title><body onerror> - compile error in <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 colno, '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>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error.htmlnew file mode 100644index 00000000000..169c9088382--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/body-onerror-compile-error.html@@ -0,0 +1,39 @@+<!doctype html>+<html>+ <head>+ <title><body onerror> - compile error in <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 colno, '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>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-data-url.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-data-url.htmlnew file mode 100644index 00000000000..1e4c386ade7--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-data-url.html@@ -0,0 +1,36 @@+<!doctype html>+<html>+ <head>+ <title>window.onerror - compile error in <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>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setInterval.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setInterval.htmlnew file mode 100644index 00000000000..25abc08f306--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setInterval.html@@ -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);+ step_timeout(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>\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setTimeout.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setTimeout.htmlnew file mode 100644index 00000000000..02c0d4da2f5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-in-setTimeout.html@@ -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>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-same-origin.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-same-origin.htmlnew file mode 100644index 00000000000..49289b713f3--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error-same-origin.html@@ -0,0 +1,36 @@+<!doctype html>+<html>+ <head>+ <title>window.onerror - compile error in <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>\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error.htmlnew file mode 100644index 00000000000..d5714a43d91--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/compile-error.html@@ -0,0 +1,38 @@+<!doctype html>+<html>+ <head>+ <title>window.onerror - compile error in <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>\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/support/syntax-error.js b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/support/syntax-error.jsnew file mode 100644index 00000000000..0f74a6fca63--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/support/syntax-error.js@@ -0,0 +1 @@+for (;) {}\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/window-onerror-parse-error.html b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/window-onerror-parse-error.htmlnew file mode 100644index 00000000000..73d32f49081--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/webappapis/scripting/processing-model-2/window-onerror-parse-error.html@@ -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>