OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 10865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10876 v8::Handle<v8::Object> obj = v8::Object::New(); | 10876 v8::Handle<v8::Object> obj = v8::Object::New(); |
10877 obj->SetIndexedPropertiesToPixelData(pixel_data, size); | 10877 obj->SetIndexedPropertiesToPixelData(pixel_data, size); |
10878 CHECK(obj->HasIndexedPropertiesInPixelData()); | 10878 CHECK(obj->HasIndexedPropertiesInPixelData()); |
10879 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); | 10879 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); |
10880 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); | 10880 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); |
10881 free(pixel_data); | 10881 free(pixel_data); |
10882 } | 10882 } |
10883 } | 10883 } |
10884 | 10884 |
10885 | 10885 |
| 10886 static v8::Handle<Value> NotHandledIndexedPropertyGetter( |
| 10887 uint32_t index, |
| 10888 const AccessorInfo& info) { |
| 10889 ApiTestFuzzer::Fuzz(); |
| 10890 return v8::Handle<Value>(); |
| 10891 } |
| 10892 |
| 10893 |
| 10894 static v8::Handle<Value> NotHandledIndexedPropertySetter( |
| 10895 uint32_t index, |
| 10896 Local<Value> value, |
| 10897 const AccessorInfo& info) { |
| 10898 ApiTestFuzzer::Fuzz(); |
| 10899 return v8::Handle<Value>(); |
| 10900 } |
| 10901 |
| 10902 |
| 10903 THREADED_TEST(PixelArrayWithInterceptor) { |
| 10904 v8::HandleScope scope; |
| 10905 LocalContext context; |
| 10906 const int kElementCount = 260; |
| 10907 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); |
| 10908 i::Handle<i::PixelArray> pixels = |
| 10909 i::Factory::NewPixelArray(kElementCount, pixel_data); |
| 10910 for (int i = 0; i < kElementCount; i++) { |
| 10911 pixels->set(i, i % 256); |
| 10912 } |
| 10913 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 10914 templ->SetIndexedPropertyHandler(NotHandledIndexedPropertyGetter, |
| 10915 NotHandledIndexedPropertySetter); |
| 10916 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 10917 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); |
| 10918 context->Global()->Set(v8_str("pixels"), obj); |
| 10919 v8::Handle<v8::Value> result = CompileRun("pixels[1]"); |
| 10920 CHECK_EQ(1, result->Int32Value()); |
| 10921 result = CompileRun("var sum = 0;" |
| 10922 "for (var i = 0; i < 8; i++) {" |
| 10923 " sum += pixels[i] = pixels[i] = -i;" |
| 10924 "}" |
| 10925 "sum;"); |
| 10926 CHECK_EQ(-28, result->Int32Value()); |
| 10927 result = CompileRun("pixels.hasOwnProperty('1')"); |
| 10928 CHECK(result->BooleanValue()); |
| 10929 free(pixel_data); |
| 10930 } |
| 10931 |
| 10932 |
10886 static int ExternalArrayElementSize(v8::ExternalArrayType array_type) { | 10933 static int ExternalArrayElementSize(v8::ExternalArrayType array_type) { |
10887 switch (array_type) { | 10934 switch (array_type) { |
10888 case v8::kExternalByteArray: | 10935 case v8::kExternalByteArray: |
10889 case v8::kExternalUnsignedByteArray: | 10936 case v8::kExternalUnsignedByteArray: |
10890 return 1; | 10937 return 1; |
10891 break; | 10938 break; |
10892 case v8::kExternalShortArray: | 10939 case v8::kExternalShortArray: |
10893 case v8::kExternalUnsignedShortArray: | 10940 case v8::kExternalUnsignedShortArray: |
10894 return 2; | 10941 return 2; |
10895 break; | 10942 break; |
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12787 v8::Handle<v8::Function> define_property = | 12834 v8::Handle<v8::Function> define_property = |
12788 CompileRun("(function() {" | 12835 CompileRun("(function() {" |
12789 " Object.defineProperty(" | 12836 " Object.defineProperty(" |
12790 " this," | 12837 " this," |
12791 " 1," | 12838 " 1," |
12792 " { configurable: true, enumerable: true, value: 3 });" | 12839 " { configurable: true, enumerable: true, value: 3 });" |
12793 "})").As<Function>(); | 12840 "})").As<Function>(); |
12794 context->DetachGlobal(); | 12841 context->DetachGlobal(); |
12795 define_property->Call(proxy, 0, NULL); | 12842 define_property->Call(proxy, 0, NULL); |
12796 } | 12843 } |
OLD | NEW |