summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/general/test_consoleAPI.html
blob: 8d710a51a421d14ad7e79140c1b8f0b29f71a652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!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",
    "exception": "function",
    "debug": "function",
    "trace": "function",
    "dir": "function",
    "group": "function",
    "groupCollapsed": "function",
    "groupEnd": "function",
    "time": "function",
    "timeEnd": "function",
    "profile": "function",
    "profileEnd": "function",
    "assert": "function",
    "count": "function",
    "table": "function",
    "clear": "function",
    "dirxml": "function",
    "markTimeline": "function",
    "timeline": "function",
    "timelineEnd": "function",
    "timeStamp": "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>