summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector/extensions/extensions-console.html
blob: 842a3cd0c3176a8e065796e7c5c977375bdfbce5 (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
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/console-test.js"></script>
<script src="../../http/tests/inspector/extensions-test.js"></script>

<script type="text/javascript">
function extension_testGetConsoleMessages(nextTest)
{
    function callback(messages)
    {
        dumpObject(messages, { url: "url" });
    }
    webInspector.console.getMessages(callbackAndNextTest(callback, nextTest));
}

function extension_testAddConsoleMessages(nextTest)
{
    webInspector.console.addMessage(webInspector.console.Severity.Debug, "debug message from extension");
    webInspector.console.addMessage(webInspector.console.Severity.Log, "log message from extension", "test-url.html", 42);
    webInspector.console.addMessage(webInspector.console.Severity.Warning, "warning message from extension");
    webInspector.console.addMessage(webInspector.console.Severity.Error, "error message from extension", null, 42);
    webInspector.inspectedWindow.eval("", function() {
        evaluateOnFrontend("InspectorTest.dumpConsoleMessagesWithClasses(); reply();", nextTest);
    });
}

function extension_testOnConsoleMessageAdded(nextTest)
{
    var expectedMessages = 6;

    function onMessage(message)
    {
        dumpObject(Array.prototype.slice.call(arguments, 0), { url: "url" });
        if (!--expectedMessages) {
            webInspector.console.onMessageAdded.removeListener(onMessage);
            nextTest();
        }
    }
    webInspector.console.onMessageAdded.addListener(onMessage);
    webInspector.inspectedWindow.eval("log();");
}

function log()
{
    console.log("log message");
    console.debug("debug message");
    console.warn("warning message");
    console.error("error message");
    console.log("log message with two parameters, an integer: %d and a string: %s", 42, "foo");
    eval("console.log('log message from evaluated code')");
}

</script>
</head>
<body onload="log(); runTest()">
<p>Tests methods of webInspector.console extension API</p>
<div id="test-div" class="test"></div>
</body>
</html>