OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 9165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9176 ExpectTrue("propertyIsEnumerable.call(other, '239')"); | 9176 ExpectTrue("propertyIsEnumerable.call(other, '239')"); |
9177 allowed_access_type[v8::ACCESS_HAS] = false; | 9177 allowed_access_type[v8::ACCESS_HAS] = false; |
9178 | 9178 |
9179 // Access a property with JS accessor. | 9179 // Access a property with JS accessor. |
9180 CompileRun("other.js_accessor_p = 2"); | 9180 CompileRun("other.js_accessor_p = 2"); |
9181 | 9181 |
9182 ExpectUndefined("other.js_accessor_p"); | 9182 ExpectUndefined("other.js_accessor_p"); |
9183 ExpectUndefined( | 9183 ExpectUndefined( |
9184 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p')"); | 9184 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p')"); |
9185 | 9185 |
9186 // Enable ACCESS_HAS. | |
9187 allowed_access_type[v8::ACCESS_HAS] = true; | |
9188 ExpectUndefined("other.js_accessor_p"); | |
9189 ExpectUndefined( | |
9190 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get"); | |
9191 ExpectUndefined( | |
9192 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set"); | |
9193 ExpectUndefined( | |
9194 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value"); | |
9195 allowed_access_type[v8::ACCESS_HAS] = false; | |
9196 | |
9197 // Enable both ACCESS_HAS and ACCESS_GET. | 9186 // Enable both ACCESS_HAS and ACCESS_GET. |
9198 allowed_access_type[v8::ACCESS_HAS] = true; | 9187 allowed_access_type[v8::ACCESS_HAS] = true; |
9199 allowed_access_type[v8::ACCESS_GET] = true; | 9188 allowed_access_type[v8::ACCESS_GET] = true; |
9200 | 9189 |
9201 ExpectString("other.js_accessor_p", "getter"); | 9190 ExpectString("other.js_accessor_p", "getter"); |
9202 ExpectObject( | 9191 ExpectObject( |
9203 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get", getter); | 9192 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get", getter); |
9204 ExpectUndefined( | |
9205 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set"); | |
9206 ExpectUndefined( | |
9207 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value"); | |
9208 | |
9209 allowed_access_type[v8::ACCESS_GET] = false; | |
9210 allowed_access_type[v8::ACCESS_HAS] = false; | |
9211 | |
9212 // Enable both ACCESS_HAS and ACCESS_SET. | |
9213 allowed_access_type[v8::ACCESS_HAS] = true; | |
9214 allowed_access_type[v8::ACCESS_SET] = true; | |
9215 | |
9216 ExpectUndefined("other.js_accessor_p"); | |
9217 ExpectUndefined( | |
9218 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get"); | |
9219 ExpectObject( | |
9220 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set", setter); | |
9221 ExpectUndefined( | |
9222 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value"); | |
9223 | |
9224 allowed_access_type[v8::ACCESS_SET] = false; | |
9225 allowed_access_type[v8::ACCESS_HAS] = false; | |
9226 | |
9227 // Enable both ACCESS_HAS, ACCESS_GET and ACCESS_SET. | |
9228 allowed_access_type[v8::ACCESS_HAS] = true; | |
9229 allowed_access_type[v8::ACCESS_GET] = true; | |
9230 allowed_access_type[v8::ACCESS_SET] = true; | |
9231 | |
9232 ExpectString("other.js_accessor_p", "getter"); | |
9233 ExpectObject( | |
9234 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').get", getter); | |
9235 ExpectObject( | 9193 ExpectObject( |
9236 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set", setter); | 9194 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').set", setter); |
9237 ExpectUndefined( | 9195 ExpectUndefined( |
9238 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value"); | 9196 "Object.getOwnPropertyDescriptor(other, 'js_accessor_p').value"); |
9239 | 9197 |
9240 allowed_access_type[v8::ACCESS_SET] = false; | 9198 allowed_access_type[v8::ACCESS_HAS] = false; |
9241 allowed_access_type[v8::ACCESS_GET] = false; | 9199 allowed_access_type[v8::ACCESS_GET] = false; |
9242 allowed_access_type[v8::ACCESS_HAS] = false; | |
9243 | 9200 |
9244 // Access an element with JS accessor. | 9201 // Access an element with JS accessor. |
9245 CompileRun("other[42] = 2"); | 9202 CompileRun("other[42] = 2"); |
9246 | 9203 |
9247 ExpectUndefined("other[42]"); | 9204 ExpectUndefined("other[42]"); |
9248 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42')"); | 9205 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42')"); |
9249 | 9206 |
9250 // Enable ACCESS_HAS. | |
9251 allowed_access_type[v8::ACCESS_HAS] = true; | |
9252 ExpectUndefined("other[42]"); | |
9253 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').get"); | |
9254 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').set"); | |
9255 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value"); | |
9256 allowed_access_type[v8::ACCESS_HAS] = false; | |
9257 | |
9258 // Enable both ACCESS_HAS and ACCESS_GET. | 9207 // Enable both ACCESS_HAS and ACCESS_GET. |
9259 allowed_access_type[v8::ACCESS_HAS] = true; | 9208 allowed_access_type[v8::ACCESS_HAS] = true; |
9260 allowed_access_type[v8::ACCESS_GET] = true; | 9209 allowed_access_type[v8::ACCESS_GET] = true; |
9261 | 9210 |
9262 ExpectString("other[42]", "el_getter"); | 9211 ExpectString("other[42]", "el_getter"); |
9263 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').get", el_getter); | 9212 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').get", el_getter); |
9264 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').set"); | |
9265 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value"); | |
9266 | |
9267 allowed_access_type[v8::ACCESS_GET] = false; | |
9268 allowed_access_type[v8::ACCESS_HAS] = false; | |
9269 | |
9270 // Enable both ACCESS_HAS and ACCESS_SET. | |
9271 allowed_access_type[v8::ACCESS_HAS] = true; | |
9272 allowed_access_type[v8::ACCESS_SET] = true; | |
9273 | |
9274 ExpectUndefined("other[42]"); | |
9275 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').get"); | |
9276 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').set", el_setter); | 9213 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').set", el_setter); |
9277 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value"); | 9214 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value"); |
9278 | 9215 |
9279 allowed_access_type[v8::ACCESS_SET] = false; | |
9280 allowed_access_type[v8::ACCESS_HAS] = false; | 9216 allowed_access_type[v8::ACCESS_HAS] = false; |
9281 | |
9282 // Enable both ACCESS_HAS, ACCESS_GET and ACCESS_SET. | |
9283 allowed_access_type[v8::ACCESS_HAS] = true; | |
9284 allowed_access_type[v8::ACCESS_GET] = true; | |
9285 allowed_access_type[v8::ACCESS_SET] = true; | |
9286 | |
9287 ExpectString("other[42]", "el_getter"); | |
9288 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').get", el_getter); | |
9289 ExpectObject("Object.getOwnPropertyDescriptor(other, '42').set", el_setter); | |
9290 ExpectUndefined("Object.getOwnPropertyDescriptor(other, '42').value"); | |
9291 | |
9292 allowed_access_type[v8::ACCESS_SET] = false; | |
9293 allowed_access_type[v8::ACCESS_GET] = false; | 9217 allowed_access_type[v8::ACCESS_GET] = false; |
9294 allowed_access_type[v8::ACCESS_HAS] = false; | |
9295 | 9218 |
9296 v8::Handle<Value> value; | 9219 v8::Handle<Value> value; |
9297 | 9220 |
9298 // Access accessible property | 9221 // Access accessible property |
9299 value = CompileRun("other.accessible_prop = 3"); | 9222 value = CompileRun("other.accessible_prop = 3"); |
9300 CHECK(value->IsNumber()); | 9223 CHECK(value->IsNumber()); |
9301 CHECK_EQ(3, value->Int32Value()); | 9224 CHECK_EQ(3, value->Int32Value()); |
9302 CHECK_EQ(3, g_echo_value_1); | 9225 CHECK_EQ(3, g_echo_value_1); |
9303 | 9226 |
9304 // Access accessible js property | 9227 // Access accessible js property |
(...skipping 13494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22799 call_eval_context = v8::Context::New(isolate); | 22722 call_eval_context = v8::Context::New(isolate); |
22800 v8::Context::Scope scope(call_eval_context); | 22723 v8::Context::Scope scope(call_eval_context); |
22801 call_eval_bound_function = | 22724 call_eval_bound_function = |
22802 Local<Function>::Cast(CompileRun("eval.bind(this, '1')")); | 22725 Local<Function>::Cast(CompileRun("eval.bind(this, '1')")); |
22803 } | 22726 } |
22804 env->Global()->Set(v8_str("CallEval"), | 22727 env->Global()->Set(v8_str("CallEval"), |
22805 v8::FunctionTemplate::New(isolate, CallEval)->GetFunction()); | 22728 v8::FunctionTemplate::New(isolate, CallEval)->GetFunction()); |
22806 Local<Value> result = CompileRun("CallEval();"); | 22729 Local<Value> result = CompileRun("CallEval();"); |
22807 CHECK_EQ(result, v8::Integer::New(isolate, 1)); | 22730 CHECK_EQ(result, v8::Integer::New(isolate, 1)); |
22808 } | 22731 } |
OLD | NEW |