2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 function shouldBe(a, b)
35 if (evalA == b || isNaN(evalA) && typeof evalA == 'number' && isNaN(b) && typeof b == 'number')
36 print("PASS: " + a + " should be " + b + " and is.", "green");
38 print("__FAIL__: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
43 print("Node is " + Node);
45 print(p + ": " + Node[p]);
48 print("node is " + node);
50 print(p + ": " + node[p]);
56 node.appendChild(child1);
57 node.appendChild(child2);
59 var childNodes = node.childNodes;
61 for (var i = 0; i < childNodes.length + 1; i++) {
62 print("item " + i + ": " + childNodes.item(i));
65 for (var i = 0; i < childNodes.length + 1; i++) {
66 print(i + ": " + childNodes[i]);
69 node.removeChild(child1);
70 node.replaceChild(child3, child2);
72 for (var i = 0; i < childNodes.length + 1; i++) {
73 print("item " + i + ": " + childNodes.item(i));
76 for (var i = 0; i < childNodes.length + 1; i++) {
77 print(i + ": " + childNodes[i]);
81 node.appendChild(null);
83 print("caught: " + e);
88 o.appendChild = node.appendChild;
91 print("caught: " + e);
97 print("caught: " + e);
100 oldNodeType = node.nodeType;
102 shouldBe("node.nodeType", oldNodeType);
104 shouldBe("node instanceof Node", true);
105 shouldBe("new Object() instanceof Node", false);