1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "test/cctest/cctest.h"
13 static void Cleanup() {
16 "delete hidden_prototype.x;"
17 "delete object[Symbol.unscopables];"
18 "delete hidden_prototype[Symbol.unscopables];");
24 v8::Isolate* isolate = context->GetIsolate();
25 v8::HandleScope handle_scope(isolate);
27 v8::Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
28 v8::Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
30 t1->SetHiddenPrototype(true);
32 v8::Local<v8::Object> object = t0->GetFunction()->NewInstance();
33 v8::Local<v8::Object> hidden_prototype = t1->GetFunction()->NewInstance();
35 object->SetPrototype(hidden_prototype);
37 context->Global()->Set(v8_str("object"), object);
38 context->Global()->Set(v8_str("hidden_prototype"), hidden_prototype);
40 CHECK_EQ(1, CompileRun(
47 "result")->Int32Value());
50 CHECK_EQ(2, CompileRun(
53 "hidden_prototype.x = 2;"
57 "result")->Int32Value());
60 CHECK_EQ(0, CompileRun(
64 "object[Symbol.unscopables] = {x: true};"
68 "result")->Int32Value());
71 CHECK_EQ(0, CompileRun(
74 "hidden_prototype.x = 4;"
75 "hidden_prototype[Symbol.unscopables] = {x: true};"
79 "result")->Int32Value());
82 CHECK_EQ(0, CompileRun(
86 "hidden_prototype[Symbol.unscopables] = {x: true};"
90 "result;")->Int32Value());
93 CHECK_EQ(0, CompileRun(
96 "hidden_prototype.x = 6;"
97 "object[Symbol.unscopables] = {x: true};"
101 "result")->Int32Value());