Commit a55e009f authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

inspector: simplify preview generator for Error objects

- we can avoid using regexps,
- this CL also fixed a bug.

R=alph@chromium.org

Bug: chromium:870957
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I9799507b85942be454a7c20d2768fe7442fc965e
Reviewed-on: https://chromium-review.googlesource.com/1250403
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarAlexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56295}
parent 7b32eb8c
......@@ -661,16 +661,15 @@ InjectedScript.prototype = {
if (InjectedScriptHost.subtype(obj) === "error") {
try {
var stack = obj.stack;
var message = obj.message && obj.message.length ? ": " + obj.message : "";
var firstCallFrame = /^\s+at\s/m.exec(stack);
var stackMessageEnd = firstCallFrame ? firstCallFrame.index : -1;
if (stackMessageEnd !== -1) {
var stackTrace = stack.substr(stackMessageEnd);
return className + message + "\n" + stackTrace;
}
return className + message;
const stack = obj.stack;
if (stack.substr(0, className.length) === className)
return stack;
const message = obj.message;
const index = /* suppressBlacklist */ stack.indexOf(message);
const messageWithStack = index !== -1 ? stack.substr(index) : message;
return className + ': ' + messageWithStack;
} catch(e) {
return className;
}
}
......
Checks preview for Error object
{
className : TypeError
description : TypeError: []. at is not a function at <anonymous>:1:15
objectId : <objectId>
subtype : error
type : object
}
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const {session, contextGroup, Protocol} = InspectorTest.start(
'Checks preview for Error object');
(async function test() {
const { result: { result } } = await Protocol.Runtime.evaluate({
expression: `[]['\\n at']()`,
generatePreview: true
});
InspectorTest.logMessage(result);
InspectorTest.completeTest();
})()
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