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 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 CHECK_EQ(v8_num(637), info.Data()); | 2523 CHECK_EQ(v8_num(637), info.Data()); |
2524 echo_indexed_call_count++; | 2524 echo_indexed_call_count++; |
2525 info.GetReturnValue().Set(v8_num(index)); | 2525 info.GetReturnValue().Set(v8_num(index)); |
2526 } | 2526 } |
2527 | 2527 |
2528 | 2528 |
2529 THREADED_TEST(IndexedPropertyHandlerGetter) { | 2529 THREADED_TEST(IndexedPropertyHandlerGetter) { |
2530 v8::Isolate* isolate = CcTest::isolate(); | 2530 v8::Isolate* isolate = CcTest::isolate(); |
2531 v8::HandleScope scope(isolate); | 2531 v8::HandleScope scope(isolate); |
2532 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 2532 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
2533 templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, | 2533 templ->InstanceTemplate()->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
2534 0, 0, 0, 0, | 2534 EchoIndexedProperty, 0, 0, 0, 0, v8_num(637))); |
2535 v8_num(637)); | |
2536 LocalContext env; | 2535 LocalContext env; |
2537 env->Global()->Set(v8_str("obj"), | 2536 env->Global()->Set(v8_str("obj"), |
2538 templ->GetFunction()->NewInstance()); | 2537 templ->GetFunction()->NewInstance()); |
2539 Local<Script> script = v8_compile("obj[900]"); | 2538 Local<Script> script = v8_compile("obj[900]"); |
2540 CHECK_EQ(script->Run()->Int32Value(), 900); | 2539 CHECK_EQ(script->Run()->Int32Value(), 900); |
2541 } | 2540 } |
2542 | 2541 |
2543 | 2542 |
2544 v8::Handle<v8::Object> bottom; | 2543 v8::Handle<v8::Object> bottom; |
2545 | 2544 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 } | 2625 } |
2627 | 2626 |
2628 | 2627 |
2629 THREADED_PROFILED_TEST(PropertyHandlerInPrototype) { | 2628 THREADED_PROFILED_TEST(PropertyHandlerInPrototype) { |
2630 LocalContext env; | 2629 LocalContext env; |
2631 v8::Isolate* isolate = env->GetIsolate(); | 2630 v8::Isolate* isolate = env->GetIsolate(); |
2632 v8::HandleScope scope(isolate); | 2631 v8::HandleScope scope(isolate); |
2633 | 2632 |
2634 // Set up a prototype chain with three interceptors. | 2633 // Set up a prototype chain with three interceptors. |
2635 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 2634 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
2636 templ->InstanceTemplate()->SetIndexedPropertyHandler( | 2635 templ->InstanceTemplate()->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
2637 CheckThisIndexedPropertyHandler, | 2636 CheckThisIndexedPropertyHandler, CheckThisIndexedPropertySetter, |
2638 CheckThisIndexedPropertySetter, | 2637 CheckThisIndexedPropertyQuery, CheckThisIndexedPropertyDeleter, |
2639 CheckThisIndexedPropertyQuery, | 2638 CheckThisIndexedPropertyEnumerator)); |
2640 CheckThisIndexedPropertyDeleter, | |
2641 CheckThisIndexedPropertyEnumerator); | |
2642 | 2639 |
2643 templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( | 2640 templ->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( |
2644 CheckThisNamedPropertyHandler, CheckThisNamedPropertySetter, | 2641 CheckThisNamedPropertyHandler, CheckThisNamedPropertySetter, |
2645 CheckThisNamedPropertyQuery, CheckThisNamedPropertyDeleter, | 2642 CheckThisNamedPropertyQuery, CheckThisNamedPropertyDeleter, |
2646 CheckThisNamedPropertyEnumerator)); | 2643 CheckThisNamedPropertyEnumerator)); |
2647 | 2644 |
2648 bottom = templ->GetFunction()->NewInstance(); | 2645 bottom = templ->GetFunction()->NewInstance(); |
2649 Local<v8::Object> top = templ->GetFunction()->NewInstance(); | 2646 Local<v8::Object> top = templ->GetFunction()->NewInstance(); |
2650 Local<v8::Object> middle = templ->GetFunction()->NewInstance(); | 2647 Local<v8::Object> middle = templ->GetFunction()->NewInstance(); |
2651 | 2648 |
(...skipping 3799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6451 if (index == 39) { | 6448 if (index == 39) { |
6452 info.GetReturnValue().Set(value); | 6449 info.GetReturnValue().Set(value); |
6453 } | 6450 } |
6454 } | 6451 } |
6455 | 6452 |
6456 | 6453 |
6457 THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { | 6454 THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { |
6458 v8::Isolate* isolate = CcTest::isolate(); | 6455 v8::Isolate* isolate = CcTest::isolate(); |
6459 v8::HandleScope scope(isolate); | 6456 v8::HandleScope scope(isolate); |
6460 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6457 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6461 templ->SetIndexedPropertyHandler(IndexedPropertyGetter, | 6458 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
6462 IndexedPropertySetter); | 6459 IndexedPropertyGetter, IndexedPropertySetter)); |
6463 LocalContext context; | 6460 LocalContext context; |
6464 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6461 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6465 Local<Script> getter_script = v8_compile( | 6462 Local<Script> getter_script = v8_compile( |
6466 "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];"); | 6463 "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];"); |
6467 Local<Script> setter_script = v8_compile( | 6464 Local<Script> setter_script = v8_compile( |
6468 "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" | 6465 "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" |
6469 "obj[17] = 23;" | 6466 "obj[17] = 23;" |
6470 "obj.foo;"); | 6467 "obj.foo;"); |
6471 Local<Script> interceptor_setter_script = v8_compile( | 6468 Local<Script> interceptor_setter_script = v8_compile( |
6472 "obj.__defineSetter__(\"39\", function(val){this.foo = \"hit\";});" | 6469 "obj.__defineSetter__(\"39\", function(val){this.foo = \"hit\";});" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6517 info.GetReturnValue().Set(Local<v8::Array>::Cast(result)); | 6514 info.GetReturnValue().Set(Local<v8::Array>::Cast(result)); |
6518 } | 6515 } |
6519 | 6516 |
6520 | 6517 |
6521 // Make sure that the the interceptor code in the runtime properly handles | 6518 // Make sure that the the interceptor code in the runtime properly handles |
6522 // merging property name lists for double-array-backed arrays. | 6519 // merging property name lists for double-array-backed arrays. |
6523 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { | 6520 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { |
6524 v8::Isolate* isolate = CcTest::isolate(); | 6521 v8::Isolate* isolate = CcTest::isolate(); |
6525 v8::HandleScope scope(isolate); | 6522 v8::HandleScope scope(isolate); |
6526 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6523 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6527 templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter, | 6524 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
6528 UnboxedDoubleIndexedPropertySetter, | 6525 UnboxedDoubleIndexedPropertyGetter, UnboxedDoubleIndexedPropertySetter, 0, |
6529 0, | 6526 0, UnboxedDoubleIndexedPropertyEnumerator)); |
6530 0, | |
6531 UnboxedDoubleIndexedPropertyEnumerator); | |
6532 LocalContext context; | 6527 LocalContext context; |
6533 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6528 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6534 // When obj is created, force it to be Stored in a FastDoubleArray. | 6529 // When obj is created, force it to be Stored in a FastDoubleArray. |
6535 Local<Script> create_unboxed_double_script = v8_compile( | 6530 Local<Script> create_unboxed_double_script = v8_compile( |
6536 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " | 6531 "obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " |
6537 "key_count = 0; " | 6532 "key_count = 0; " |
6538 "for (x in obj) {key_count++;};" | 6533 "for (x in obj) {key_count++;};" |
6539 "obj;"); | 6534 "obj;"); |
6540 Local<Value> result = create_unboxed_double_script->Run(); | 6535 Local<Value> result = create_unboxed_double_script->Run(); |
6541 CHECK(result->ToObject(isolate)->HasRealIndexedProperty(2000)); | 6536 CHECK(result->ToObject(isolate)->HasRealIndexedProperty(2000)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6573 } | 6568 } |
6574 } | 6569 } |
6575 | 6570 |
6576 | 6571 |
6577 // Make sure that the the interceptor code in the runtime properly handles | 6572 // Make sure that the the interceptor code in the runtime properly handles |
6578 // merging property name lists for non-string arguments arrays. | 6573 // merging property name lists for non-string arguments arrays. |
6579 THREADED_TEST(IndexedInterceptorSloppyArgsWithIndexedAccessor) { | 6574 THREADED_TEST(IndexedInterceptorSloppyArgsWithIndexedAccessor) { |
6580 v8::Isolate* isolate = CcTest::isolate(); | 6575 v8::Isolate* isolate = CcTest::isolate(); |
6581 v8::HandleScope scope(isolate); | 6576 v8::HandleScope scope(isolate); |
6582 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6577 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6583 templ->SetIndexedPropertyHandler(SloppyIndexedPropertyGetter, | 6578 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
6584 0, | 6579 SloppyIndexedPropertyGetter, 0, 0, 0, |
6585 0, | 6580 SloppyArgsIndexedPropertyEnumerator)); |
6586 0, | |
6587 SloppyArgsIndexedPropertyEnumerator); | |
6588 LocalContext context; | 6581 LocalContext context; |
6589 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6582 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6590 Local<Script> create_args_script = v8_compile( | 6583 Local<Script> create_args_script = v8_compile( |
6591 "var key_count = 0;" | 6584 "var key_count = 0;" |
6592 "for (x in obj) {key_count++;} key_count;"); | 6585 "for (x in obj) {key_count++;} key_count;"); |
6593 Local<Value> result = create_args_script->Run(); | 6586 Local<Value> result = create_args_script->Run(); |
6594 CHECK_EQ(v8_num(4), result); | 6587 CHECK_EQ(v8_num(4), result); |
6595 } | 6588 } |
6596 | 6589 |
6597 | 6590 |
6598 static void IdentityIndexedPropertyGetter( | 6591 static void IdentityIndexedPropertyGetter( |
6599 uint32_t index, | 6592 uint32_t index, |
6600 const v8::PropertyCallbackInfo<v8::Value>& info) { | 6593 const v8::PropertyCallbackInfo<v8::Value>& info) { |
6601 info.GetReturnValue().Set(index); | 6594 info.GetReturnValue().Set(index); |
6602 } | 6595 } |
6603 | 6596 |
6604 | 6597 |
6605 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { | 6598 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { |
6606 v8::Isolate* isolate = CcTest::isolate(); | 6599 v8::Isolate* isolate = CcTest::isolate(); |
6607 v8::HandleScope scope(isolate); | 6600 v8::HandleScope scope(isolate); |
6608 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6601 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6609 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6602 templ->SetHandler( |
| 6603 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6610 | 6604 |
6611 LocalContext context; | 6605 LocalContext context; |
6612 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6606 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6613 | 6607 |
6614 // Check fast object case. | 6608 // Check fast object case. |
6615 const char* fast_case_code = | 6609 const char* fast_case_code = |
6616 "Object.getOwnPropertyDescriptor(obj, 0).value.toString()"; | 6610 "Object.getOwnPropertyDescriptor(obj, 0).value.toString()"; |
6617 ExpectString(fast_case_code, "0"); | 6611 ExpectString(fast_case_code, "0"); |
6618 | 6612 |
6619 // Check slow case. | 6613 // Check slow case. |
6620 const char* slow_case_code = | 6614 const char* slow_case_code = |
6621 "obj.x = 1; delete obj.x;" | 6615 "obj.x = 1; delete obj.x;" |
6622 "Object.getOwnPropertyDescriptor(obj, 1).value.toString()"; | 6616 "Object.getOwnPropertyDescriptor(obj, 1).value.toString()"; |
6623 ExpectString(slow_case_code, "1"); | 6617 ExpectString(slow_case_code, "1"); |
6624 } | 6618 } |
6625 | 6619 |
6626 | 6620 |
6627 THREADED_TEST(IndexedInterceptorWithNoSetter) { | 6621 THREADED_TEST(IndexedInterceptorWithNoSetter) { |
6628 v8::Isolate* isolate = CcTest::isolate(); | 6622 v8::Isolate* isolate = CcTest::isolate(); |
6629 v8::HandleScope scope(isolate); | 6623 v8::HandleScope scope(isolate); |
6630 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6624 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6631 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6625 templ->SetHandler( |
| 6626 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6632 | 6627 |
6633 LocalContext context; | 6628 LocalContext context; |
6634 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 6629 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
6635 | 6630 |
6636 const char* code = | 6631 const char* code = |
6637 "try {" | 6632 "try {" |
6638 " obj[0] = 239;" | 6633 " obj[0] = 239;" |
6639 " for (var i = 0; i < 100; i++) {" | 6634 " for (var i = 0; i < 100; i++) {" |
6640 " var v = obj[0];" | 6635 " var v = obj[0];" |
6641 " if (v != 0) throw 'Wrong value ' + v + ' at iteration ' + i;" | 6636 " if (v != 0) throw 'Wrong value ' + v + ' at iteration ' + i;" |
6642 " }" | 6637 " }" |
6643 " 'PASSED'" | 6638 " 'PASSED'" |
6644 "} catch(e) {" | 6639 "} catch(e) {" |
6645 " e" | 6640 " e" |
6646 "}"; | 6641 "}"; |
6647 ExpectString(code, "PASSED"); | 6642 ExpectString(code, "PASSED"); |
6648 } | 6643 } |
6649 | 6644 |
6650 | 6645 |
6651 THREADED_TEST(IndexedInterceptorWithAccessorCheck) { | 6646 THREADED_TEST(IndexedInterceptorWithAccessorCheck) { |
6652 v8::Isolate* isolate = CcTest::isolate(); | 6647 v8::Isolate* isolate = CcTest::isolate(); |
6653 v8::HandleScope scope(isolate); | 6648 v8::HandleScope scope(isolate); |
6654 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6649 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6655 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6650 templ->SetHandler( |
| 6651 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6656 | 6652 |
6657 LocalContext context; | 6653 LocalContext context; |
6658 Local<v8::Object> obj = templ->NewInstance(); | 6654 Local<v8::Object> obj = templ->NewInstance(); |
6659 obj->TurnOnAccessCheck(); | 6655 obj->TurnOnAccessCheck(); |
6660 context->Global()->Set(v8_str("obj"), obj); | 6656 context->Global()->Set(v8_str("obj"), obj); |
6661 | 6657 |
6662 const char* code = | 6658 const char* code = |
6663 "var result = 'PASSED';" | 6659 "var result = 'PASSED';" |
6664 "for (var i = 0; i < 100; i++) {" | 6660 "for (var i = 0; i < 100; i++) {" |
6665 " try {" | 6661 " try {" |
6666 " var v = obj[0];" | 6662 " var v = obj[0];" |
6667 " result = 'Wrong value ' + v + ' at iteration ' + i;" | 6663 " result = 'Wrong value ' + v + ' at iteration ' + i;" |
6668 " break;" | 6664 " break;" |
6669 " } catch (e) {" | 6665 " } catch (e) {" |
6670 " /* pass */" | 6666 " /* pass */" |
6671 " }" | 6667 " }" |
6672 "}" | 6668 "}" |
6673 "result"; | 6669 "result"; |
6674 ExpectString(code, "PASSED"); | 6670 ExpectString(code, "PASSED"); |
6675 } | 6671 } |
6676 | 6672 |
6677 | 6673 |
6678 THREADED_TEST(IndexedInterceptorWithAccessorCheckSwitchedOn) { | 6674 THREADED_TEST(IndexedInterceptorWithAccessorCheckSwitchedOn) { |
6679 i::FLAG_allow_natives_syntax = true; | 6675 i::FLAG_allow_natives_syntax = true; |
6680 v8::Isolate* isolate = CcTest::isolate(); | 6676 v8::Isolate* isolate = CcTest::isolate(); |
6681 v8::HandleScope scope(isolate); | 6677 v8::HandleScope scope(isolate); |
6682 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6678 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6683 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6679 templ->SetHandler( |
| 6680 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6684 | 6681 |
6685 LocalContext context; | 6682 LocalContext context; |
6686 Local<v8::Object> obj = templ->NewInstance(); | 6683 Local<v8::Object> obj = templ->NewInstance(); |
6687 context->Global()->Set(v8_str("obj"), obj); | 6684 context->Global()->Set(v8_str("obj"), obj); |
6688 | 6685 |
6689 const char* code = | 6686 const char* code = |
6690 "var result = 'PASSED';" | 6687 "var result = 'PASSED';" |
6691 "for (var i = 0; i < 100; i++) {" | 6688 "for (var i = 0; i < 100; i++) {" |
6692 " var expected = i;" | 6689 " var expected = i;" |
6693 " if (i == 5) {" | 6690 " if (i == 5) {" |
(...skipping 17 matching lines...) Expand all Loading... |
6711 "}" | 6708 "}" |
6712 "result"; | 6709 "result"; |
6713 ExpectString(code, "PASSED"); | 6710 ExpectString(code, "PASSED"); |
6714 } | 6711 } |
6715 | 6712 |
6716 | 6713 |
6717 THREADED_TEST(IndexedInterceptorWithDifferentIndices) { | 6714 THREADED_TEST(IndexedInterceptorWithDifferentIndices) { |
6718 v8::Isolate* isolate = CcTest::isolate(); | 6715 v8::Isolate* isolate = CcTest::isolate(); |
6719 v8::HandleScope scope(isolate); | 6716 v8::HandleScope scope(isolate); |
6720 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6717 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6721 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6718 templ->SetHandler( |
| 6719 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6722 | 6720 |
6723 LocalContext context; | 6721 LocalContext context; |
6724 Local<v8::Object> obj = templ->NewInstance(); | 6722 Local<v8::Object> obj = templ->NewInstance(); |
6725 context->Global()->Set(v8_str("obj"), obj); | 6723 context->Global()->Set(v8_str("obj"), obj); |
6726 | 6724 |
6727 const char* code = | 6725 const char* code = |
6728 "try {" | 6726 "try {" |
6729 " for (var i = 0; i < 100; i++) {" | 6727 " for (var i = 0; i < 100; i++) {" |
6730 " var v = obj[i];" | 6728 " var v = obj[i];" |
6731 " if (v != i) throw 'Wrong value ' + v + ' at iteration ' + i;" | 6729 " if (v != i) throw 'Wrong value ' + v + ' at iteration ' + i;" |
6732 " }" | 6730 " }" |
6733 " 'PASSED'" | 6731 " 'PASSED'" |
6734 "} catch(e) {" | 6732 "} catch(e) {" |
6735 " e" | 6733 " e" |
6736 "}"; | 6734 "}"; |
6737 ExpectString(code, "PASSED"); | 6735 ExpectString(code, "PASSED"); |
6738 } | 6736 } |
6739 | 6737 |
6740 | 6738 |
6741 THREADED_TEST(IndexedInterceptorWithNegativeIndices) { | 6739 THREADED_TEST(IndexedInterceptorWithNegativeIndices) { |
6742 v8::Isolate* isolate = CcTest::isolate(); | 6740 v8::Isolate* isolate = CcTest::isolate(); |
6743 v8::HandleScope scope(isolate); | 6741 v8::HandleScope scope(isolate); |
6744 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6742 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6745 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6743 templ->SetHandler( |
| 6744 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6746 | 6745 |
6747 LocalContext context; | 6746 LocalContext context; |
6748 Local<v8::Object> obj = templ->NewInstance(); | 6747 Local<v8::Object> obj = templ->NewInstance(); |
6749 context->Global()->Set(v8_str("obj"), obj); | 6748 context->Global()->Set(v8_str("obj"), obj); |
6750 | 6749 |
6751 const char* code = | 6750 const char* code = |
6752 "try {" | 6751 "try {" |
6753 " for (var i = 0; i < 100; i++) {" | 6752 " for (var i = 0; i < 100; i++) {" |
6754 " var expected = i;" | 6753 " var expected = i;" |
6755 " var key = i;" | 6754 " var key = i;" |
(...skipping 19 matching lines...) Expand all Loading... |
6775 " e" | 6774 " e" |
6776 "}"; | 6775 "}"; |
6777 ExpectString(code, "PASSED"); | 6776 ExpectString(code, "PASSED"); |
6778 } | 6777 } |
6779 | 6778 |
6780 | 6779 |
6781 THREADED_TEST(IndexedInterceptorWithNotSmiLookup) { | 6780 THREADED_TEST(IndexedInterceptorWithNotSmiLookup) { |
6782 v8::Isolate* isolate = CcTest::isolate(); | 6781 v8::Isolate* isolate = CcTest::isolate(); |
6783 v8::HandleScope scope(isolate); | 6782 v8::HandleScope scope(isolate); |
6784 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6783 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6785 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6784 templ->SetHandler( |
| 6785 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6786 | 6786 |
6787 LocalContext context; | 6787 LocalContext context; |
6788 Local<v8::Object> obj = templ->NewInstance(); | 6788 Local<v8::Object> obj = templ->NewInstance(); |
6789 context->Global()->Set(v8_str("obj"), obj); | 6789 context->Global()->Set(v8_str("obj"), obj); |
6790 | 6790 |
6791 const char* code = | 6791 const char* code = |
6792 "try {" | 6792 "try {" |
6793 " for (var i = 0; i < 100; i++) {" | 6793 " for (var i = 0; i < 100; i++) {" |
6794 " var expected = i;" | 6794 " var expected = i;" |
6795 " var key = i;" | 6795 " var key = i;" |
6796 " if (i == 50) {" | 6796 " if (i == 50) {" |
6797 " key = 'foobar';" | 6797 " key = 'foobar';" |
6798 " expected = undefined;" | 6798 " expected = undefined;" |
6799 " }" | 6799 " }" |
6800 " var v = obj[key];" | 6800 " var v = obj[key];" |
6801 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" | 6801 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" |
6802 " }" | 6802 " }" |
6803 " 'PASSED'" | 6803 " 'PASSED'" |
6804 "} catch(e) {" | 6804 "} catch(e) {" |
6805 " e" | 6805 " e" |
6806 "}"; | 6806 "}"; |
6807 ExpectString(code, "PASSED"); | 6807 ExpectString(code, "PASSED"); |
6808 } | 6808 } |
6809 | 6809 |
6810 | 6810 |
6811 THREADED_TEST(IndexedInterceptorGoingMegamorphic) { | 6811 THREADED_TEST(IndexedInterceptorGoingMegamorphic) { |
6812 v8::Isolate* isolate = CcTest::isolate(); | 6812 v8::Isolate* isolate = CcTest::isolate(); |
6813 v8::HandleScope scope(isolate); | 6813 v8::HandleScope scope(isolate); |
6814 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6814 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6815 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6815 templ->SetHandler( |
| 6816 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6816 | 6817 |
6817 LocalContext context; | 6818 LocalContext context; |
6818 Local<v8::Object> obj = templ->NewInstance(); | 6819 Local<v8::Object> obj = templ->NewInstance(); |
6819 context->Global()->Set(v8_str("obj"), obj); | 6820 context->Global()->Set(v8_str("obj"), obj); |
6820 | 6821 |
6821 const char* code = | 6822 const char* code = |
6822 "var original = obj;" | 6823 "var original = obj;" |
6823 "try {" | 6824 "try {" |
6824 " for (var i = 0; i < 100; i++) {" | 6825 " for (var i = 0; i < 100; i++) {" |
6825 " var expected = i;" | 6826 " var expected = i;" |
(...skipping 10 matching lines...) Expand all Loading... |
6836 " e" | 6837 " e" |
6837 "}"; | 6838 "}"; |
6838 ExpectString(code, "PASSED"); | 6839 ExpectString(code, "PASSED"); |
6839 } | 6840 } |
6840 | 6841 |
6841 | 6842 |
6842 THREADED_TEST(IndexedInterceptorReceiverTurningSmi) { | 6843 THREADED_TEST(IndexedInterceptorReceiverTurningSmi) { |
6843 v8::Isolate* isolate = CcTest::isolate(); | 6844 v8::Isolate* isolate = CcTest::isolate(); |
6844 v8::HandleScope scope(isolate); | 6845 v8::HandleScope scope(isolate); |
6845 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6846 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6846 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6847 templ->SetHandler( |
| 6848 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6847 | 6849 |
6848 LocalContext context; | 6850 LocalContext context; |
6849 Local<v8::Object> obj = templ->NewInstance(); | 6851 Local<v8::Object> obj = templ->NewInstance(); |
6850 context->Global()->Set(v8_str("obj"), obj); | 6852 context->Global()->Set(v8_str("obj"), obj); |
6851 | 6853 |
6852 const char* code = | 6854 const char* code = |
6853 "var original = obj;" | 6855 "var original = obj;" |
6854 "try {" | 6856 "try {" |
6855 " for (var i = 0; i < 100; i++) {" | 6857 " for (var i = 0; i < 100; i++) {" |
6856 " var expected = i;" | 6858 " var expected = i;" |
(...skipping 10 matching lines...) Expand all Loading... |
6867 " e" | 6869 " e" |
6868 "}"; | 6870 "}"; |
6869 ExpectString(code, "PASSED"); | 6871 ExpectString(code, "PASSED"); |
6870 } | 6872 } |
6871 | 6873 |
6872 | 6874 |
6873 THREADED_TEST(IndexedInterceptorOnProto) { | 6875 THREADED_TEST(IndexedInterceptorOnProto) { |
6874 v8::Isolate* isolate = CcTest::isolate(); | 6876 v8::Isolate* isolate = CcTest::isolate(); |
6875 v8::HandleScope scope(isolate); | 6877 v8::HandleScope scope(isolate); |
6876 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 6878 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
6877 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 6879 templ->SetHandler( |
| 6880 v8::IndexedPropertyHandlerConfiguration(IdentityIndexedPropertyGetter)); |
6878 | 6881 |
6879 LocalContext context; | 6882 LocalContext context; |
6880 Local<v8::Object> obj = templ->NewInstance(); | 6883 Local<v8::Object> obj = templ->NewInstance(); |
6881 context->Global()->Set(v8_str("obj"), obj); | 6884 context->Global()->Set(v8_str("obj"), obj); |
6882 | 6885 |
6883 const char* code = | 6886 const char* code = |
6884 "var o = {__proto__: obj};" | 6887 "var o = {__proto__: obj};" |
6885 "try {" | 6888 "try {" |
6886 " for (var i = 0; i < 100; i++) {" | 6889 " for (var i = 0; i < 100; i++) {" |
6887 " var v = o[i];" | 6890 " var v = o[i];" |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7979 info.GetReturnValue().Set(false); // intercepted, don't delete the property | 7982 info.GetReturnValue().Set(false); // intercepted, don't delete the property |
7980 } | 7983 } |
7981 | 7984 |
7982 | 7985 |
7983 THREADED_TEST(Deleter) { | 7986 THREADED_TEST(Deleter) { |
7984 v8::Isolate* isolate = CcTest::isolate(); | 7987 v8::Isolate* isolate = CcTest::isolate(); |
7985 v8::HandleScope scope(isolate); | 7988 v8::HandleScope scope(isolate); |
7986 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 7989 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
7987 obj->SetHandler(v8::NamedPropertyHandlerConfiguration(NoBlockGetterX, NULL, | 7990 obj->SetHandler(v8::NamedPropertyHandlerConfiguration(NoBlockGetterX, NULL, |
7988 NULL, PDeleter, NULL)); | 7991 NULL, PDeleter, NULL)); |
7989 obj->SetIndexedPropertyHandler(NoBlockGetterI, NULL, NULL, IDeleter, NULL); | 7992 obj->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
| 7993 NoBlockGetterI, NULL, NULL, IDeleter, NULL)); |
7990 LocalContext context; | 7994 LocalContext context; |
7991 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 7995 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
7992 CompileRun( | 7996 CompileRun( |
7993 "k.foo = 'foo';" | 7997 "k.foo = 'foo';" |
7994 "k.bar = 'bar';" | 7998 "k.bar = 'bar';" |
7995 "k[2] = 2;" | 7999 "k[2] = 2;" |
7996 "k[4] = 4;"); | 8000 "k[4] = 4;"); |
7997 CHECK(v8_compile("delete k.foo")->Run()->IsFalse()); | 8001 CHECK(v8_compile("delete k.foo")->Run()->IsFalse()); |
7998 CHECK(v8_compile("delete k.bar")->Run()->IsTrue()); | 8002 CHECK(v8_compile("delete k.bar")->Run()->IsTrue()); |
7999 | 8003 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8044 info.GetReturnValue().Set(result); | 8048 info.GetReturnValue().Set(result); |
8045 } | 8049 } |
8046 | 8050 |
8047 | 8051 |
8048 THREADED_TEST(Enumerators) { | 8052 THREADED_TEST(Enumerators) { |
8049 v8::Isolate* isolate = CcTest::isolate(); | 8053 v8::Isolate* isolate = CcTest::isolate(); |
8050 v8::HandleScope scope(isolate); | 8054 v8::HandleScope scope(isolate); |
8051 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 8055 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
8052 obj->SetHandler( | 8056 obj->SetHandler( |
8053 v8::NamedPropertyHandlerConfiguration(GetK, NULL, NULL, NULL, NamedEnum)); | 8057 v8::NamedPropertyHandlerConfiguration(GetK, NULL, NULL, NULL, NamedEnum)); |
8054 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); | 8058 obj->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
| 8059 IndexedGetK, NULL, NULL, NULL, IndexedEnum)); |
8055 LocalContext context; | 8060 LocalContext context; |
8056 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 8061 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
8057 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 8062 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
8058 "k[10] = 0;" | 8063 "k[10] = 0;" |
8059 "k.a = 0;" | 8064 "k.a = 0;" |
8060 "k[5] = 0;" | 8065 "k[5] = 0;" |
8061 "k.b = 0;" | 8066 "k.b = 0;" |
8062 "k[4294967295] = 0;" | 8067 "k[4294967295] = 0;" |
8063 "k.c = 0;" | 8068 "k.c = 0;" |
8064 "k[4294967296] = 0;" | 8069 "k[4294967296] = 0;" |
(...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10194 | 10199 |
10195 | 10200 |
10196 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { | 10201 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
10197 v8::Isolate* isolate = CcTest::isolate(); | 10202 v8::Isolate* isolate = CcTest::isolate(); |
10198 v8::HandleScope handle_scope(isolate); | 10203 v8::HandleScope handle_scope(isolate); |
10199 v8::Handle<v8::ObjectTemplate> obj_template = | 10204 v8::Handle<v8::ObjectTemplate> obj_template = |
10200 v8::ObjectTemplate::New(isolate); | 10205 v8::ObjectTemplate::New(isolate); |
10201 | 10206 |
10202 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7)); | 10207 obj_template->Set(v8_str("7"), v8::Integer::New(CcTest::isolate(), 7)); |
10203 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42)); | 10208 obj_template->Set(v8_str("x"), v8::Integer::New(CcTest::isolate(), 42)); |
10204 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, | 10209 obj_template->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
10205 IndexedPropertyEnumerator); | 10210 NULL, NULL, NULL, NULL, IndexedPropertyEnumerator)); |
10206 obj_template->SetHandler(v8::NamedPropertyHandlerConfiguration( | 10211 obj_template->SetHandler(v8::NamedPropertyHandlerConfiguration( |
10207 NULL, NULL, NULL, NULL, NamedPropertyEnumerator)); | 10212 NULL, NULL, NULL, NULL, NamedPropertyEnumerator)); |
10208 | 10213 |
10209 LocalContext context; | 10214 LocalContext context; |
10210 v8::Handle<v8::Object> global = context->Global(); | 10215 v8::Handle<v8::Object> global = context->Global(); |
10211 global->Set(v8_str("object"), obj_template->NewInstance()); | 10216 global->Set(v8_str("object"), obj_template->NewInstance()); |
10212 | 10217 |
10213 v8::Handle<v8::Value> result = | 10218 v8::Handle<v8::Value> result = |
10214 CompileRun("Object.getOwnPropertyNames(object)"); | 10219 CompileRun("Object.getOwnPropertyNames(object)"); |
10215 CHECK(result->IsArray()); | 10220 CHECK(result->IsArray()); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10547 | 10552 |
10548 // Create an object that requires access-check functions to be | 10553 // Create an object that requires access-check functions to be |
10549 // called for cross-domain access. The object also has interceptors | 10554 // called for cross-domain access. The object also has interceptors |
10550 // interceptor. | 10555 // interceptor. |
10551 v8::Handle<v8::ObjectTemplate> object_template = | 10556 v8::Handle<v8::ObjectTemplate> object_template = |
10552 v8::ObjectTemplate::New(isolate); | 10557 v8::ObjectTemplate::New(isolate); |
10553 object_template->SetAccessCheckCallbacks(NamedAccessCounter, | 10558 object_template->SetAccessCheckCallbacks(NamedAccessCounter, |
10554 IndexedAccessCounter); | 10559 IndexedAccessCounter); |
10555 object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( | 10560 object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( |
10556 AccessControlNamedGetter, AccessControlNamedSetter)); | 10561 AccessControlNamedGetter, AccessControlNamedSetter)); |
10557 object_template->SetIndexedPropertyHandler(AccessControlIndexedGetter, | 10562 object_template->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
10558 AccessControlIndexedSetter); | 10563 AccessControlIndexedGetter, AccessControlIndexedSetter)); |
10559 Local<v8::Object> object = object_template->NewInstance(); | 10564 Local<v8::Object> object = object_template->NewInstance(); |
10560 | 10565 |
10561 v8::HandleScope scope1(isolate); | 10566 v8::HandleScope scope1(isolate); |
10562 | 10567 |
10563 // Create another environment. | 10568 // Create another environment. |
10564 v8::Local<Context> context1 = Context::New(isolate); | 10569 v8::Local<Context> context1 = Context::New(isolate); |
10565 context1->Enter(); | 10570 context1->Enter(); |
10566 | 10571 |
10567 // Make easy access to the object from the other environment. | 10572 // Make easy access to the object from the other environment. |
10568 v8::Handle<v8::Object> global1 = context1->Global(); | 10573 v8::Handle<v8::Object> global1 = context1->Global(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10782 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; | 10787 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; |
10783 v8::Isolate* isolate = CcTest::isolate(); | 10788 v8::Isolate* isolate = CcTest::isolate(); |
10784 v8::HandleScope handle_scope(isolate); | 10789 v8::HandleScope handle_scope(isolate); |
10785 | 10790 |
10786 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate); | 10791 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate); |
10787 LocalContext context(NULL, global_template); | 10792 LocalContext context(NULL, global_template); |
10788 | 10793 |
10789 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 10794 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
10790 t->InstanceTemplate()->SetHandler( | 10795 t->InstanceTemplate()->SetHandler( |
10791 v8::NamedPropertyHandlerConfiguration(ShadowNamedGet)); | 10796 v8::NamedPropertyHandlerConfiguration(ShadowNamedGet)); |
10792 t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet); | 10797 t->InstanceTemplate()->SetHandler( |
| 10798 v8::IndexedPropertyHandlerConfiguration(ShadowIndexedGet)); |
10793 Local<ObjectTemplate> proto = t->PrototypeTemplate(); | 10799 Local<ObjectTemplate> proto = t->PrototypeTemplate(); |
10794 Local<ObjectTemplate> instance = t->InstanceTemplate(); | 10800 Local<ObjectTemplate> instance = t->InstanceTemplate(); |
10795 | 10801 |
10796 proto->Set(v8_str("f"), | 10802 proto->Set(v8_str("f"), |
10797 v8::FunctionTemplate::New(isolate, | 10803 v8::FunctionTemplate::New(isolate, |
10798 ShadowFunctionCallback, | 10804 ShadowFunctionCallback, |
10799 Local<Value>())); | 10805 Local<Value>())); |
10800 proto->Set(v8_str("x"), v8_num(12)); | 10806 proto->Set(v8_str("x"), v8_num(12)); |
10801 | 10807 |
10802 instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter); | 10808 instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter); |
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13600 CHECK(value->IsInt32()); | 13606 CHECK(value->IsInt32()); |
13601 CHECK_EQ(42, value->Int32Value()); | 13607 CHECK_EQ(42, value->Int32Value()); |
13602 } | 13608 } |
13603 | 13609 |
13604 | 13610 |
13605 // Test that we ignore null interceptors. | 13611 // Test that we ignore null interceptors. |
13606 THREADED_TEST(NullIndexedInterceptor) { | 13612 THREADED_TEST(NullIndexedInterceptor) { |
13607 v8::Isolate* isolate = CcTest::isolate(); | 13613 v8::Isolate* isolate = CcTest::isolate(); |
13608 v8::HandleScope scope(isolate); | 13614 v8::HandleScope scope(isolate); |
13609 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); | 13615 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); |
13610 templ->SetIndexedPropertyHandler( | 13616 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
13611 static_cast<v8::IndexedPropertyGetterCallback>(0)); | 13617 static_cast<v8::IndexedPropertyGetterCallback>(0))); |
13612 LocalContext context; | 13618 LocalContext context; |
13613 templ->Set(CcTest::isolate(), "42", v8_num(42)); | 13619 templ->Set(CcTest::isolate(), "42", v8_num(42)); |
13614 v8::Handle<v8::Object> obj = templ->NewInstance(); | 13620 v8::Handle<v8::Object> obj = templ->NewInstance(); |
13615 context->Global()->Set(v8_str("obj"), obj); | 13621 context->Global()->Set(v8_str("obj"), obj); |
13616 v8::Handle<Value> value = CompileRun("obj[42]"); | 13622 v8::Handle<Value> value = CompileRun("obj[42]"); |
13617 CHECK(value->IsInt32()); | 13623 CHECK(value->IsInt32()); |
13618 CHECK_EQ(42, value->Int32Value()); | 13624 CHECK_EQ(42, value->Int32Value()); |
13619 } | 13625 } |
13620 | 13626 |
13621 | 13627 |
(...skipping 3258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16880 i::Handle<i::ExternalUint8ClampedArray> pixels = | 16886 i::Handle<i::ExternalUint8ClampedArray> pixels = |
16881 i::Handle<i::ExternalUint8ClampedArray>::cast( | 16887 i::Handle<i::ExternalUint8ClampedArray>::cast( |
16882 factory->NewExternalArray(kElementCount, | 16888 factory->NewExternalArray(kElementCount, |
16883 v8::kExternalUint8ClampedArray, | 16889 v8::kExternalUint8ClampedArray, |
16884 pixel_data)); | 16890 pixel_data)); |
16885 for (int i = 0; i < kElementCount; i++) { | 16891 for (int i = 0; i < kElementCount; i++) { |
16886 pixels->set(i, i % 256); | 16892 pixels->set(i, i % 256); |
16887 } | 16893 } |
16888 v8::Handle<v8::ObjectTemplate> templ = | 16894 v8::Handle<v8::ObjectTemplate> templ = |
16889 v8::ObjectTemplate::New(context->GetIsolate()); | 16895 v8::ObjectTemplate::New(context->GetIsolate()); |
16890 templ->SetIndexedPropertyHandler(NotHandledIndexedPropertyGetter, | 16896 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
16891 NotHandledIndexedPropertySetter); | 16897 NotHandledIndexedPropertyGetter, NotHandledIndexedPropertySetter)); |
16892 v8::Handle<v8::Object> obj = templ->NewInstance(); | 16898 v8::Handle<v8::Object> obj = templ->NewInstance(); |
16893 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); | 16899 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); |
16894 context->Global()->Set(v8_str("pixels"), obj); | 16900 context->Global()->Set(v8_str("pixels"), obj); |
16895 v8::Handle<v8::Value> result = CompileRun("pixels[1]"); | 16901 v8::Handle<v8::Value> result = CompileRun("pixels[1]"); |
16896 CHECK_EQ(1, result->Int32Value()); | 16902 CHECK_EQ(1, result->Int32Value()); |
16897 result = CompileRun("var sum = 0;" | 16903 result = CompileRun("var sum = 0;" |
16898 "for (var i = 0; i < 8; i++) {" | 16904 "for (var i = 0; i < 8; i++) {" |
16899 " sum += pixels[i] = pixels[i] = -i;" | 16905 " sum += pixels[i] = pixels[i] = -i;" |
16900 "}" | 16906 "}" |
16901 "sum;"); | 16907 "sum;"); |
(...skipping 4346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21248 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21254 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21249 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( | 21255 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( |
21250 HasOwnPropertyNamedPropertyGetter)); | 21256 HasOwnPropertyNamedPropertyGetter)); |
21251 Handle<Object> instance = templ->NewInstance(); | 21257 Handle<Object> instance = templ->NewInstance(); |
21252 CHECK(!instance->HasOwnProperty(v8_str("42"))); | 21258 CHECK(!instance->HasOwnProperty(v8_str("42"))); |
21253 CHECK(instance->HasOwnProperty(v8_str("foo"))); | 21259 CHECK(instance->HasOwnProperty(v8_str("foo"))); |
21254 CHECK(!instance->HasOwnProperty(v8_str("bar"))); | 21260 CHECK(!instance->HasOwnProperty(v8_str("bar"))); |
21255 } | 21261 } |
21256 { // Check indexed getter interceptors. | 21262 { // Check indexed getter interceptors. |
21257 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21263 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21258 templ->SetIndexedPropertyHandler(HasOwnPropertyIndexedPropertyGetter); | 21264 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
| 21265 HasOwnPropertyIndexedPropertyGetter)); |
21259 Handle<Object> instance = templ->NewInstance(); | 21266 Handle<Object> instance = templ->NewInstance(); |
21260 CHECK(instance->HasOwnProperty(v8_str("42"))); | 21267 CHECK(instance->HasOwnProperty(v8_str("42"))); |
21261 CHECK(!instance->HasOwnProperty(v8_str("43"))); | 21268 CHECK(!instance->HasOwnProperty(v8_str("43"))); |
21262 CHECK(!instance->HasOwnProperty(v8_str("foo"))); | 21269 CHECK(!instance->HasOwnProperty(v8_str("foo"))); |
21263 } | 21270 } |
21264 { // Check named query interceptors. | 21271 { // Check named query interceptors. |
21265 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21272 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21266 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( | 21273 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( |
21267 0, 0, HasOwnPropertyNamedPropertyQuery)); | 21274 0, 0, HasOwnPropertyNamedPropertyQuery)); |
21268 Handle<Object> instance = templ->NewInstance(); | 21275 Handle<Object> instance = templ->NewInstance(); |
21269 CHECK(instance->HasOwnProperty(v8_str("foo"))); | 21276 CHECK(instance->HasOwnProperty(v8_str("foo"))); |
21270 CHECK(!instance->HasOwnProperty(v8_str("bar"))); | 21277 CHECK(!instance->HasOwnProperty(v8_str("bar"))); |
21271 } | 21278 } |
21272 { // Check indexed query interceptors. | 21279 { // Check indexed query interceptors. |
21273 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21280 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21274 templ->SetIndexedPropertyHandler(0, 0, HasOwnPropertyIndexedPropertyQuery); | 21281 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
| 21282 0, 0, HasOwnPropertyIndexedPropertyQuery)); |
21275 Handle<Object> instance = templ->NewInstance(); | 21283 Handle<Object> instance = templ->NewInstance(); |
21276 CHECK(instance->HasOwnProperty(v8_str("42"))); | 21284 CHECK(instance->HasOwnProperty(v8_str("42"))); |
21277 CHECK(!instance->HasOwnProperty(v8_str("41"))); | 21285 CHECK(!instance->HasOwnProperty(v8_str("41"))); |
21278 } | 21286 } |
21279 { // Check callbacks. | 21287 { // Check callbacks. |
21280 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21288 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21281 templ->SetAccessor(v8_str("foo"), HasOwnPropertyAccessorGetter); | 21289 templ->SetAccessor(v8_str("foo"), HasOwnPropertyAccessorGetter); |
21282 Handle<Object> instance = templ->NewInstance(); | 21290 Handle<Object> instance = templ->NewInstance(); |
21283 CHECK(instance->HasOwnProperty(v8_str("foo"))); | 21291 CHECK(instance->HasOwnProperty(v8_str("foo"))); |
21284 CHECK(!instance->HasOwnProperty(v8_str("bar"))); | 21292 CHECK(!instance->HasOwnProperty(v8_str("bar"))); |
21285 } | 21293 } |
21286 { // Check that query wins on disagreement. | 21294 { // Check that query wins on disagreement. |
21287 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21295 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21288 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( | 21296 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( |
21289 HasOwnPropertyNamedPropertyGetter, 0, | 21297 HasOwnPropertyNamedPropertyGetter, 0, |
21290 HasOwnPropertyNamedPropertyQuery2)); | 21298 HasOwnPropertyNamedPropertyQuery2)); |
21291 Handle<Object> instance = templ->NewInstance(); | 21299 Handle<Object> instance = templ->NewInstance(); |
21292 CHECK(!instance->HasOwnProperty(v8_str("foo"))); | 21300 CHECK(!instance->HasOwnProperty(v8_str("foo"))); |
21293 CHECK(instance->HasOwnProperty(v8_str("bar"))); | 21301 CHECK(instance->HasOwnProperty(v8_str("bar"))); |
21294 } | 21302 } |
21295 } | 21303 } |
21296 | 21304 |
21297 | 21305 |
21298 TEST(IndexedInterceptorWithStringProto) { | 21306 TEST(IndexedInterceptorWithStringProto) { |
21299 v8::Isolate* isolate = CcTest::isolate(); | 21307 v8::Isolate* isolate = CcTest::isolate(); |
21300 v8::HandleScope scope(isolate); | 21308 v8::HandleScope scope(isolate); |
21301 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); | 21309 Handle<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
21302 templ->SetIndexedPropertyHandler(NULL, | 21310 templ->SetHandler(v8::IndexedPropertyHandlerConfiguration( |
21303 NULL, | 21311 NULL, NULL, HasOwnPropertyIndexedPropertyQuery)); |
21304 HasOwnPropertyIndexedPropertyQuery); | |
21305 LocalContext context; | 21312 LocalContext context; |
21306 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 21313 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
21307 CompileRun("var s = new String('foobar'); obj.__proto__ = s;"); | 21314 CompileRun("var s = new String('foobar'); obj.__proto__ = s;"); |
21308 // These should be intercepted. | 21315 // These should be intercepted. |
21309 CHECK(CompileRun("42 in obj")->BooleanValue()); | 21316 CHECK(CompileRun("42 in obj")->BooleanValue()); |
21310 CHECK(CompileRun("'42' in obj")->BooleanValue()); | 21317 CHECK(CompileRun("'42' in obj")->BooleanValue()); |
21311 // These should fall through to the String prototype. | 21318 // These should fall through to the String prototype. |
21312 CHECK(CompileRun("0 in obj")->BooleanValue()); | 21319 CHECK(CompileRun("0 in obj")->BooleanValue()); |
21313 CHECK(CompileRun("'0' in obj")->BooleanValue()); | 21320 CHECK(CompileRun("'0' in obj")->BooleanValue()); |
21314 // And these should both fail. | 21321 // And these should both fail. |
(...skipping 3189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24504 " function store() { MEM32[0] = 0; }" | 24511 " function store() { MEM32[0] = 0; }" |
24505 " return { store: store };" | 24512 " return { store: store };" |
24506 "}" | 24513 "}" |
24507 "var buffer = new ArrayBuffer(4);" | 24514 "var buffer = new ArrayBuffer(4);" |
24508 "Module(this, {}, buffer).store();" | 24515 "Module(this, {}, buffer).store();" |
24509 "buffer"; | 24516 "buffer"; |
24510 | 24517 |
24511 result = CompileRun(store).As<v8::ArrayBuffer>(); | 24518 result = CompileRun(store).As<v8::ArrayBuffer>(); |
24512 CHECK_EQ(should_be_neuterable, result->IsNeuterable()); | 24519 CHECK_EQ(should_be_neuterable, result->IsNeuterable()); |
24513 } | 24520 } |
OLD | NEW |