Skip to content

Commit bccd2f5

Browse files
bnoordhuisMylesBorins
authored andcommitted
v8: handle proxy objects in MakeMirror(), v1
PR-URL: #14343 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4963228 commit bccd2f5

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 5
1212
#define V8_MINOR_VERSION 1
1313
#define V8_BUILD_NUMBER 281
14-
#define V8_PATCH_LEVEL 105
14+
#define V8_PATCH_LEVEL 106
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/runtime/runtime-debug.cc

+4
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) {
310310

311311
DCHECK(args.length() == 2);
312312

313+
if (args[0]->IsJSProxy()) return isolate->heap()->undefined_value();
313314
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
314315
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
315316

@@ -382,6 +383,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetProperty) {
382383

383384
DCHECK(args.length() == 2);
384385

386+
if (args[0]->IsJSProxy()) return isolate->heap()->undefined_value();
385387
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
386388
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
387389

@@ -1318,6 +1320,7 @@ static bool HasInPrototypeChainIgnoringProxies(Isolate* isolate,
13181320
RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
13191321
HandleScope scope(isolate);
13201322
DCHECK(args.length() == 3);
1323+
if (!args[0]->IsJSObject()) return *isolate->factory()->NewJSArray(0);
13211324
CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
13221325
CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1);
13231326
RUNTIME_ASSERT(filter->IsUndefined() || filter->IsJSObject());
@@ -1408,6 +1411,7 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
14081411
RUNTIME_FUNCTION(Runtime_DebugGetPrototype) {
14091412
HandleScope shs(isolate);
14101413
DCHECK(args.length() == 1);
1414+
if (args[0]->IsJSProxy()) return isolate->heap()->undefined_value();
14111415
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
14121416
Handle<Object> prototype;
14131417
// TODO(1543): Come up with a solution for clients to handle potential errors
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const vm = require('vm');
6+
7+
const { MakeMirror } = vm.runInDebugContext('Debug');
8+
const proxy = new Proxy({ x: 1, y: 2 }, { get: Reflect.get });
9+
const mirror = MakeMirror(proxy, /* transient */ true);
10+
11+
assert.strictEqual(mirror.protoObject().value(), undefined);
12+
assert.strictEqual(mirror.className(), 'Object');
13+
assert.strictEqual(mirror.constructorFunction().value(), undefined);
14+
assert.strictEqual(mirror.prototypeObject().value(), undefined);
15+
assert.strictEqual(mirror.hasNamedInterceptor(), false);
16+
assert.strictEqual(mirror.hasIndexedInterceptor(), false);
17+
assert.strictEqual(mirror.referencedBy(1).length, 0);
18+
assert.strictEqual(mirror.toText(), '#<Object>');
19+
20+
const propertyNames = mirror.propertyNames();
21+
const DebugContextArray = propertyNames.constructor;
22+
assert.deepStrictEqual(propertyNames, DebugContextArray.from(['x', 'y']));
23+
24+
const properties = mirror.properties();
25+
assert.strictEqual(properties.length, 2);
26+
// UndefinedMirror because V8 cannot retrieve the values without invoking
27+
// the handler. Could be turned a PropertyMirror but mirror.value() would
28+
// still be an UndefinedMirror. This seems Good Enough for now.
29+
assert(properties[0].isUndefined());
30+
assert(properties[1].isUndefined());

0 commit comments

Comments
 (0)