gecko/dom/tests/mochitest/general/test_consoleAPI.html

57 lines
1.2 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>window.console test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body id="body">
<script type="application/javascript;version=1.8">
function doTest() {
ok(window.console, "console exists");
try {
ok(!console.foo, "random property doesn't throw");
} catch (ex) {
ok(false, "random property threw: " + ex);
}
var expectedProps = {
"log": "function",
"info": "function",
"warn": "function",
"error": "function",
"debug": "function",
"trace": "function",
"dir": "function",
"group": "function",
"groupCollapsed": "function",
"groupEnd": "function",
"time": "function",
"timeEnd": "function",
"__noSuchMethod__": "function"
};
var foundProps = 0;
for (var prop in console) {
foundProps++;
is(typeof(console[prop]), expectedProps[prop], "expect console prop " + prop + " exists");
}
is(foundProps, Object.keys(expectedProps).length, "found correct number of properties");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
<p id="display"></p>
</body>
</html>