fix: send null in debugger callback when no error (#14814)
Fixes #13811
This commit is contained in:
parent
985d35fc1c
commit
7dc7cd1d89
2 changed files with 8 additions and 4 deletions
|
@ -67,14 +67,17 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
||||||
return;
|
return;
|
||||||
base::DictionaryValue* error_body = nullptr;
|
base::DictionaryValue* error_body = nullptr;
|
||||||
base::DictionaryValue error;
|
base::DictionaryValue error;
|
||||||
if (dict->GetDictionary("error", &error_body))
|
bool has_error;
|
||||||
|
if ((has_error = dict->GetDictionary("error", &error_body))) {
|
||||||
error.Swap(error_body);
|
error.Swap(error_body);
|
||||||
|
}
|
||||||
|
|
||||||
base::DictionaryValue* result_body = nullptr;
|
base::DictionaryValue* result_body = nullptr;
|
||||||
base::DictionaryValue result;
|
base::DictionaryValue result;
|
||||||
if (dict->GetDictionary("result", &result_body))
|
if (dict->GetDictionary("result", &result_body))
|
||||||
result.Swap(result_body);
|
result.Swap(result_body);
|
||||||
send_command_callback.Run(error, result);
|
send_command_callback.Run(has_error ? error.Clone() : base::Value(),
|
||||||
|
result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ describe('debugger module', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const callback = (err, res) => {
|
const callback = (err, res) => {
|
||||||
expect(err.message).to.be.undefined()
|
expect(err).to.be.null()
|
||||||
expect(res.wasThrown).to.be.undefined()
|
expect(res.wasThrown).to.be.undefined()
|
||||||
expect(res.result.value).to.equal(6)
|
expect(res.result.value).to.equal(6)
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ describe('debugger module', () => {
|
||||||
return done(`unexpected error : ${err}`)
|
return done(`unexpected error : ${err}`)
|
||||||
}
|
}
|
||||||
const callback = (err, res) => {
|
const callback = (err, res) => {
|
||||||
expect(err.message).to.be.undefined()
|
expect(err).to.be.null()
|
||||||
expect(res.wasThrown).to.be.undefined()
|
expect(res.wasThrown).to.be.undefined()
|
||||||
expect(res.result.value).to.equal(6)
|
expect(res.result.value).to.equal(6)
|
||||||
w.webContents.debugger.detach()
|
w.webContents.debugger.detach()
|
||||||
|
@ -178,6 +178,7 @@ describe('debugger module', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
w.webContents.debugger.sendCommand('Test', err => {
|
w.webContents.debugger.sendCommand('Test', err => {
|
||||||
|
expect(err).to.not.be.null()
|
||||||
expect(err.message).to.equal("'Test' wasn't found")
|
expect(err.message).to.equal("'Test' wasn't found")
|
||||||
w.webContents.debugger.detach()
|
w.webContents.debugger.detach()
|
||||||
done()
|
done()
|
||||||
|
|
Loading…
Reference in a new issue