9 function print(message, color)
11 var paragraph = document.createElement("div");
12 paragraph.appendChild(document.createTextNode(message));
13 paragraph.style.fontFamily = "monospace";
15 paragraph.style.color = color;
16 document.getElementById("console").appendChild(paragraph);
19 function shouldBe(a, b)
28 print("FAIL: " + a + " should be " + b + " but instead is " + evalA, "red");
33 if (window.testRunner)
34 testRunner.dumpAsText();
36 domParser = new DOMParser();
37 shouldBe("DOMParser.prototype.isPrototypeOf(domParser)", true);
39 xmlHttpRequest = new XMLHttpRequest();
40 shouldBe("XMLHttpRequest.prototype.isPrototypeOf(xmlHttpRequest)", true);
42 xmlSerializer = new XMLSerializer();
43 shouldBe("XMLSerializer.prototype.isPrototypeOf(xmlSerializer)", true);
45 xsltProcessor = new XSLTProcessor();
46 shouldBe("XSLTProcessor.prototype.isPrototypeOf(xsltProcessor)", true);
48 shouldBe("window.Document.prototype.isPrototypeOf(document)", true);
49 shouldBe("window.HTMLDocument.prototype.isPrototypeOf(document)", true);
51 element = document.body;
52 shouldBe("window.Node.prototype.isPrototypeOf(element)", true);
53 shouldBe("window.Element.prototype.isPrototypeOf(element)", true);
54 shouldBe("window.HTMLElement.prototype.isPrototypeOf(element)", true);
56 range = document.createRange();
57 shouldBe("window.Range.prototype.isPrototypeOf(range)", true);
59 cssRule = document.styleSheets[0].cssRules[0];
60 shouldBe("window.CSSRule.prototype.isPrototypeOf(cssRule)", true);
62 cssPrimitiveValue = cssRule.style.getPropertyCSSValue("color");
63 shouldBe("window.CSSValue.prototype.isPrototypeOf(cssPrimitiveValue)", true);
64 shouldBe("window.CSSPrimitiveValue.prototype.isPrototypeOf(cssPrimitiveValue)", true);
66 cssStyleDeclaration = cssRule.style;
67 shouldBe("window.CSSStyleDeclaration.prototype.isPrototypeOf(cssStyleDeclaration)", true);
69 event = document.createEvent("MutationEvents");
70 shouldBe("window.Event.prototype.isPrototypeOf(event)", true);
71 shouldBe("window.MutationEvent.prototype.isPrototypeOf(event)", true);
73 xmldoc = document.implementation.createDocument(null, null, null);
74 shouldBe("window.XMLDocument.prototype.isPrototypeOf(xmldoc)", true);
76 fragment = document.createDocumentFragment();
77 shouldBe("window.DocumentFragment.prototype.isPrototypeOf(fragment)", true);
79 xpathevaluator = new XPathEvaluator();
80 shouldBe("window.XPathEvaluator.prototype.isPrototypeOf(xpathevaluator)", true);
82 xpathresult = xpathevaluator.evaluate('/', document, null, 0, null);
83 shouldBe("window.XPathResult.prototype.isPrototypeOf(xpathresult)", true);
86 nodeFilter = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, function () {}, false).filter;
88 shouldBe("window.NodeFilter.prototype.isPrototypeOf(nodeFilter)", true);
90 originalNodePrototype = window.Node.prototype;
92 delete window.Node.prototype;
93 print("[Deleted window.Node.prototype]");
94 shouldBe("window.Node.prototype", originalNodePrototype);
96 originalNodeConstructor = window.Node;
100 print("[Set window.Node = 1]");
101 shouldBe("window.Node", 1);
103 // Unshadow window.Node
105 print("[Deleted window.Node]");
106 shouldBe("window.Node", originalNodeConstructor);
108 // Attempt to shadow window.Node with a frame named 'Node'
109 var iframe = document.createElement('iframe');
110 iframe.setAttribute('name', "Node");
111 document.body.appendChild(iframe);
112 print("[Added an iframe named 'Node']");
113 shouldBe("window.Node", originalNodeConstructor);
119 <body onload="test();">
120 <p>This page tests global constructor objects like window.HTMLDocument. If it passes, you'll
121 see no lines with the text FAIL below.
124 <div id='console'></div>