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.
5 // TODO(mythria): Remove this after this flag is turned on globally
6 #define V8_IMMINENT_DEPRECATION_WARNINGS
11 #include "test/cctest/cctest.h"
16 static void Cleanup() {
19 "delete hidden_prototype.x;"
20 "delete object[Symbol.unscopables];"
21 "delete hidden_prototype[Symbol.unscopables];");
27 v8::Isolate* isolate = context->GetIsolate();
28 v8::HandleScope handle_scope(isolate);
29 v8::Local<v8::Context> current_context = isolate->GetCurrentContext();
31 v8::Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
32 v8::Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
34 t1->SetHiddenPrototype(true);
36 v8::Local<v8::Object> object = t0->GetFunction(current_context)
38 ->NewInstance(current_context)
40 v8::Local<v8::Object> hidden_prototype = t1->GetFunction(current_context)
42 ->NewInstance(current_context)
45 CHECK(object->SetPrototype(current_context, hidden_prototype).FromJust());
48 ->Set(current_context, v8_str("object"), object)
51 ->Set(current_context, v8_str("hidden_prototype"), hidden_prototype)
54 CHECK_EQ(1, CompileRun("var result;"
61 ->Int32Value(current_context)
65 CHECK_EQ(2, CompileRun("var result;"
67 "hidden_prototype.x = 2;"
72 ->Int32Value(current_context)
76 CHECK_EQ(0, CompileRun("var result;"
79 "object[Symbol.unscopables] = {x: true};"
84 ->Int32Value(current_context)
88 CHECK_EQ(0, CompileRun("var result;"
90 "hidden_prototype.x = 4;"
91 "hidden_prototype[Symbol.unscopables] = {x: true};"
96 ->Int32Value(current_context)
100 CHECK_EQ(0, CompileRun("var result;"
103 "hidden_prototype[Symbol.unscopables] = {x: true};"
108 ->Int32Value(current_context)
112 CHECK_EQ(0, CompileRun("var result;"
114 "hidden_prototype.x = 6;"
115 "object[Symbol.unscopables] = {x: true};"
120 ->Int32Value(current_context)