Commit 2a55bf6d authored by paulirish's avatar paulirish Committed by Commit bot

The WebInspector.sendOverProtocol method provides an easy mechanism to test

and debug protocol commands. It's intended for developer debugging only.

Examples:

    WebInspector.sendOverProtocol('Emulation.setDeviceMetricsOverride', { ... });
    WebInspector.sendOverProtocol('Emulation.clearDeviceMetricsOverride');

    WebInspector.sendOverProtocol('Page.captureScreenshot')
        .then((err, result) => console.log(result));

Review-Url: https://codereview.chromium.org/2149833002
Cr-Commit-Position: refs/heads/master@{#405625}
parent 6fbb24a6
......@@ -949,6 +949,23 @@ WebInspector.Main.InspectedNodeRevealer.prototype = {
}
}
/**
* @param {string} method
* @param {?Object} params
* @return {!Promise}
*/
WebInspector.sendOverProtocol = function(method, params)
{
var connection = WebInspector.targetManager.mainTarget().connection();
return new Promise((resolve, reject) => {
connection.sendRawMessageForTesting(method, params, (err, result) => {
if (err)
return reject(err);
return resolve(result);
});
});
}
/**
* @constructor
* @extends {WebInspector.VBox}
......
......@@ -317,6 +317,17 @@ InspectorBackendClass.Connection.prototype = {
throw "Not implemented";
},
/**
* @param {string} method
* @param {?Object} params
* @param {?function(*)} callback
*/
sendRawMessageForTesting: function(method, params, callback)
{
var domain = method.split(".")[0];
this._wrapCallbackAndSendMessageObject(domain, method, params, callback);
},
/**
* @param {!Object|string} message
*/
......
......@@ -74,6 +74,15 @@ WebInspector.Target.prototype = {
return (this._capabilitiesMask & capabilitiesMask) === capabilitiesMask;
},
/**
*
* @return {!InspectorBackendClass.Connection}
*/
connection: function()
{
return this._connection;
},
/**
* @param {string} label
* @return {string}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment