summaryrefslogtreecommitdiffstats
path: root/dom/bindings/test/test_exception_messages.html
blob: a0f0cabe63a2cf57badddda3780ae27fae87d32a (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=882653
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 882653</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">

  /** Test for Bug 882653 **/
  // Each test is a string to eval, the expected exception message, and the
  // test description.
  var tests = [
      [ 'document.documentElement.appendChild.call({}, new Image())',
        "'appendChild' called on an object that does not implement interface Node.",
        "bogus method this object" ],
      [ 'Object.getOwnPropertyDescriptor(Document.prototype, "documentElement").get.call({})',
        "'get documentElement' called on an object that does not implement interface Document.",
        "bogus getter this object" ],
      [ 'Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML").set.call({})',
        "'set innerHTML' called on an object that does not implement interface Element.",
        "bogus setter this object" ],
      [ 'document.documentElement.appendChild(5)',
        "Argument 1 of Node.appendChild is not an object.",
        "bogus interface argument" ],
      [ 'document.documentElement.appendChild(null)',
        "Argument 1 of Node.appendChild is not an object.",
        "null interface argument" ],
      [ 'document.createTreeWalker(document).currentNode = 5',
        "Value being assigned to TreeWalker.currentNode is not an object.",
        "interface setter call" ],
      [ 'document.documentElement.appendChild({})',
        "Argument 1 of Node.appendChild does not implement interface Node.",
        "wrong interface argument" ],
      [ 'document.createTreeWalker(document).currentNode = {}',
        "Value being assigned to TreeWalker.currentNode does not implement interface Node.",
        "wrong interface setter call" ],
      [ 'document.createElement("canvas").getContext("2d").fill("bogus")',
        "Argument 1 of CanvasRenderingContext2D.fill 'bogus' is not a valid value for enumeration CanvasWindingRule.",
        "bogus enum value" ],
      [ 'document.createTreeWalker(document, 0xFFFFFFFF, { acceptNode: 5 }).nextNode()',
        "Property 'acceptNode' is not callable.",
        "non-callable callback interface operation property" ],
      [ '(new TextDecoder).decode(new Uint8Array(), new RegExp())',
        "Argument 2 of TextDecoder.decode can't be converted to a dictionary.",
        "regexp passed for a dictionary" ],
      [ 'URL.createObjectURL(null, null)',
        "Argument 1 is not valid for any of the 2-argument overloads of URL.createObjectURL.",
        "overload resolution failure" ],
      [ 'document.createElement("select").add({})',
        "Argument 1 of HTMLSelectElement.add could not be converted to any of: HTMLOptionElement, HTMLOptGroupElement.",
        "invalid value passed for union" ],
      [ 'document.createElement("canvas").getContext("2d").createLinearGradient(0, 1, 0, 1).addColorStop(NaN, "")',
        "Argument 1 of CanvasGradient.addColorStop is not a finite floating-point value.",
        "invalid float" ]
  ];

  for (var i = 0; i < tests.length; ++i) {
      msg = "Correct exception should be thrown for " + tests[i][2];
      try {
          eval(tests[i][0]);
          ok(false, msg);
      } catch (e) {
          is(e.message, tests[i][1], msg);
      }
  }

  </script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=882653">Mozilla Bug 882653</a>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
</pre>
</body>
</html>