summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/console/console-timestamp.html
blob: a9fe078ce7c9909d9ac301c41a3f0c1aa4437c73 (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
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
<script>

function test()
{
    InspectorTest.assert = function(result, message)
    {
        if (!result) {
            InspectorTest.log("FAIL: " + message);
            InspectorTest.completeTest();
        }
    };

    var messages = [];

    function messageAdded(data)
    {
        var payload = data.params.message;

        if (messages.length > 0)
            InspectorTest.assert(payload.timestamp >= messages[messages.length - 1].timestamp, "Timestamp shouldn't decrease over time.");

        messages.push(payload);
        InspectorTest.assert(payload.timestamp, "No timestamp found in message.");

        InspectorTest.assert(Math.abs(new Date().getTime() / 1000 - payload.timestamp) < 60, "Timestamp shouldn't differ very much from current time (one minute interval).");
    }

    function messageRepeatCountUpdated(data)
    {
        InspectorTest.assert(data.params.timestamp, "No timestamp found on repeat count update.");

        var updatedTimestamp = data.params.timestamp;

        InspectorTest.assert(updatedTimestamp >= messages[messages.length - 1].timestamp, "Timestamp shouldn't decrease over time.");

        InspectorTest.completeTest();
    }

    InspectorTest.eventHandler["Console.messageAdded"] = messageAdded;
    InspectorTest.eventHandler["Console.messageRepeatCountUpdated"] = messageRepeatCountUpdated;
    InspectorTest.sendCommand("Console.enable", {});

    InspectorTest.sendCommand("Runtime.evaluate", { expression: "console.log('testUnique'); for (var i = 0; i < 2; ++i) console.log('testDouble');" });
}

</script>
</head>
<body onload="runTest()">
</body>
</html>