summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/htmlcollection-conversion-throws-exception.html
blob: deffb06ab513c9668677bd2d8ef2f111e8cb9c7e (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
<html>
<head>
<script>
  function test() {
    alert(
    'This test verifies that exception thrown while converting an object to string '
    + 'are correctly propagated and do not crash the browser.');

    if (window.testRunner) {
      testRunner.dumpAsText();
    }

    var throwing = { toString: function() { throw 'EXCEPTION'; } };
    try {
      document.images.item(throwing);
      alert('FAIL: document.images.item(throwing) should have thrown an exception!');
    } catch (e) {
      alert('OK: ' + e);
    }
    try {
      document.images[throwing];
      alert('FAIL: document.images[throwing] should have thrown an exception!');
    } catch (e) {
      alert('OK: ' + e);
    }
  }
</script>
</head>
<body onload='test()'>
</body>
</html>