2011-02-28 Yury Semikhatsky <yurys@chromium.org>
[WebKit-https.git] / LayoutTests / inspector / report-protocol-errors.html
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script>
5
6 function test()
7 {
8     var messages = [
9         'some wrong string',
10         '{}',
11         '{"command":1}',
12         '{"command":"test"}',
13         '{"seq":"not a number","command":"test"}',
14         '{"seq":1,"command":"test"}',
15         '{"seq":2,"command":"resourceContent"}',
16         '{"seq":3,"command":"resourceContent","arguments":[]}',
17         '{"seq":4,"command":"resourceContent","arguments":{}}',
18         '{"seq":5,"command":"resourceContent","arguments":{"identifier":"not a number"}}',
19     ];
20     var numberOfReports = 0;
21
22     InspectorBackend.reportProtocolError = function(message)
23     {
24         if (numberOfReports < messages.length)
25             InspectorTest.addObject(message);
26
27         if (++numberOfReports === messages.length)
28             InspectorTest.completeTest();
29     }
30
31     function fire() {
32         for (var i = 0; i < messages.length; ++i)
33             InspectorFrontendHost.sendMessageToBackend(messages[i]);
34     }
35
36     DebuggerAgent.disable(fire);
37 }
38
39 </script>
40 </head>
41
42 <body onload="runTest()">
43 <p>
44 Tests that InspectorBackendDispatcher is catching incorrect messages.
45 </p>
46
47 </body>
48 </html>