Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / incompatible-operations.html
blob7263ecc0913e19019717c73f3077d319eceff367
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 </head>
5 <body>
7 <script>
8 description('This test checks the behavior of DOM operations when called on non-DOM or incompatible receivers with non-DOM or incompatible arguments.');
10 function trySuspect(fun) {
11 try {
12 result = fun();
13 return '' + result;
14 } catch (e) {
15 return 'threw ' + e;
19 function check(a, b) {
20 return 1;
23 var aDOMImplementation = document.implementation;
25 var aSelect = document.createElement("select");
26 var anOption = document.createElement("option");
27 var aNode = document.createElement("div");
28 var aSecondNode = document.createElement("div");
29 aNode.appendChild(aSecondNode);
31 shouldThrow("aNode.appendChild(aDOMImplementation)", '"TypeError: Failed to execute \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'."');
33 shouldThrow("aNode.appendChild('knort')", '"TypeError: Failed to execute \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'."');
35 shouldThrow("aNode.appendChild(void 0)", '"TypeError: Failed to execute \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'."');
37 shouldThrow("aNode.isSameNode(aDOMImplementation)");
38 shouldThrow("aNode.isSameNode('foo')");
39 shouldBeFalse("aNode.isSameNode(void 0)");
40 shouldBe("aNode.lookupPrefix(aDOMImplementation)", "null");
41 shouldBe("aNode.lookupPrefix(void 0)", "null");
42 shouldBeTrue("aNode.cloneNode(aDOMImplementation) instanceof HTMLDivElement");
43 shouldThrow("aSelect.add(aDOMImplementation, aDOMImplementation)");
44 shouldThrow("aSelect.add(aDOMImplementation, anOption)");
45 shouldThrow("aSelect.add(void 0, void 0)");
46 shouldThrow("aSelect.add(void 0, anOption)");
47 shouldBeUndefined("aSelect.add(anOption, aDOMImplementation)");
48 shouldBeUndefined("aSelect.add(anOption, void 0)");
49 </script>
50 </body>
51 </html>