OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "gin/arguments.h" | 6 #include "gin/arguments.h" |
7 #include "gin/handle.h" | 7 #include "gin/handle.h" |
8 #include "gin/interceptor.h" | 8 #include "gin/interceptor.h" |
9 #include "gin/object_template_builder.h" | 9 #include "gin/object_template_builder.h" |
10 #include "gin/per_isolate_data.h" | 10 #include "gin/per_isolate_data.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 v8::HandleScope handle_scope(isolate); | 132 v8::HandleScope handle_scope(isolate); |
133 | 133 |
134 gin::Handle<MyInterceptor> obj = MyInterceptor::Create(isolate); | 134 gin::Handle<MyInterceptor> obj = MyInterceptor::Create(isolate); |
135 | 135 |
136 obj->set_value(42); | 136 obj->set_value(42); |
137 EXPECT_EQ(42, obj->value()); | 137 EXPECT_EQ(42, obj->value()); |
138 | 138 |
139 v8::Local<v8::String> source = StringToV8(isolate, script_source); | 139 v8::Local<v8::String> source = StringToV8(isolate, script_source); |
140 EXPECT_FALSE(source.IsEmpty()); | 140 EXPECT_FALSE(source.IsEmpty()); |
141 | 141 |
142 gin::TryCatch try_catch; | 142 gin::TryCatch try_catch(isolate); |
143 v8::Local<v8::Script> script = v8::Script::Compile(source); | 143 v8::Local<v8::Script> script = v8::Script::Compile(source); |
144 EXPECT_FALSE(script.IsEmpty()); | 144 EXPECT_FALSE(script.IsEmpty()); |
145 v8::Local<v8::Value> val = script->Run(); | 145 v8::Local<v8::Value> val = script->Run(); |
146 EXPECT_FALSE(val.IsEmpty()); | 146 EXPECT_FALSE(val.IsEmpty()); |
147 v8::Local<v8::Function> func; | 147 v8::Local<v8::Function> func; |
148 EXPECT_TRUE(ConvertFromV8(isolate, val, &func)); | 148 EXPECT_TRUE(ConvertFromV8(isolate, val, &func)); |
149 v8::Local<v8::Value> argv[] = {ConvertToV8(isolate, obj.get()), }; | 149 v8::Local<v8::Value> argv[] = {ConvertToV8(isolate, obj.get()), }; |
150 func->Call(v8::Undefined(isolate), 1, argv); | 150 func->Call(v8::Undefined(isolate), 1, argv); |
151 EXPECT_FALSE(try_catch.HasCaught()); | 151 EXPECT_FALSE(try_catch.HasCaught()); |
152 EXPECT_EQ("", try_catch.GetStackTrace()); | 152 EXPECT_EQ("", try_catch.GetStackTrace()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 TEST_F(InterceptorTest, BypassInterceptorForbidden) { | 187 TEST_F(InterceptorTest, BypassInterceptorForbidden) { |
188 RunInterceptorTest( | 188 RunInterceptorTest( |
189 "(function (obj) {" | 189 "(function (obj) {" |
190 " obj.value = 191 /* make test happy */;" | 190 " obj.value = 191 /* make test happy */;" |
191 " obj[1] = 23;" | 191 " obj[1] = 23;" |
192 " if (obj[1] === 23) throw 'FAIL'; })"); | 192 " if (obj[1] === 23) throw 'FAIL'; })"); |
193 } | 193 } |
194 | 194 |
195 } // namespace gin | 195 } // namespace gin |
OLD | NEW |