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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #include "src/api.h" | 32 #include "src/api.h" |
33 #include "src/frames-inl.h" | 33 #include "src/frames-inl.h" |
34 #include "src/string-stream.h" | 34 #include "src/string-stream.h" |
35 #include "test/cctest/cctest.h" | 35 #include "test/cctest/cctest.h" |
36 | 36 |
37 using ::v8::ObjectTemplate; | 37 using ::v8::ObjectTemplate; |
38 using ::v8::Value; | 38 using ::v8::Value; |
39 using ::v8::Context; | 39 using ::v8::Context; |
40 using ::v8::Local; | 40 using ::v8::Local; |
| 41 using ::v8::Name; |
41 using ::v8::String; | 42 using ::v8::String; |
42 using ::v8::Script; | 43 using ::v8::Script; |
43 using ::v8::Function; | 44 using ::v8::Function; |
44 using ::v8::Extension; | 45 using ::v8::Extension; |
45 | 46 |
46 static void handle_property(Local<String> name, | 47 static void handle_property(Local<String> name, |
47 const v8::PropertyCallbackInfo<v8::Value>& info) { | 48 const v8::PropertyCallbackInfo<v8::Value>& info) { |
48 ApiTestFuzzer::Fuzz(); | 49 ApiTestFuzzer::Fuzz(); |
49 info.GetReturnValue().Set(v8_num(900)); | 50 info.GetReturnValue().Set(v8_num(900)); |
50 } | 51 } |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 } | 507 } |
507 | 508 |
508 | 509 |
509 void JSONStringifyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { | 510 void JSONStringifyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { |
510 v8::Handle<v8::Array> array = v8::Array::New(info.GetIsolate(), 1); | 511 v8::Handle<v8::Array> array = v8::Array::New(info.GetIsolate(), 1); |
511 array->Set(0, v8_str("regress")); | 512 array->Set(0, v8_str("regress")); |
512 info.GetReturnValue().Set(array); | 513 info.GetReturnValue().Set(array); |
513 } | 514 } |
514 | 515 |
515 | 516 |
516 void JSONStringifyGetter(Local<String> name, | 517 void JSONStringifyGetter(Local<Name> name, |
517 const v8::PropertyCallbackInfo<v8::Value>& info) { | 518 const v8::PropertyCallbackInfo<v8::Value>& info) { |
518 info.GetReturnValue().Set(v8_str("crbug-161028")); | 519 info.GetReturnValue().Set(v8_str("crbug-161028")); |
519 } | 520 } |
520 | 521 |
521 | 522 |
522 THREADED_TEST(JSONStringifyNamedInterceptorObject) { | 523 THREADED_TEST(JSONStringifyNamedInterceptorObject) { |
523 LocalContext env; | 524 LocalContext env; |
524 v8::Isolate* isolate = env->GetIsolate(); | 525 v8::Isolate* isolate = env->GetIsolate(); |
525 v8::HandleScope scope(isolate); | 526 v8::HandleScope scope(isolate); |
526 | 527 |
527 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 528 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
528 obj->SetNamedPropertyHandler( | 529 obj->SetHandler(v8::NamedPropertyHandlerConfiguration( |
529 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator); | 530 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator)); |
530 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 531 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
531 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); | 532 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); |
532 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); | 533 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); |
533 } | 534 } |
534 | 535 |
535 | 536 |
536 static v8::Local<v8::Context> expected_current_context; | 537 static v8::Local<v8::Context> expected_current_context; |
537 static v8::Local<v8::Context> expected_calling_context; | 538 static v8::Local<v8::Context> expected_calling_context; |
538 | 539 |
539 | 540 |
(...skipping 30 matching lines...) Expand all Loading... |
570 "Object.defineProperty(this.__proto__, 'x', {" | 571 "Object.defineProperty(this.__proto__, 'x', {" |
571 " get : function() { return this; }," | 572 " get : function() { return this; }," |
572 " set : function() { set_value = this; }" | 573 " set : function() { set_value = this; }" |
573 "});" | 574 "});" |
574 "function getter() { return x; }" | 575 "function getter() { return x; }" |
575 "function setter() { x = 1; }" | 576 "function setter() { x = 1; }" |
576 "for (var i = 0; i < 4; i++) { getter(); setter(); }"); | 577 "for (var i = 0; i < 4; i++) { getter(); setter(); }"); |
577 CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy()); | 578 CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy()); |
578 CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy()); | 579 CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy()); |
579 } | 580 } |
OLD | NEW |