| OLD | NEW |
| (Empty) |
| 1 var initialize_ProtocolTest = function() { | |
| 2 | |
| 3 InspectorTest.filterProps = function(object, nondeterministicProps) | |
| 4 { | |
| 5 if (object instanceof Object) | |
| 6 for (var prop in object) | |
| 7 if (prop in nondeterministicProps) | |
| 8 object[prop] = "<" + typeof object[prop] + ">"; | |
| 9 else | |
| 10 object[prop] = this.filterProps(object[prop], nondeterministicPr
ops); | |
| 11 else if (object instanceof Array) | |
| 12 for (var i = 0; i < object.length; ++i) | |
| 13 object[i] = this.filterProps(object[i], nondeterministicProps); | |
| 14 else if (typeof object === "number") | |
| 15 object = "<number>"; | |
| 16 else if (typeof object === "string" && object.indexOf("\"id\"") != -1) | |
| 17 object = "<string>"; | |
| 18 return object; | |
| 19 }; | |
| 20 | |
| 21 InspectorTest._dumpEvent = function() | |
| 22 { | |
| 23 var args = Array.prototype.slice.call(arguments); | |
| 24 var eventName = args.shift(); | |
| 25 InspectorTest._agentCoverage[eventName] = "checked"; | |
| 26 InspectorTest.addResult("event " + InspectorTest._agentName + "." + eventNam
e); | |
| 27 InspectorTest.addObject(InspectorTest._lastReceivedMessage, InspectorTest._c
ustomFormatters); | |
| 28 InspectorTest.addResult(""); | |
| 29 | |
| 30 var originalEventHandler = args.shift(); | |
| 31 originalEventHandler.apply(this, args); | |
| 32 }; | |
| 33 | |
| 34 | |
| 35 InspectorTest._dumpCallArguments = function(callArguments) | |
| 36 { | |
| 37 var callArgumentsCopy = JSON.parse(JSON.stringify(callArguments)); | |
| 38 var agentName = callArgumentsCopy.shift(); | |
| 39 var functionName = callArgumentsCopy.shift(); | |
| 40 this.filterProps(callArgumentsCopy, this._customFormatters); | |
| 41 var expression = JSON.stringify(callArgumentsCopy); | |
| 42 expression = expression.slice(1, expression.length - 1).replace(/\"<number>\
"/g, "<number>").replace(/\"<string>\"/g, "<string>"); | |
| 43 | |
| 44 InspectorTest.addResult("---------------------------------------------------
--------"); | |
| 45 InspectorTest.addResult(agentName + "." + functionName + "(" + expression +
")"); | |
| 46 InspectorTest.addResult(""); | |
| 47 }; | |
| 48 | |
| 49 InspectorTest._callback = function(result) | |
| 50 { | |
| 51 InspectorTest.addResult("response:"); | |
| 52 InspectorTest.addObject(InspectorTest._lastReceivedMessage, InspectorTest._c
ustomFormatters); | |
| 53 InspectorTest.addResult(""); | |
| 54 InspectorTest._runNextTest(); | |
| 55 }; | |
| 56 | |
| 57 InspectorTest._runNextTest = function() | |
| 58 { | |
| 59 var step = ++this._step; | |
| 60 var nextTest = this._testSuite[step]; | |
| 61 if (nextTest) { | |
| 62 InspectorTest._dumpCallArguments(nextTest); | |
| 63 | |
| 64 nextTest.push(this._callback.bind(this)); | |
| 65 | |
| 66 var agentName = nextTest.shift(); | |
| 67 var functionName = nextTest.shift(); | |
| 68 window[agentName][functionName].apply(window[agentName], nextTest); | |
| 69 | |
| 70 var lastSentMessage = InspectorTest._lastSentMessage; // This is because
the next call will override _lastSentMessage. | |
| 71 InspectorTest.addResult("request:"); | |
| 72 InspectorTest.addObject(lastSentMessage, InspectorTest._customFormatters
); | |
| 73 InspectorTest.addResult(""); | |
| 74 | |
| 75 if (agentName === this._agentName) | |
| 76 this._agentCoverage[functionName] = "checked"; | |
| 77 } | |
| 78 else { | |
| 79 InspectorTest.addResult("===============================================
============"); | |
| 80 InspectorTest.addResult("Coverage for " + this._agentName); | |
| 81 InspectorTest.addObject(this._agentCoverage); | |
| 82 InspectorBackend.dispatch = this._originalDispatch; | |
| 83 InspectorFrontendHost.sendMessageToBackend = this._originalSendMessageTo
Backend; | |
| 84 this.completeTest(); | |
| 85 } | |
| 86 }; | |
| 87 | |
| 88 InspectorTest.runProtocolTestSuite = function(agentName, testSuite, nondetermini
sticProps) | |
| 89 { | |
| 90 this._agentName = agentName; | |
| 91 this._testSuite = testSuite; | |
| 92 this._customFormatters = {}; | |
| 93 for (var i = 0; i < nondeterministicProps.length; ++i) | |
| 94 this._customFormatters[nondeterministicProps[i]] = "formatAsTypeName"; | |
| 95 var agent = window[agentName]; | |
| 96 | |
| 97 this._agentCoverage = {}; | |
| 98 for (var key in agent) | |
| 99 this._agentCoverage[key] = "not checked"; | |
| 100 | |
| 101 var domain = agentName.replace(/Agent$/,""); | |
| 102 var domainMessagesHandler = InspectorBackend._domainDispatchers[domain]; | |
| 103 for (var eventName in domainMessagesHandler) { | |
| 104 if (typeof domainMessagesHandler[eventName] !== "function") | |
| 105 continue; | |
| 106 this._agentCoverage[eventName] = "not checked"; | |
| 107 domainMessagesHandler[eventName] = InspectorTest._dumpEvent.bind(domainM
essagesHandler, eventName, domainMessagesHandler[eventName]); | |
| 108 } | |
| 109 | |
| 110 this._originalDispatch = InspectorBackend.dispatch; | |
| 111 InspectorBackend.dispatch = function(message) | |
| 112 { | |
| 113 InspectorTest._lastReceivedMessage = (typeof message === "string") ? JSO
N.parse(message) : message; | |
| 114 InspectorTest._originalDispatch.apply(InspectorBackend, [message]); | |
| 115 } | |
| 116 | |
| 117 this._originalSendMessageToBackend = InspectorFrontendHost.sendMessageToBack
end; | |
| 118 InspectorFrontendHost.sendMessageToBackend = function(message) | |
| 119 { | |
| 120 InspectorTest._lastSentMessage = JSON.parse(message); | |
| 121 InspectorTest._originalSendMessageToBackend.apply(InspectorFrontendHost,
[message]); | |
| 122 } | |
| 123 | |
| 124 this._step = -1; | |
| 125 | |
| 126 this._runNextTest(); | |
| 127 }; | |
| 128 | |
| 129 }; | |
| OLD | NEW |