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 13255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13266 // TODO(verwaest): Update once blink doesn't rely on ForceSet to delete api | 13266 // TODO(verwaest): Update once blink doesn't rely on ForceSet to delete api |
13267 // accessors. | 13267 // accessors. |
13268 global->ForceSet(access_property, v8::Int32::New(isolate, 8)); | 13268 global->ForceSet(access_property, v8::Int32::New(isolate, 8)); |
13269 CHECK_EQ(8, global->Get(access_property)->Int32Value()); | 13269 CHECK_EQ(8, global->Get(access_property)->Int32Value()); |
13270 CHECK_EQ(1, force_set_set_count); | 13270 CHECK_EQ(1, force_set_set_count); |
13271 CHECK_EQ(2, force_set_get_count); | 13271 CHECK_EQ(2, force_set_get_count); |
13272 } | 13272 } |
13273 | 13273 |
13274 | 13274 |
13275 TEST(ForceSetWithInterceptor) { | 13275 TEST(ForceSetWithInterceptor) { |
13276 force_set_get_count = 0; | |
13277 force_set_set_count = 0; | |
13278 pass_on_get = false; | |
13279 | |
13280 v8::Isolate* isolate = CcTest::isolate(); | 13276 v8::Isolate* isolate = CcTest::isolate(); |
13281 v8::HandleScope scope(isolate); | 13277 v8::HandleScope scope(isolate); |
13282 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); | 13278 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); |
13283 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( | 13279 templ->SetHandler(v8::NamedPropertyHandlerConfiguration( |
13284 ForceSetInterceptGetter, ForceSetInterceptSetter)); | 13280 ForceSetInterceptGetter, ForceSetInterceptSetter)); |
| 13281 pass_on_get = true; |
13285 LocalContext context(NULL, templ); | 13282 LocalContext context(NULL, templ); |
13286 v8::Handle<v8::Object> global = context->Global(); | 13283 v8::Handle<v8::Object> global = context->Global(); |
13287 | 13284 |
| 13285 force_set_get_count = 0; |
| 13286 force_set_set_count = 0; |
| 13287 pass_on_get = false; |
| 13288 |
13288 v8::Handle<v8::String> some_property = | 13289 v8::Handle<v8::String> some_property = |
13289 v8::String::NewFromUtf8(isolate, "a"); | 13290 v8::String::NewFromUtf8(isolate, "a"); |
13290 CHECK_EQ(0, force_set_set_count); | 13291 CHECK_EQ(0, force_set_set_count); |
13291 CHECK_EQ(0, force_set_get_count); | 13292 CHECK_EQ(0, force_set_get_count); |
13292 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 13293 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
13293 // Setting the property shouldn't override it, just call the setter | 13294 // Setting the property shouldn't override it, just call the setter |
13294 // which in this case does nothing. | 13295 // which in this case does nothing. |
13295 global->Set(some_property, v8::Int32::New(isolate, 7)); | 13296 global->Set(some_property, v8::Int32::New(isolate, 7)); |
13296 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 13297 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
13297 CHECK_EQ(1, force_set_set_count); | 13298 CHECK_EQ(1, force_set_set_count); |
(...skipping 8357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21655 CHECK(set->Has(env.local(), set).FromJust()); | 21656 CHECK(set->Has(env.local(), set).FromJust()); |
21656 | 21657 |
21657 CHECK(set->Delete(env.local(), set).FromJust()); | 21658 CHECK(set->Delete(env.local(), set).FromJust()); |
21658 CHECK_EQ(2U, set->Size()); | 21659 CHECK_EQ(2U, set->Size()); |
21659 CHECK(!set->Has(env.local(), set).FromJust()); | 21660 CHECK(!set->Has(env.local(), set).FromJust()); |
21660 CHECK(!set->Delete(env.local(), set).FromJust()); | 21661 CHECK(!set->Delete(env.local(), set).FromJust()); |
21661 | 21662 |
21662 set->Clear(); | 21663 set->Clear(); |
21663 CHECK_EQ(0U, set->Size()); | 21664 CHECK_EQ(0U, set->Size()); |
21664 } | 21665 } |
OLD | NEW |