From e6e885d50188d323c59d54a745d45aa9a41a4353 Mon Sep 17 00:00:00 2001 From: "loislo@chromium.org" Date: Fri, 4 Mar 2011 11:11:58 +0000 Subject: [PATCH 1/1] 2011-03-03 Ilya Tikhonovsky Reviewed by Yury Semikhatsky. Web Inspector: introduce a protocol test for RuntimeAgent API. https://bugs.webkit.org/show_bug.cgi?id=55482 * http/tests/inspector/protocol-test.js: Added. (initialize_ProtocolTest.InspectorTest.filterProps): (initialize_ProtocolTest.InspectorTest._dumpStepResult): (initialize_ProtocolTest.InspectorTest._runNextStep): (initialize_ProtocolTest.InspectorTest.runProtocolTestSuite): (initialize_ProtocolTest): * inspector/protocol/runtime-agent-expected.txt: Added. * inspector/protocol/runtime-agent.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80341 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 16 + .../http/tests/inspector/inspector-test.js | 2 +- .../http/tests/inspector/protocol-test.js | 89 +++++ .../protocol/runtime-agent-expected.txt | 309 ++++++++++++++++++ .../inspector/protocol/runtime-agent.html | 45 +++ 5 files changed, 460 insertions(+), 1 deletion(-) create mode 100644 LayoutTests/http/tests/inspector/protocol-test.js create mode 100644 LayoutTests/inspector/protocol/runtime-agent-expected.txt create mode 100644 LayoutTests/inspector/protocol/runtime-agent.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index e3b0d70d8b49..3113847e6bc5 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,19 @@ +2011-03-03 Ilya Tikhonovsky + + Reviewed by Yury Semikhatsky. + + Web Inspector: introduce a protocol test for RuntimeAgent API. + https://bugs.webkit.org/show_bug.cgi?id=55482 + + * http/tests/inspector/protocol-test.js: Added. + (initialize_ProtocolTest.InspectorTest.filterProps): + (initialize_ProtocolTest.InspectorTest._dumpStepResult): + (initialize_ProtocolTest.InspectorTest._runNextStep): + (initialize_ProtocolTest.InspectorTest.runProtocolTestSuite): + (initialize_ProtocolTest): + * inspector/protocol/runtime-agent-expected.txt: Added. + * inspector/protocol/runtime-agent.html: Added. + 2011-03-03 Pavel Feldman Reviewed by Yury Semikhatsky. diff --git a/LayoutTests/http/tests/inspector/inspector-test.js b/LayoutTests/http/tests/inspector/inspector-test.js index cf66bd43ed59..dd8d19283c6e 100644 --- a/LayoutTests/http/tests/inspector/inspector-test.js +++ b/LayoutTests/http/tests/inspector/inspector-test.js @@ -90,7 +90,7 @@ InspectorTest.addObject = function(object, nondeterministicProps, prefix, firstL firstLinePrefix = firstLinePrefix || prefix; InspectorTest.addResult(firstLinePrefix + "{"); for (var prop in object) { - if (!object.hasOwnProperty(prop)) + if (typeof object.hasOwnProperty === "function" && !object.hasOwnProperty(prop)) continue; var prefixWithName = prefix + " " + prop + " : "; var propValue = object[prop]; diff --git a/LayoutTests/http/tests/inspector/protocol-test.js b/LayoutTests/http/tests/inspector/protocol-test.js new file mode 100644 index 000000000000..bd74b6290fa7 --- /dev/null +++ b/LayoutTests/http/tests/inspector/protocol-test.js @@ -0,0 +1,89 @@ +var initialize_ProtocolTest = function() { + +InspectorTest.filterProps = function(something, nondeterministicProps) +{ + if (something instanceof Object) + for (var prop in something) + if (prop in nondeterministicProps) + something[prop] = "<" + typeof something[prop] + ">"; + else + something[prop] = this.filterProps(something[prop], nondeterministicProps); + else if (something instanceof Array) + for (var i = 0; i < something.length; ++i) + something[i] = this.filterProps(something[i], nondeterministicProps); + else if (typeof something === "number") + something = ""; + return something; +}; + +InspectorTest._dumpTestResult = function(callArguments) +{ + var functionName = callArguments.shift(); + this.filterProps(callArguments, this._nondeterministicProps); + var expression = JSON.stringify(callArguments); + expression = expression.slice(1, expression.length - 1).replace(/\"\"/g, "");; + var sentObject = JSON.parse(this._lastSentTestMessage); + var receivedObject = (typeof this._lastReceivedMessage === "string") ? JSON.parse(this._lastReceivedMessage) : this._lastReceivedMessage; + + InspectorTest.addResult("-----------------------------------------------------------"); + InspectorTest.addResult(this._agentName + "." + functionName + "(" + expression + ")"); + InspectorTest.addResult(""); + InspectorTest.addResult("request:"); + InspectorTest.addObject(sentObject, this._nondeterministicProps); + InspectorTest.addResult(""); + InspectorTest.addResult("response:"); + InspectorTest.addObject(receivedObject, this._nondeterministicProps); + InspectorTest.addResult(""); +}; + +InspectorTest._callback = function(callArguments, result) +{ + this._dumpTestResult(callArguments); + this._runNextStep(result); +}; + +InspectorTest._runNextStep = function(result) +{ + var step = ++this._step; + var nextTest = this._testSuite[step]; + if (nextTest) { + var nextTestCopy = JSON.parse(JSON.stringify(nextTest)); + nextTest.push(this._callback.bind(this, nextTestCopy)); + var functionName = nextTest.shift(); + this._agentCoverage[functionName] = "checked"; + this._agent[functionName].apply(this._agent, nextTest); + this._lastSentTestMessage = this._lastSentMessage; + } + else { + InspectorTest.addResult("==========================================================="); + InspectorTest.addResult("Coverage for " + this._agentName); + InspectorTest.addObject(this._agentCoverage); + InspectorBackend.dispatch = this._originalDispatch; + InspectorFrontendHost.sendMessageToBackend = this._originalSendMessageToBackend; + this.completeTest(); + } +}; + +InspectorTest.runProtocolTestSuite = function(agentName, testSuite, nondeterministicProps) +{ + this._agentName = agentName; + this._testSuite = testSuite; + this._nondeterministicProps = {}; + for (var i = 0; i < nondeterministicProps.length; ++i) + this._nondeterministicProps[nondeterministicProps[i]] = true; + this._agent = window[agentName]; + this._agentCoverage = {}; + for (var key in this._agent) + this._agentCoverage[key] = "not checked"; + this._step = -1; + + this._originalDispatch = InspectorBackend.dispatch; + InspectorBackend.dispatch = function(message) { InspectorTest._lastReceivedMessage = message; InspectorTest._originalDispatch.apply(InspectorBackend, [message]); } + + this._originalSendMessageToBackend = InspectorFrontendHost.sendMessageToBackend; + InspectorFrontendHost.sendMessageToBackend = function(message) { InspectorTest._lastSentMessage = message; InspectorTest._originalSendMessageToBackend.apply(InspectorFrontendHost, [message]); } + + this._runNextStep(); +}; + +}; \ No newline at end of file diff --git a/LayoutTests/inspector/protocol/runtime-agent-expected.txt b/LayoutTests/inspector/protocol/runtime-agent-expected.txt new file mode 100644 index 000000000000..b14526cc8593 --- /dev/null +++ b/LayoutTests/inspector/protocol/runtime-agent-expected.txt @@ -0,0 +1,309 @@ +Protocol stability test. It is dumping request/response pairs of RuntimeAgent functions. + +----------------------------------------------------------- +RuntimeAgent.evaluate("testObject","test",false) + +request: +{ + seq : + domain : "Runtime" + command : "evaluate" + arguments : { + expression : "testObject" + objectGroup : "test" + includeCommandLineAPI : false + } +} + +response: +{ + seq : + domain : "Runtime" + success : true + body : { + result : { + objectId : { + injectedScriptId : + id : + groupName : "test" + } + type : "object" + description : "TestObject" + hasChildren : true + } + } +} + +----------------------------------------------------------- +RuntimeAgent.evaluateOn({"injectedScriptId":,"id":,"groupName":"test"},"this.assignedByEvaluateOn = \"evaluateOn function works fine\";") + +request: +{ + seq : + domain : "Runtime" + command : "evaluateOn" + arguments : { + objectId : { + injectedScriptId : + id : + groupName : "test" + } + expression : "this.assignedByEvaluateOn = "evaluateOn function works fine";" + } +} + +response: +{ + seq : + domain : "Runtime" + success : true + body : { + result : { + objectId : null + type : "undefined" + description : "undefined" + hasChildren : false + } + } +} + +----------------------------------------------------------- +RuntimeAgent.setPropertyValue({"injectedScriptId":,"id":,"groupName":"test"},"assignedBySetPropertyValue","true") + +request: +{ + seq : + domain : "Runtime" + command : "setPropertyValue" + arguments : { + objectId : { + injectedScriptId : + id : + groupName : "test" + } + propertyName : "assignedBySetPropertyValue" + expression : "true" + } +} + +response: +{ + seq : + domain : "Runtime" + success : true + body : { + result : true + } +} + +----------------------------------------------------------- +RuntimeAgent.setPropertyValue({"injectedScriptId":,"id":,"groupName":"test"},"removedBySetPropertyValue","") + +request: +{ + seq : + domain : "Runtime" + command : "setPropertyValue" + arguments : { + objectId : { + injectedScriptId : + id : + groupName : "test" + } + propertyName : "removedBySetPropertyValue" + expression : "" + } +} + +response: +{ + seq : + domain : "Runtime" + success : true + body : { + result : true + } +} + +----------------------------------------------------------- +RuntimeAgent.getProperties({"injectedScriptId":,"id":,"groupName":"test"},false,false) + +request: +{ + seq : + domain : "Runtime" + command : "getProperties" + arguments : { + objectId : { + injectedScriptId : + id : + groupName : "test" + } + ignoreHasOwnProperty : false + abbreviate : false + } +} + +response: +{ + seq : + domain : "Runtime" + success : true + body : { + result : { + 0 : { + name : "assignedByEvaluateOn" + value : { + objectId : null + type : "string" + description : "evaluateOn function works fine" + hasChildren : false + } + } + 1 : { + name : "assignedBySetPropertyValue" + value : { + objectId : null + type : "boolean" + description : "true" + hasChildren : false + } + } + 2 : { + name : "__proto__" + value : { + objectId : { + injectedScriptId : + id : + groupName : "test" + } + type : "object" + description : "TestObject" + hasChildren : true + } + } + } + } +} + +----------------------------------------------------------- +RuntimeAgent.releaseObject({"injectedScriptId":,"id":,"groupName":"test"}) + +request: +{ + seq : + domain : "Runtime" + command : "releaseObject" + arguments : { + objectId : { + injectedScriptId : + id : + groupName : "test" + } + } +} + +response: +{ + seq : + domain : "Runtime" + success : true +} + +----------------------------------------------------------- +RuntimeAgent.releaseWrapperObjectGroup(,"test") + +request: +{ + seq : + domain : "Runtime" + command : "releaseWrapperObjectGroup" + arguments : { + injectedScriptId : + objectGroup : "test" + } +} + +response: +{ + seq : + domain : "Runtime" + success : true +} + +----------------------------------------------------------- +RuntimeAgent.getCompletions("testProperty",false) + +request: +{ + seq : + domain : "Runtime" + command : "getCompletions" + arguments : { + expression : "testProperty" + includeCommandLineAPI : false + } +} + +response: +{ + seq : + domain : "Runtime" + success : true + body : { + result : { + } + } +} + +----------------------------------------------------------- +RuntimeAgent.getCompletions("testProperty",true) + +request: +{ + seq : + domain : "Runtime" + command : "getCompletions" + arguments : { + expression : "testProperty" + includeCommandLineAPI : true + } +} + +response: +{ + seq : + domain : "Runtime" + success : true + body : { + result : { + $ : true + $$ : true + $x : true + dir : true + dirxml : true + keys : true + values : true + profile : true + profileEnd : true + monitorEvents : true + unmonitorEvents : true + inspect : true + copy : true + clear : true + } + } +} + +=========================================================== +Coverage for RuntimeAgent +{ + evaluate : "checked" + evaluateOn : "checked" + getCompletions : "checked" + getProperties : "checked" + setPropertyValue : "checked" + releaseObject : "checked" + releaseWrapperObjectGroup : "checked" +} + diff --git a/LayoutTests/inspector/protocol/runtime-agent.html b/LayoutTests/inspector/protocol/runtime-agent.html new file mode 100644 index 000000000000..eceeccc260c4 --- /dev/null +++ b/LayoutTests/inspector/protocol/runtime-agent.html @@ -0,0 +1,45 @@ + + + + + + + + +

+Protocol stability test. It is dumping request/response pairs of RuntimeAgent functions. +

+ + + -- 2.36.0