blob: b226a0d8488958ba83ebb97ea5cfcf11aaefd56c [file] [log] [blame]
<html>
<head>
<link rel="stylesheet" href="resources/stylesheet.css">
<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 message, color;
var evalA;
try {
evalA = eval(a);
} catch (e) {
evalA = e;
}
if (evalA == b) {
color = "green";
message = "PASS: " + a + " should be " + b + " and is.";
} else {
color = "red";
message = "FAIL: " + a + " should be " + b + " but instead is " + evalA + ".";
}
print(message, color);
}
var cssRule, cssValue, nodeFilter, event;
function test() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
cssRule = document.styleSheets[0].cssRules[0];
shouldBe("cssRule.UNKNOWN_RULE", 0);
shouldBe("cssRule.STYLE_RULE", 1);
shouldBe("cssRule.CHARSET_RULE", 2);
shouldBe("cssRule.IMPORT_RULE", 3);
shouldBe("cssRule.MEDIA_RULE", 4);
shouldBe("cssRule.FONT_FACE_RULE", 5);
shouldBe("cssRule.PAGE_RULE", 6);
shouldBe("window.CSSRule.UNKNOWN_RULE", 0);
shouldBe("window.CSSRule.STYLE_RULE", 1);
shouldBe("window.CSSRule.CHARSET_RULE", 2);
shouldBe("window.CSSRule.IMPORT_RULE", 3);
shouldBe("window.CSSRule.MEDIA_RULE", 4);
shouldBe("window.CSSRule.FONT_FACE_RULE", 5);
shouldBe("window.CSSRule.PAGE_RULE", 6);
cssValue = cssRule.style.getPropertyCSSValue("color");
shouldBe("cssValue.CSS_INHERIT", 0);
shouldBe("cssValue.CSS_PRIMITIVE_VALUE", 1);
shouldBe("cssValue.CSS_VALUE_LIST", 2);
shouldBe("cssValue.CSS_CUSTOM", 3);
shouldBe("window.CSSValue.CSS_INHERIT", 0);
shouldBe("window.CSSValue.CSS_PRIMITIVE_VALUE", 1);
shouldBe("window.CSSValue.CSS_VALUE_LIST", 2);
shouldBe("window.CSSValue.CSS_CUSTOM", 3);
var nodeIterator;
try {
nodeIterator = document.createNodeIterator(document,
NodeFilter.SHOW_ELEMENT,
function () { return NodeFilter.FILTER_ACCEPT; },
false);
} catch(e) {
nodeIterator = new Object();
}
nodeFilter = nodeIterator.filter;
shouldBe("nodeFilter.FILTER_ACCEPT", 1);
shouldBe("nodeFilter.FILTER_REJECT", 2);
shouldBe("nodeFilter.FILTER_SKIP", 3);
shouldBe("nodeFilter.SHOW_ALL", -1);
shouldBe("nodeFilter.SHOW_ELEMENT", 0x00000001);
shouldBe("nodeFilter.SHOW_ATTRIBUTE", 0x00000002);
shouldBe("nodeFilter.SHOW_TEXT", 0x00000004);
shouldBe("nodeFilter.SHOW_CDATA_SECTION", 0x00000008);
shouldBe("nodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
shouldBe("nodeFilter.SHOW_ENTITY", 0x00000020);
shouldBe("nodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
shouldBe("nodeFilter.SHOW_COMMENT", 0x00000080);
shouldBe("nodeFilter.SHOW_DOCUMENT", 0x00000100);
shouldBe("nodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
shouldBe("nodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
shouldBe("nodeFilter.SHOW_NOTATION", 0x00000800);
shouldBe("window.NodeFilter.FILTER_ACCEPT", 1);
shouldBe("window.NodeFilter.FILTER_REJECT", 2);
shouldBe("window.NodeFilter.FILTER_SKIP", 3);
shouldBe("window.NodeFilter.SHOW_ALL", -1);
shouldBe("window.NodeFilter.SHOW_ELEMENT", 0x00000001);
shouldBe("window.NodeFilter.SHOW_ATTRIBUTE", 0x00000002);
shouldBe("window.NodeFilter.SHOW_TEXT", 0x00000004);
shouldBe("window.NodeFilter.SHOW_CDATA_SECTION", 0x00000008);
shouldBe("window.NodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
shouldBe("window.NodeFilter.SHOW_ENTITY", 0x00000020);
shouldBe("window.NodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
shouldBe("window.NodeFilter.SHOW_COMMENT", 0x00000080);
shouldBe("window.NodeFilter.SHOW_DOCUMENT", 0x00000100);
shouldBe("window.NodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
shouldBe("window.NodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
shouldBe("window.NodeFilter.SHOW_NOTATION", 0x00000800);
event = document.createEvent("Event");
shouldBe("event.CAPTURING_PHASE", 1);
shouldBe("event.AT_TARGET", 2);
shouldBe("event.BUBBLING_PHASE", 3);
shouldBe("event.MOUSEDOWN", 1);
shouldBe("event.MOUSEUP", 2);
shouldBe("event.MOUSEOVER", 4);
shouldBe("event.MOUSEOUT", 8);
shouldBe("event.MOUSEMOVE", 16);
shouldBe("event.MOUSEDRAG", 32);
shouldBe("event.CLICK", 64);
shouldBe("event.DBLCLICK", 128);
shouldBe("event.KEYDOWN", 256);
shouldBe("event.KEYUP", 512);
shouldBe("event.KEYPRESS", 1024);
shouldBe("event.DRAGDROP", 2048);
shouldBe("event.FOCUS", 4096);
shouldBe("event.BLUR", 8192);
shouldBe("event.SELECT", 16384);
shouldBe("event.CHANGE", 32768);
shouldBe("window.Event.CAPTURING_PHASE", 1);
shouldBe("window.Event.AT_TARGET", 2);
shouldBe("window.Event.BUBBLING_PHASE", 3);
shouldBe("window.Event.MOUSEDOWN", 1);
shouldBe("window.Event.MOUSEUP", 2);
shouldBe("window.Event.MOUSEOVER", 4);
shouldBe("window.Event.MOUSEOUT", 8);
shouldBe("window.Event.MOUSEMOVE", 16);
shouldBe("window.Event.MOUSEDRAG", 32);
shouldBe("window.Event.CLICK", 64);
shouldBe("window.Event.DBLCLICK", 128);
shouldBe("window.Event.KEYDOWN", 256);
shouldBe("window.Event.KEYUP", 512);
shouldBe("window.Event.KEYPRESS", 1024);
shouldBe("window.Event.DRAGDROP", 2048);
shouldBe("window.Event.FOCUS", 4096);
shouldBe("window.Event.BLUR", 8192);
shouldBe("window.Event.SELECT", 16384);
shouldBe("window.Event.CHANGE", 32768);
}
</script>
</head>
<body onload="test();">
<p>This page tests CSSRule, CSSValue, NodeFilter, and Event. It tests:</p>
<ol>
<li>Whether their global constructors have the correct constant values</li>
<li>Whether their objects have the correct constant values</li>
</ol>
<hr>
<div id='console'></div>
</body>
</html>