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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 try { | 422 try { |
| 423 Array.prototype.push.call(arguments, result); | 423 Array.prototype.push.call(arguments, result); |
| 424 override.apply(this, arguments); | 424 override.apply(this, arguments); |
| 425 } catch (e) { | 425 } catch (e) { |
| 426 throw ("Exception in overriden method '" + methodName + "': " + e); | 426 throw ("Exception in overriden method '" + methodName + "': " + e); |
| 427 } | 427 } |
| 428 return result; | 428 return result; |
| 429 }; | 429 }; |
| 430 } | 430 } |
| 431 | 431 |
| 432 InspectorTest.addSnifferPromise = function(receiver, methodName) | |
| 433 { | |
| 434 return new Promise(function (resolve, reject) { | |
| 435 var original = receiver[methodName]; | |
|
pfeldman
2015/04/10 12:35:33
poor indent.
dmurph
2015/04/13 18:23:03
Removed.
| |
| 436 if (typeof original !== "function") { | |
| 437 reject("Cannot find method to override: " + methodName); | |
| 438 return; | |
| 439 } | |
| 440 | |
| 441 receiver[methodName] = function(var_args) { | |
| 442 try { | |
| 443 var result = original.apply(this, arguments); | |
| 444 } finally { | |
| 445 receiver[methodName] = original; | |
| 446 } | |
| 447 // In case of exception the override won't be called. | |
| 448 try { | |
| 449 Array.prototype.push.call(arguments, result); | |
| 450 resolve.apply(this, arguments); | |
| 451 } catch (e) { | |
| 452 reject("Exception in overriden method '" + methodName + "': " + e); | |
| 453 } | |
| 454 return result; | |
| 455 }; | |
| 456 }); | |
| 457 } | |
| 458 | |
| 432 InspectorTest.addConsoleSniffer = function(override, opt_sticky) | 459 InspectorTest.addConsoleSniffer = function(override, opt_sticky) |
| 433 { | 460 { |
| 434 InspectorTest.addSniffer(WebInspector.ConsoleModel.prototype, "addMessage", override, opt_sticky); | 461 InspectorTest.addSniffer(WebInspector.ConsoleModel.prototype, "addMessage", override, opt_sticky); |
| 435 } | 462 } |
| 436 | 463 |
| 437 InspectorTest.override = function(receiver, methodName, override, opt_sticky) | 464 InspectorTest.override = function(receiver, methodName, override, opt_sticky) |
| 438 { | 465 { |
| 439 override = InspectorTest.safeWrap(override); | 466 override = InspectorTest.safeWrap(override); |
| 440 | 467 |
| 441 var original = receiver[methodName]; | 468 var original = receiver[methodName]; |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 _output("[page] " + text); | 985 _output("[page] " + text); |
| 959 } | 986 } |
| 960 | 987 |
| 961 function _output(result) | 988 function _output(result) |
| 962 { | 989 { |
| 963 if (!outputElement) | 990 if (!outputElement) |
| 964 createOutputElement(); | 991 createOutputElement(); |
| 965 outputElement.appendChild(document.createTextNode(result)); | 992 outputElement.appendChild(document.createTextNode(result)); |
| 966 outputElement.appendChild(document.createElement("br")); | 993 outputElement.appendChild(document.createElement("br")); |
| 967 } | 994 } |
| OLD | NEW |