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 21837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21848 " fake.age;\n" | 21848 " fake.age;\n" |
21849 " result = 1;\n" | 21849 " result = 1;\n" |
21850 " } catch (e) {\n" | 21850 " } catch (e) {\n" |
21851 " }\n" | 21851 " }\n" |
21852 " test(d+1);\n" | 21852 " test(d+1);\n" |
21853 "}\n" | 21853 "}\n" |
21854 "test(0);\n" | 21854 "test(0);\n" |
21855 "result;\n", | 21855 "result;\n", |
21856 0); | 21856 0); |
21857 } | 21857 } |
| 21858 |
| 21859 |
| 21860 static bool AccessSymbolsAlwaysBlocked(Local<v8::Object> global, |
| 21861 Local<Value> name, v8::AccessType type, |
| 21862 Local<Value> data) { |
| 21863 if (!name->IsSymbol()) return true; |
| 21864 i::PrintF("Access blocked.\n"); |
| 21865 return false; |
| 21866 } |
| 21867 |
| 21868 |
| 21869 THREADED_TEST(Regress507553) { |
| 21870 v8::Isolate* isolate = CcTest::isolate(); |
| 21871 HandleScope scope(isolate); |
| 21872 |
| 21873 // Template for object with security check. |
| 21874 Local<ObjectTemplate> spreadable_template = v8::ObjectTemplate::New(isolate); |
| 21875 spreadable_template->SetAccessCheckCallbacks(AccessSymbolsAlwaysBlocked, |
| 21876 NULL); |
| 21877 |
| 21878 // Context for "foreign" objects used in test. |
| 21879 Local<Context> context = v8::Context::New(isolate); |
| 21880 context->Enter(); |
| 21881 |
| 21882 // Object with explicit security check. |
| 21883 Local<Object> protected_object = spreadable_template->NewInstance(); |
| 21884 |
| 21885 // JSGlobalProxy object, always have security check. |
| 21886 Local<Object> proxy_object = context->Global(); |
| 21887 |
| 21888 // Global object, the prototype of proxy_object. No security checks. |
| 21889 Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate); |
| 21890 |
| 21891 spreadable_template->Set(v8::Symbol::GetIsConcatSpreadable(isolate), |
| 21892 v8::Boolean::New(isolate, true)); |
| 21893 |
| 21894 protected_object->Set(v8_str("length"), v8::Integer::New(isolate, 2)); |
| 21895 protected_object->Set(0U, v8_str("a")); |
| 21896 protected_object->Set(1U, v8_str("b")); |
| 21897 |
| 21898 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); |
| 21899 global_template->Set(v8_str("protected"), protected_object); |
| 21900 global_template->Set(v8_str("global"), global_object); |
| 21901 |
| 21902 context->Exit(); |
| 21903 |
| 21904 LocalContext context2(NULL, global_template); |
| 21905 |
| 21906 Local<Value> result1 = CompileRun("[].concat(protected)"); |
| 21907 CHECK(result1->IsArray()); |
| 21908 CHECK(result1.As<Object>()->Get(0)->Equals(protected_object)); |
| 21909 |
| 21910 Local<Value> result2 = CompileRun("[].concat([global], global, protected)"); |
| 21911 CHECK(result2->IsArray()); |
| 21912 CHECK(result2.As<Object>()->Get(0)->Equals(global_object)); |
| 21913 CHECK(result2.As<Object>()->Get(1)->Equals(global_object)); |
| 21914 CHECK(result2.As<Object>()->Get(2)->Equals(protected_object)); |
| 21915 } |
OLD | NEW |