summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/semantics/reporting-errors/002.html
blob: c2cd377b435d8bb39dc6381301d180d84d1da4da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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>
<!--
*/
//-->