Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 var initialize_InspectorTest = function() { | 1 var initialize_InspectorTest = function() { |
| 2 | 2 |
| 3 var results = []; | 3 var results = []; |
| 4 | 4 |
| 5 function consoleOutputHook(messageType) | 5 function consoleOutputHook(messageType) |
| 6 { | 6 { |
| 7 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu ments, 1)); | 7 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu ments, 1)); |
| 8 } | 8 } |
| 9 | 9 |
| 10 window._originalConsoleLog = console.log.bind(console); | 10 window._originalConsoleLog = console.log.bind(console); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 var callbacks = pendingPromiseEvalRequests[callId]; | 107 var callbacks = pendingPromiseEvalRequests[callId]; |
| 108 if (!callbacks) { | 108 if (!callbacks) { |
| 109 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?"); | 109 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?"); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 var callback = didResolve ? callbacks.resolve : callbacks.reject; | 112 var callback = didResolve ? callbacks.resolve : callbacks.reject; |
| 113 delete pendingPromiseEvalRequests[callId]; | 113 delete pendingPromiseEvalRequests[callId]; |
| 114 callback(value); | 114 callback(value); |
| 115 } | 115 } |
| 116 | 116 |
| 117 InspectorTest.invokePageFunctionAsync = function(functionName, callback) | 117 InspectorTest.invokePageFunctionAsync = function(functionName, optionalArgs, cal lback) |
|
dgozman
2015/07/31 06:50:38
Should comment or annotate that optionalArgs is no
| |
| 118 { | 118 { |
| 119 var id = ++lastEvalId; | 119 var id = ++lastEvalId; |
| 120 var args = Array.prototype.slice.call(arguments, 1); | |
| 121 var callback = args.pop(); | |
| 120 pendingEvalRequests[id] = InspectorTest.safeWrap(callback); | 122 pendingEvalRequests[id] = InspectorTest.safeWrap(callback); |
| 121 var asyncEvalWrapper = function(callId, functionName) | 123 var asyncEvalWrapper = function(callId, functionName, argsString) |
| 122 { | 124 { |
| 123 function evalCallback(result) | 125 function evalCallback(result) |
| 124 { | 126 { |
| 125 testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest .didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");"); | 127 testRunner.evaluateInWebInspector(evalCallbackCallId, "InspectorTest .didInvokePageFunctionAsync(" + callId + ", " + JSON.stringify(result) + ");"); |
| 126 } | 128 } |
| 127 | 129 var argsArray = argsString.replace(/^\[(.*)\]$/, "$1"); |
| 130 if (argsArray.length) | |
| 131 argsArray += ","; | |
| 128 try { | 132 try { |
| 129 eval(functionName + "(" + evalCallback + ")"); | 133 eval(functionName + "(" + argsArray + evalCallback + ")"); |
| 130 } catch(e) { | 134 } catch(e) { |
| 131 InspectorTest.addResult("Error: " + e); | 135 InspectorTest.addResult("Error: " + e); |
| 132 evalCallback(String(e)); | 136 evalCallback(String(e)); |
| 133 } | 137 } |
| 134 } | 138 } |
| 135 InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "'))"); | 139 var escapedJSONArgs = JSON.stringify(JSON.stringify(args)); |
| 140 InspectorTest.evaluateInPage("(" + asyncEvalWrapper.toString() + ")(" + id + ", unescape('" + escape(functionName) + "')," + escapedJSONArgs + ")"); | |
| 136 } | 141 } |
| 137 | 142 |
| 138 InspectorTest.didInvokePageFunctionAsync = function(callId, value) | 143 InspectorTest.didInvokePageFunctionAsync = function(callId, value) |
| 139 { | 144 { |
| 140 var callback = pendingEvalRequests[callId]; | 145 var callback = pendingEvalRequests[callId]; |
| 141 if (!callback) { | 146 if (!callback) { |
| 142 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?"); | 147 InspectorTest.addResult("Missing callback for async eval " + callId + ", perhaps callback invoked twice?"); |
| 143 return; | 148 return; |
| 144 } | 149 } |
| 145 delete pendingEvalRequests[callId]; | 150 delete pendingEvalRequests[callId]; |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 _output("[page] " + text); | 1064 _output("[page] " + text); |
| 1060 } | 1065 } |
| 1061 | 1066 |
| 1062 function _output(result) | 1067 function _output(result) |
| 1063 { | 1068 { |
| 1064 if (!outputElement) | 1069 if (!outputElement) |
| 1065 createOutputElement(); | 1070 createOutputElement(); |
| 1066 outputElement.appendChild(document.createTextNode(result)); | 1071 outputElement.appendChild(document.createTextNode(result)); |
| 1067 outputElement.appendChild(document.createElement("br")); | 1072 outputElement.appendChild(document.createElement("br")); |
| 1068 } | 1073 } |
| OLD | NEW |