Index: LayoutTests/http/tests/inspector/inspector-test.js |
diff --git a/LayoutTests/http/tests/inspector/inspector-test.js b/LayoutTests/http/tests/inspector/inspector-test.js |
index 353c0460ebe5af536200f2225636ad8dab0b982f..72d4ad411d15b13a5dcf38edcd75045462e7fbfc 100644 |
--- a/LayoutTests/http/tests/inspector/inspector-test.js |
+++ b/LayoutTests/http/tests/inspector/inspector-test.js |
@@ -429,6 +429,33 @@ InspectorTest.addSniffer = function(receiver, methodName, override, opt_sticky) |
}; |
} |
+InspectorTest.addSnifferPromise = function(receiver, methodName) |
+{ |
+ return new Promise(function (resolve, reject) { |
+ var original = receiver[methodName]; |
pfeldman
2015/04/10 12:35:33
poor indent.
dmurph
2015/04/13 18:23:03
Removed.
|
+ if (typeof original !== "function") { |
+ reject("Cannot find method to override: " + methodName); |
+ return; |
+ } |
+ |
+ receiver[methodName] = function(var_args) { |
+ try { |
+ var result = original.apply(this, arguments); |
+ } finally { |
+ receiver[methodName] = original; |
+ } |
+ // In case of exception the override won't be called. |
+ try { |
+ Array.prototype.push.call(arguments, result); |
+ resolve.apply(this, arguments); |
+ } catch (e) { |
+ reject("Exception in overriden method '" + methodName + "': " + e); |
+ } |
+ return result; |
+ }; |
+ }); |
+} |
+ |
InspectorTest.addConsoleSniffer = function(override, opt_sticky) |
{ |
InspectorTest.addSniffer(WebInspector.ConsoleModel.prototype, "addMessage", override, opt_sticky); |