summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/semantics/reporting-errors
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/workers/semantics/reporting-errors')
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/001.html53
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/002.html59
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/003.html39
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html18
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/004.html39
5 files changed, 208 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/001.html b/testing/web-platform/tests/workers/semantics/reporting-errors/001.html
new file mode 100644
index 000000000..adba81f63
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/001.html
@@ -0,0 +1,53 @@
+<!--
+var port;
+var timeout;
+onerror = function(a,b,c,d,e) {
+ // will return undefined, thus the error is "not handled"
+ // so error should be reported to the user, but this test doesn't check
+ // that.
+ // just make sure that this method is invoked with five arguments
+ clearTimeout(timeout);
+ var log = '';
+ if (arguments.length != 5)
+ log += 'got ' + arguments.length + ' arguments, expected 5. ';
+ if (typeof a != 'string')
+ log += 'first argument wasn\'t a string. ';
+ if (b != location.href)
+ log += 'second argument was ' + b + ', expected ' + location.href + '. ';
+ if (typeof c != 'number')
+ log += 'third argument wasn\'t a number. ';
+ if (typeof d != 'number')
+ log += 'fourth argument wasn\'t a number. ';
+ if (e != 42)
+ log += 'fifth argument wasn\'t the thrown exception. ';
+ port.postMessage(log);
+}
+onconnect = function (e) {
+ port = e.ports[0];
+ timeout = setTimeout(function() { port.postMessage('self.onerror was not invoked'); }, 250);
+ throw 42; // will "report the error"
+}
+
+
+/*
+-->
+<!doctype html>
+<title>shared worker, not handled</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+setup({allow_uncaught_exception:true});
+async_test(function() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, '');
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/002.html b/testing/web-platform/tests/workers/semantics/reporting-errors/002.html
new file mode 100644
index 000000000..c2cd377b4
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/002.html
@@ -0,0 +1,59 @@
+<!--
+var port;
+var timeout;
+addEventListener('error', function(e) {
+ // event is not canceled, thus the error is "not handled"
+ // so error should be reported to the user, but this test doesn't check
+ // that.
+ // just make sure that this event has the right properties
+ clearTimeout(timeout);
+ var log = '';
+ if (!self.ErrorEvent || Object.getPrototypeOf(e) != ErrorEvent.prototype)
+ log += 'event should be an ErrorEvent. ';
+ if (e.bubbles)
+ log += 'event should not bubble. ';
+ if (!e.cancelable)
+ log += 'event should be cancelable. ';
+ if (!e.isTrusted)
+ log += 'event should be trusted. ';
+ if (typeof e.message != 'string')
+ log += 'message wasn\'t a string. ';
+ if (e.filename != location.href)
+ log += 'filename was ' + e.filename + ', expected ' + location.href + '. ';
+ if (typeof e.lineno != 'number')
+ log += 'lineno wasn\'t a number. ';
+ if (typeof e.colno != 'number')
+ log += 'colno argument wasn\'t a number. ';
+ if (e.error != 42)
+ log += 'fifth argument wasn\'t the thrown exception. ';
+ port.postMessage(log);
+}, false);
+onconnect = function (e) {
+ port = e.ports[0];
+ timeout = setTimeout(function() { port.postMessage('No error event fired'); }, 250);
+ throw 42; // will "report the error"
+}
+
+
+/*
+-->
+<!doctype html>
+<title>shared worker, addEventListener</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+setup({allow_uncaught_exception:true});
+async_test(function() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, '');
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/003.html b/testing/web-platform/tests/workers/semantics/reporting-errors/003.html
new file mode 100644
index 000000000..1b01c7caf
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/003.html
@@ -0,0 +1,39 @@
+<!--
+onconnect = function (e) {
+ setTimeout(function() { e.ports[0].postMessage(''); }, 250);
+ y(); // will "report the error"
+ // onerror is null so it'll be "not handled", and the error should be
+ // reported to the user, although we don't test that here
+ // make sure we don't fire an error event on the message port or the
+ // SharedWorker object
+}
+
+
+/*
+-->
+<!doctype html>
+<title>shared worker, no error event on worker or port</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+setup({allow_uncaught_exception:true});
+async_test(function() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('error on worker');
+ }), false);
+ worker.port.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('error on port');
+ }), false);
+ worker.port.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, '');
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html b/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html
new file mode 100644
index 000000000..676c21e60
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<script>
+parent.t.step(function() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('(inner) window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('004.html#', '');
+ worker.addEventListener('error', this.step_func(function(e) {
+ parent.assert_unreached('(inner) error on worker');
+ }), false);
+ worker.port.addEventListener('error', this.step_func(function(e) {
+ parent.assert_unreached('(inner) error on port');
+ }), false);
+ worker.port.onmessage = this.step_func_done(function(e) {
+ parent.assert_equals(e.data, 2);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/004.html b/testing/web-platform/tests/workers/semantics/reporting-errors/004.html
new file mode 100644
index 000000000..1dd1eb3b5
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/004.html
@@ -0,0 +1,39 @@
+<!--
+var i = 0;
+onconnect = function (e) {
+ i++;
+ setTimeout(function() { e.ports[0].postMessage(i); }, 250);
+ y(); // will "report the error"
+}
+
+/*
+-->
+<!doctype html>
+<title>shared worker in two documents and window.onerror</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+setup({allow_uncaught_exception:true});
+var t = async_test(function() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('(outer) window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('(outer) error on worker');
+ }), false);
+ worker.port.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('(outer) error on port');
+ }), false);
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 1);
+ var iframe = document.createElement('iframe');
+ iframe.src = '004-1.html';
+ document.body.appendChild(iframe);
+ });
+});
+</script>
+<!--
+*/
+//-->