+2011-03-03 Ilya Tikhonovsky <loislo@chromium.org>
+
+ 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 Kenji Imasaki <imasaki@chromium.org>
Reviewed by Mihai Parparita.
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];
--- /dev/null
+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
+ this.filterProps(something[prop], nondeterministicProps);
+ else if (something instanceof Array)
+ for (var i = 0; i < something.length; ++i)
+ this.filterProps(prop, nondeterministicProps);
+};
+
+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(/\"<number>\"/g, "<number>");;
+ 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
--- /dev/null
+Protocol stability test. It is dumping request/response pairs of RuntimeAgent functions.
+
+-----------------------------------------------------------
+RuntimeAgent.evaluate("testObject","test",false)
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "evaluate"
+ arguments : {
+ expression : "testObject"
+ objectGroup : "test"
+ includeCommandLineAPI : false
+ }
+}
+
+response:
+{
+ seq : <number>
+ domain : "Runtime"
+ success : true
+ body : {
+ result : {
+ objectId : {
+ injectedScriptId : <number>
+ id : <number>
+ groupName : "test"
+ }
+ type : "object"
+ description : "TestObject"
+ hasChildren : true
+ }
+ }
+}
+
+-----------------------------------------------------------
+RuntimeAgent.evaluateOn({"injectedScriptId":<number>,"id":<number>,"groupName":"test"},"this.assignedByEvaluateOn = \"evaluateOn function works fine\";")
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "evaluateOn"
+ arguments : {
+ objectId : {
+ injectedScriptId : <number>
+ id : <number>
+ groupName : "test"
+ }
+ expression : "this.assignedByEvaluateOn = "evaluateOn function works fine";"
+ }
+}
+
+response:
+{
+ seq : <number>
+ domain : "Runtime"
+ success : true
+ body : {
+ result : {
+ objectId : null
+ type : "undefined"
+ description : "undefined"
+ hasChildren : false
+ }
+ }
+}
+
+-----------------------------------------------------------
+RuntimeAgent.setPropertyValue({"injectedScriptId":<number>,"id":<number>,"groupName":"test"},"assignedBySetPropertyValue","true")
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "setPropertyValue"
+ arguments : {
+ objectId : {
+ injectedScriptId : <number>
+ id : <number>
+ groupName : "test"
+ }
+ propertyName : "assignedBySetPropertyValue"
+ expression : "true"
+ }
+}
+
+response:
+{
+ seq : <number>
+ domain : "Runtime"
+ success : true
+ body : {
+ result : true
+ }
+}
+
+-----------------------------------------------------------
+RuntimeAgent.setPropertyValue({"injectedScriptId":<number>,"id":<number>,"groupName":"test"},"removedBySetPropertyValue","")
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "setPropertyValue"
+ arguments : {
+ objectId : {
+ injectedScriptId : <number>
+ id : <number>
+ groupName : "test"
+ }
+ propertyName : "removedBySetPropertyValue"
+ expression : ""
+ }
+}
+
+response:
+{
+ seq : <number>
+ domain : "Runtime"
+ success : true
+ body : {
+ result : true
+ }
+}
+
+-----------------------------------------------------------
+RuntimeAgent.getProperties({"injectedScriptId":<number>,"id":<number>,"groupName":"test"},false,false)
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "getProperties"
+ arguments : {
+ objectId : {
+ injectedScriptId : <number>
+ id : <number>
+ groupName : "test"
+ }
+ ignoreHasOwnProperty : false
+ abbreviate : false
+ }
+}
+
+response:
+{
+ seq : <number>
+ 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 : <number>
+ id : <number>
+ groupName : "test"
+ }
+ type : "object"
+ description : "TestObject"
+ hasChildren : true
+ }
+ }
+ }
+ }
+}
+
+-----------------------------------------------------------
+RuntimeAgent.releaseObject({"injectedScriptId":<number>,"id":<number>,"groupName":"test"})
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "releaseObject"
+ arguments : {
+ objectId : {
+ injectedScriptId : <number>
+ id : <number>
+ groupName : "test"
+ }
+ }
+}
+
+response:
+{
+ seq : <number>
+ domain : "Runtime"
+ success : true
+}
+
+-----------------------------------------------------------
+RuntimeAgent.releaseWrapperObjectGroup(1,"test")
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "releaseWrapperObjectGroup"
+ arguments : {
+ injectedScriptId : <number>
+ objectGroup : "test"
+ }
+}
+
+response:
+{
+ seq : <number>
+ domain : "Runtime"
+ success : true
+}
+
+-----------------------------------------------------------
+RuntimeAgent.getCompletions("testProperty",false)
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "getCompletions"
+ arguments : {
+ expression : "testProperty"
+ includeCommandLineAPI : false
+ }
+}
+
+response:
+{
+ seq : <number>
+ domain : "Runtime"
+ success : true
+ body : {
+ result : {
+ }
+ }
+}
+
+-----------------------------------------------------------
+RuntimeAgent.getCompletions("testProperty",true)
+
+request:
+{
+ seq : <number>
+ domain : "Runtime"
+ command : "getCompletions"
+ arguments : {
+ expression : "testProperty"
+ includeCommandLineAPI : true
+ }
+}
+
+response:
+{
+ seq : <number>
+ 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"
+}
+
--- /dev/null
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/protocol-test.js"></script>
+<script>
+
+function TestObject()
+{
+ this.removedBySetPropertyValue = "doesn't work";
+}
+
+testObject = new TestObject();
+testProperty = true;
+
+function test()
+{
+ function callback(result)
+ {
+ var testSuite = [
+ ["evaluate", 'testObject', 'test', false],
+ ["evaluateOn", result.objectId, 'this.assignedByEvaluateOn = "evaluateOn function works fine";'],
+ ["setPropertyValue", result.objectId, 'assignedBySetPropertyValue', 'true'],
+ ["setPropertyValue", result.objectId, 'removedBySetPropertyValue', ''],
+ ["getProperties", result.objectId, false, false],
+ ["releaseObject", result.objectId],
+ ["releaseWrapperObjectGroup", result.objectId.injectedScriptId, 'test'],
+ ["getCompletions", 'testProperty', false],
+ ["getCompletions", 'testProperty', true]];
+
+ InspectorTest.runProtocolTestSuite("RuntimeAgent", testSuite, ['seq', 'id', 'injectedScriptId']);
+ }
+
+ RuntimeAgent.evaluate('window.testObject', 'test', false, callback);
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+Protocol stability test. It is dumping request/response pairs of RuntimeAgent functions.
+</p>
+
+</body>
+</html>