blob: 523c63fd7a55228c31ce041514b500806667fdbe [file] [log] [blame]
<html>
<head>
<style>
* {
color: black;
}
</style>
<script>
function print(message, color)
{
var paragraph = document.createElement("div");
paragraph.appendChild(document.createTextNode(message));
paragraph.style.fontFamily = "monospace";
if (color)
paragraph.style.color = color;
document.getElementById("console").appendChild(paragraph);
}
function shouldBe(a, b)
{
var evalA;
try {
evalA = eval(a);
} catch(e) {
evalA = e;
}
if (evalA == b)
print("PASS: " + a + " should be " + b + " and is.", "green");
else
print("FAIL: " + a + " should be " + b + " but instead is " + evalA, "red");
}
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
domParser = new DOMParser();
shouldBe("DOMParser.prototype.isPrototypeOf(domParser)", true);
xmlHttpRequest = new XMLHttpRequest();
shouldBe("XMLHttpRequest.prototype.isPrototypeOf(xmlHttpRequest)", true);
xmlSerializer = new XMLSerializer();
shouldBe("XMLSerializer.prototype.isPrototypeOf(xmlSerializer)", true);
xsltProcessor = new XSLTProcessor();
shouldBe("XSLTProcessor.prototype.isPrototypeOf(xsltProcessor)", true);
shouldBe("window.Document.prototype.isPrototypeOf(document)", true);
shouldBe("window.HTMLDocument.prototype.isPrototypeOf(document)", true);
element = document.body;
shouldBe("window.Node.prototype.isPrototypeOf(element)", true);
shouldBe("window.Element.prototype.isPrototypeOf(element)", true);
shouldBe("window.HTMLElement.prototype.isPrototypeOf(element)", true);
range = document.createRange();
shouldBe("window.Range.prototype.isPrototypeOf(range)", true);
cssRule = document.styleSheets[0].cssRules[0];
shouldBe("window.CSSRule.prototype.isPrototypeOf(cssRule)", true);
cssPrimitiveValue = cssRule.style.getPropertyCSSValue("color");
shouldBe("window.CSSValue.prototype.isPrototypeOf(cssPrimitiveValue)", true);
shouldBe("window.CSSPrimitiveValue.prototype.isPrototypeOf(cssPrimitiveValue)", true);
cssStyleDeclaration = cssRule.style;
shouldBe("window.CSSStyleDeclaration.prototype.isPrototypeOf(cssStyleDeclaration)", true);
event = document.createEvent("MutationEvents");
shouldBe("window.Event.prototype.isPrototypeOf(event)", true);
shouldBe("window.MutationEvent.prototype.isPrototypeOf(event)", true);
xmldoc = document.implementation.createDocument(null, null, null);
shouldBe("window.XMLDocument.prototype.isPrototypeOf(xmldoc)", true);
fragment = document.createDocumentFragment();
shouldBe("window.DocumentFragment.prototype.isPrototypeOf(fragment)", true);
xpathevaluator = new XPathEvaluator();
shouldBe("window.XPathEvaluator.prototype.isPrototypeOf(xpathevaluator)", true);
xpathresult = xpathevaluator.evaluate('/', document, null, 0, null);
shouldBe("window.XPathResult.prototype.isPrototypeOf(xpathresult)", true);
try {
nodeFilter = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, function () {}, false).filter;
} catch(e) {}
shouldBe("window.NodeFilter.prototype.isPrototypeOf(nodeFilter)", true);
delete window.Node.prototype;
print("[Deleted window.Node.prototype]");
shouldBe("window.Node.prototype", undefined);
originalNodeConstructor = window.Node;
// Shadow window.Node
window.Node = 1;
print("[Set window.Node = 1]");
shouldBe("window.Node", 1);
// Unshadow window.Node
delete window.Node;
print("[Deleted window.Node]");
shouldBe("window.Node", originalNodeConstructor);
// Attempt to shadow window.Node with a frame named 'Node'
var iframe = document.createElement('iframe');
iframe.setAttribute('name', "Node");
document.body.appendChild(iframe);
print("[Added an iframe named 'Node']");
shouldBe("window.Node", originalNodeConstructor);
}
</script>
</head>
<body onload="test();">
<p>This page tests global constructor objects like window.HTMLDocument. If it passes, you'll
see a series of 'PASS' messages below.
</p>
<hr>
<div id='console'></div>
</body>
</html>