2011-04-06 Ilya Tikhonovsky <loislo@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         '{"method":1}',
12         '{"method":"resourceContent"}',
13         '{"id":"not a number","method":"Network.resourceContent"}',
14         '{"id":1,"method":"DOM.test"}',
15         '{"id":2,"method":"Network.getResourceContent"}',
16         '{"id":3,"method":"Network.getResourceContent","params":[]}',
17         '{"id":4,"method":"Network.getResourceContent","params":{}}',
18         '{"id":5,"method":"Network.getResourceContent","params":{"frameId":"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>