Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: test/cctest/test-api-interceptors.cc

Issue 1180073002: Introduce DefineOwnPropertyIgnoreAttributes and make it call SetPropertyWithInterceptor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "test/cctest/test-api.h" 7 #include "test/cctest/test-api.h"
8 8
9 #include "include/v8-util.h" 9 #include "include/v8-util.h"
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 static void NoBlockGetterI(uint32_t index, 1920 static void NoBlockGetterI(uint32_t index,
1921 const v8::PropertyCallbackInfo<v8::Value>&) {} 1921 const v8::PropertyCallbackInfo<v8::Value>&) {}
1922 1922
1923 1923
1924 static void PDeleter(Local<Name> name, 1924 static void PDeleter(Local<Name> name,
1925 const v8::PropertyCallbackInfo<v8::Boolean>& info) { 1925 const v8::PropertyCallbackInfo<v8::Boolean>& info) {
1926 if (!name->Equals(v8_str("foo"))) { 1926 if (!name->Equals(v8_str("foo"))) {
1927 return; // not intercepted 1927 return; // not intercepted
1928 } 1928 }
1929 1929
1930 info.GetReturnValue().Set(false); // intercepted, don't delete the property 1930 // cannot be intercepted, the property isn't handled by the interceptor.
1931 info.GetReturnValue().Set(false);
1931 } 1932 }
1932 1933
1933 1934
1934 static void IDeleter(uint32_t index, 1935 static void IDeleter(uint32_t index,
1935 const v8::PropertyCallbackInfo<v8::Boolean>& info) { 1936 const v8::PropertyCallbackInfo<v8::Boolean>& info) {
1936 if (index != 2) { 1937 if (index != 2) {
1937 return; // not intercepted 1938 return; // not intercepted
1938 } 1939 }
1939 1940
1940 info.GetReturnValue().Set(false); // intercepted, don't delete the property 1941 // cannot be intercepted, the property isn't handled by the interceptor.
1942 info.GetReturnValue().Set(false);
1941 } 1943 }
1942 1944
1943 1945
1944 THREADED_TEST(Deleter) { 1946 THREADED_TEST(Deleter) {
1945 v8::Isolate* isolate = CcTest::isolate(); 1947 v8::Isolate* isolate = CcTest::isolate();
1946 v8::HandleScope scope(isolate); 1948 v8::HandleScope scope(isolate);
1947 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); 1949 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
1948 obj->SetHandler(v8::NamedPropertyHandlerConfiguration(NoBlockGetterX, NULL, 1950 obj->SetHandler(v8::NamedPropertyHandlerConfiguration(NoBlockGetterX, NULL,
1949 NULL, PDeleter, NULL)); 1951 NULL, PDeleter, NULL));
1950 obj->SetHandler(v8::IndexedPropertyHandlerConfiguration( 1952 obj->SetHandler(v8::IndexedPropertyHandlerConfiguration(
1951 NoBlockGetterI, NULL, NULL, IDeleter, NULL)); 1953 NoBlockGetterI, NULL, NULL, IDeleter, NULL));
1952 LocalContext context; 1954 LocalContext context;
1953 context->Global()->Set(v8_str("k"), obj->NewInstance()); 1955 context->Global()->Set(v8_str("k"), obj->NewInstance());
1954 CompileRun( 1956 CompileRun(
1955 "k.foo = 'foo';" 1957 "k.foo = 'foo';"
1956 "k.bar = 'bar';" 1958 "k.bar = 'bar';"
1957 "k[2] = 2;" 1959 "k[2] = 2;"
1958 "k[4] = 4;"); 1960 "k[4] = 4;");
1959 CHECK(v8_compile("delete k.foo")->Run()->IsFalse()); 1961 CHECK(v8_compile("delete k.foo")->Run()->IsTrue());
1960 CHECK(v8_compile("delete k.bar")->Run()->IsTrue()); 1962 CHECK(v8_compile("delete k.bar")->Run()->IsTrue());
1961 1963
1962 CHECK(v8_compile("k.foo")->Run()->Equals(v8_str("foo"))); 1964 CHECK(v8_compile("k.foo")->Run()->Equals(v8_str("foo")));
1963 CHECK(v8_compile("k.bar")->Run()->IsUndefined()); 1965 CHECK(v8_compile("k.bar")->Run()->IsUndefined());
1964 1966
1965 CHECK(v8_compile("delete k[2]")->Run()->IsFalse()); 1967 CHECK(v8_compile("delete k[2]")->Run()->IsTrue());
1966 CHECK(v8_compile("delete k[4]")->Run()->IsTrue()); 1968 CHECK(v8_compile("delete k[4]")->Run()->IsTrue());
1967 1969
1968 CHECK(v8_compile("k[2]")->Run()->Equals(v8_num(2))); 1970 CHECK(v8_compile("k[2]")->Run()->Equals(v8_num(2)));
1969 CHECK(v8_compile("k[4]")->Run()->IsUndefined()); 1971 CHECK(v8_compile("k[4]")->Run()->IsUndefined());
1970 } 1972 }
1971 1973
1972 1974
1973 static void GetK(Local<Name> name, 1975 static void GetK(Local<Name> name,
1974 const v8::PropertyCallbackInfo<v8::Value>& info) { 1976 const v8::PropertyCallbackInfo<v8::Value>& info) {
1975 ApiTestFuzzer::Fuzz(); 1977 ApiTestFuzzer::Fuzz();
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3306 "var obj = intercepted_1;" 3308 "var obj = intercepted_1;"
3307 "obj.x = 4;" 3309 "obj.x = 4;"
3308 "eval('obj.x');" 3310 "eval('obj.x');"
3309 "eval('obj.x');" 3311 "eval('obj.x');"
3310 "eval('obj.x');" 3312 "eval('obj.x');"
3311 "obj = intercepted_2;" 3313 "obj = intercepted_2;"
3312 "obj.x = 9;" 3314 "obj.x = 9;"
3313 "eval('obj.x');", 3315 "eval('obj.x');",
3314 9); 3316 9);
3315 } 3317 }
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698