Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Unified Diff: third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js

Issue 2701763002: DevTools: run user callback inside promise for promisified domains (Closed)
Patch Set: rebaseline test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/inspector-backend-commands-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
diff --git a/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js b/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
index b1266f916a64ca073a29d0d11c8132e620885d19..e444f2d37f2e30bb4fc2e9c9787dcd0ea7200885 100644
--- a/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
+++ b/third_party/WebKit/Source/devtools/front_end/protocol/InspectorBackend.js
@@ -599,13 +599,15 @@ Protocol.InspectorBackend._AgentPrototype = class {
}
var userCallback = (args.length && typeof args.peekLast() === 'function') ? args.pop() : null;
var params = this._prepareParameters(method, signature, args, !userCallback, onError);
- if (errorMessage)
- return Promise.reject(new Error(errorMessage));
- else
- return new Promise(promiseAction.bind(this));
+ var responseArguments;
+ if (errorMessage) {
+ responseArguments = [errorMessage];
+ return Promise.resolve().then(runUserCallback);
+ }
+ return new Promise(promiseAction.bind(this)).then(runUserCallback);
/**
- * @param {function(?)} resolve
+ * @param {function()} resolve
* @param {function(!Error)} reject
* @this {Protocol.InspectorBackend._AgentPrototype}
*/
@@ -614,11 +616,15 @@ Protocol.InspectorBackend._AgentPrototype = class {
* @param {...*} vararg
*/
function callback(vararg) {
- var result = userCallback ? userCallback.apply(null, arguments) : undefined;
- resolve(result);
+ responseArguments = arguments;
+ resolve();
}
this._target._wrapCallbackAndSendMessageObject(this._domain, method, params, callback);
}
+
+ function runUserCallback() {
+ return userCallback ? userCallback.apply(null, responseArguments) : undefined;
+ }
}
/**
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/inspector-backend-commands-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698