OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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. | |
4 | |
5 #include <stdlib.h> | |
6 | |
7 #include "src/v8.h" | |
8 #include "test/cctest/cctest.h" | |
9 | |
10 | |
11 TEST(Proxy) { | |
Yang
2015/12/22 14:47:55
I would have put this in test-api.cc, where all ot
Camillo Bruni
2015/12/22 14:52:24
can do, I preferred a separate file ;)
| |
12 i::FLAG_harmony_proxies = true; | |
13 LocalContext context; | |
14 v8::Isolate* isolate = CcTest::isolate(); | |
15 v8::HandleScope scope(isolate); | |
16 v8::Local<v8::Object> target = CompileRun("({})").As<v8::Object>(); | |
17 v8::Local<v8::Object> handler = CompileRun("({})").As<v8::Object>(); | |
18 | |
19 v8::Local<v8::Proxy> proxy = | |
20 v8::Proxy::New(context.local(), target, handler).ToLocalChecked(); | |
21 CHECK(proxy->IsProxy()); | |
22 CHECK(!target->IsProxy()); | |
23 CHECK(!proxy->IsRevoked()); | |
24 CHECK(proxy->GetTarget()->SameValue(target)); | |
25 CHECK(proxy->GetHandler()->SameValue(handler)); | |
26 | |
27 proxy->Revoke(); | |
28 CHECK(proxy->IsProxy()); | |
29 CHECK(!target->IsProxy()); | |
30 CHECK(proxy->IsRevoked()); | |
31 CHECK(proxy->GetTarget()->SameValue(target)); | |
32 CHECK(proxy->GetHandler()->IsNull()); | |
33 } | |
OLD | NEW |