Commit 46d815e7 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

inspector: add lengths for binary data descriptions

This CL adds support for ArrayBuffer and SharedArrayBuffer subtypes for injected
script source. It also adds the byteLength/size to the description of these
objects and for the upcoming "blob" subtype when appropriate.

This is dependent on a DevTools frontend patch to accept these new subtypes:
https://chromium-review.googlesource.com/c/582427/

Bug: chromium:653620
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: If8f612b54e82e6fd2f056545bd521868ba7349fd
Reviewed-on: https://chromium-review.googlesource.com/582233
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46851}
parent fe18ad65
...@@ -627,12 +627,18 @@ InjectedScript.prototype = { ...@@ -627,12 +627,18 @@ InjectedScript.prototype = {
return className; return className;
} }
if (subtype === "map" || subtype === "set") { if (subtype === "map" || subtype === "set" || subtype === "blob") {
if (typeof obj.size === "number") if (typeof obj.size === "number")
return className + "(" + obj.size + ")"; return className + "(" + obj.size + ")";
return className; return className;
} }
if (subtype === "arraybuffer" || subtype === "dataview") {
if (typeof obj.byteLength === "number")
return className + "(" + obj.byteLength + ")";
return className;
}
if (typeof obj === "function") if (typeof obj === "function")
return toString(obj); return toString(obj);
......
...@@ -219,6 +219,14 @@ void V8InjectedScriptHost::subtypeCallback( ...@@ -219,6 +219,14 @@ void V8InjectedScriptHost::subtypeCallback(
info.GetReturnValue().Set(toV8StringInternalized(isolate, "promise")); info.GetReturnValue().Set(toV8StringInternalized(isolate, "promise"));
return; return;
} }
if (value->IsArrayBuffer() || value->IsSharedArrayBuffer()) {
info.GetReturnValue().Set(toV8StringInternalized(isolate, "arraybuffer"));
return;
}
if (value->IsDataView()) {
info.GetReturnValue().Set(toV8StringInternalized(isolate, "dataview"));
return;
}
std::unique_ptr<StringBuffer> subtype = std::unique_ptr<StringBuffer> subtype =
unwrapInspector(info)->client()->valueSubtype(value); unwrapInspector(info)->client()->valueSubtype(value);
if (subtype) { if (subtype) {
......
...@@ -7,6 +7,12 @@ Array(0) ...@@ -7,6 +7,12 @@ Array(0)
Array(2) Array(2)
Uint8Array(0) Uint8Array(0)
Uint8Array(2) Uint8Array(2)
ArrayBuffer(0)
ArrayBuffer(2)
SharedArrayBuffer(0)
SharedArrayBuffer(2)
DataView(0)
DataView(5)
WeakMap WeakMap
WeakSet WeakSet
Set(0) Set(0)
...@@ -17,5 +23,11 @@ Array(0) ...@@ -17,5 +23,11 @@ Array(0)
Array(2) Array(2)
Uint8Array(0) Uint8Array(0)
Uint8Array(2) Uint8Array(2)
ArrayBuffer(0)
ArrayBuffer(2)
SharedArrayBuffer(0)
SharedArrayBuffer(2)
DataView(0)
DataView(5)
WeakMap WeakMap
WeakSet WeakSet
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
let {session, contextGroup, Protocol} = InspectorTest.start("Test that descriptions for arrays, maps, and sets include the correct length or size.") // Flags: --harmony-sharedarraybuffer
let {session, contextGroup, Protocol} = InspectorTest.start("Test that descriptions for arrays, maps, and sets include the correct length or size.");
contextGroup.setupInjectedScriptEnvironment(); contextGroup.setupInjectedScriptEnvironment();
...@@ -15,6 +17,12 @@ Promise.all([ ...@@ -15,6 +17,12 @@ Promise.all([
testExpression("new Array(2)"), testExpression("new Array(2)"),
testExpression("new Uint8Array()"), testExpression("new Uint8Array()"),
testExpression("new Uint8Array(2)"), testExpression("new Uint8Array(2)"),
testExpression("new ArrayBuffer()"),
testExpression("new ArrayBuffer(2)"),
testExpression("new SharedArrayBuffer()"),
testExpression("new SharedArrayBuffer(2)"),
testExpression("new DataView(new ArrayBuffer())"),
testExpression("new DataView(new ArrayBuffer(5))"),
// WeakMap and WeakSet should not have size in description. // WeakMap and WeakSet should not have size in description.
testExpression("new WeakMap([[{}, 42]])"), testExpression("new WeakMap([[{}, 42]])"),
testExpression("new WeakSet([{}])") testExpression("new WeakSet([{}])")
......
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