Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / inspector-backend-commands.html
blob1adb84d5d61ab2b4c8e715bde882afca1b199658
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <script src="../http/tests/inspector/inspector-test.js"></script>
5 <script>
6 function test()
8 function dumpArgument(name, value)
10 InspectorTest.addResult(name + " result: " + (typeof value === "string" ? value : JSON.stringify(value)));
13 function processResult(name, promise)
15 return promise.then(dumpArgument.bind(null, name + ": then"), dumpArgument.bind(null, name + ": catch"));
18 function sendMessageToBackendLoopback(message)
20 var messageObject = JSON.parse(message);
21 messageObject.result = messageObject.params;
22 messageObject.error = messageObject.params && messageObject.params.error;
23 var response = JSON.stringify(messageObject);
24 setTimeout(InspectorFrontendAPI.dispatchMessage.bind(InspectorFrontendAPI, response), 0);
27 var inspectorJson = {"domains": [{
28 "domain": "Profiler",
29 "commands": [
31 "name": "commandArgs0"
34 "name": "commandArgs1Rets0",
35 "parameters": [
36 {"name": "arg1", "type": "number"}
40 "name": "commandArgs1Rets1",
41 "parameters": [
42 {"name": "arg1", "type": "object"}
44 "returns": [
45 {"name": "arg1", "type": "object"}
49 "name": "commandArgs3Rets3",
50 "parameters": [
51 {"name": "arg1", "type": "object"},
52 {"name": "arg2", "type": "number", "optional": true},
53 {"name": "arg3", "type": "string", "optional": true}
55 "returns": [
56 {"name": "arg1", "type": "object"},
57 {"name": "arg2", "type": "number"},
58 {"name": "arg3", "type": "string"}
62 "name": "commandError",
63 "parameters": [
64 {"name": "error", "type": "object"}
67 }]};
68 var commands = InspectorBackendClass._generateCommands(inspectorJson);
69 eval(commands);
71 var sendMessageToBackendOriginal = InspectorFrontendHost.sendMessageToBackend;
72 InspectorFrontendHost.sendMessageToBackend = sendMessageToBackendLoopback;
74 function defaultHandler() {
75 return Array.prototype.slice.call(arguments);
78 var agent = WebInspector.targetManager.mainTarget().profilerAgent();
79 Promise.resolve()
80 .then(function() { return processResult("commandError", agent.commandError({"message": "this is the error message"}, defaultHandler)); }) // Error: error in the protocol response
81 .then(function() { return processResult("commandArgs0", agent.commandArgs0(defaultHandler)); })
82 .then(function() { return processResult("commandArgs0", agent.commandArgs0(1, defaultHandler)); }) // Error: extra arg
83 .then(function() { return processResult("commandArgs1Rets0", agent.commandArgs1Rets0(123, defaultHandler)); })
84 .then(function() { return processResult("commandArgs1Rets0", agent.commandArgs1Rets0(123, 456, defaultHandler)); }) // Error: extra arg
85 .then(function() { return processResult("commandArgs1Rets0", agent.commandArgs1Rets0("abc", defaultHandler)); }) // Error: wrong type
86 .then(function() { return processResult("commandArgs1Rets0", agent.commandArgs1Rets0(defaultHandler)); }) // Error: missing arg
87 .then(function() { return processResult("commandArgs1Rets1", agent.commandArgs1Rets1({"value1": 234}, defaultHandler)); })
88 .then(function() { return processResult("commandArgs1Rets1", agent.commandArgs1Rets1({"value1": 234}, defaultHandler)); })
89 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3({}, 345, "alph", defaultHandler)); })
90 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3({}, 345, defaultHandler)); })
91 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3({}, undefined, "alph", defaultHandler)); })
92 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3({}, "alph", defaultHandler)); }) // Error: wrong type
93 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3({}, defaultHandler)); })
94 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3(defaultHandler)); }) // Error: missing arg
95 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3({}, "alph", 345, defaultHandler)); }) // Error: wrong types
96 .then(function() { return processResult("commandArgs3Rets3", agent.commandArgs3Rets3({}, "alph", 345, 678, defaultHandler)); }) // Error: extra arg
97 .then(finishTest);
99 function finishTest()
101 InspectorFrontendHost.sendMessageToBackend = sendMessageToBackendOriginal;
102 InspectorTest.completeTest();
105 </script>
106 </head>
107 <body onload="runTest()">
108 <p>Tests correctness of promisified protocol commands.</p>
109 </body>
110 </html>