OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 CHECK(obj->Delete(prop_name)); | 1801 CHECK(obj->Delete(prop_name)); |
1802 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 1802 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
1803 | 1803 |
1804 HEAP->CollectAllGarbage(false); | 1804 HEAP->CollectAllGarbage(false); |
1805 | 1805 |
1806 CHECK(obj->DeleteHiddenValue(key)); | 1806 CHECK(obj->DeleteHiddenValue(key)); |
1807 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 1807 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
1808 } | 1808 } |
1809 | 1809 |
1810 | 1810 |
| 1811 THREADED_TEST(Regress97784) { |
| 1812 // Regression test for crbug.com/97784 |
| 1813 // Messing with the Object.prototype should not have effect on |
| 1814 // hidden properties. |
| 1815 v8::HandleScope scope; |
| 1816 LocalContext env; |
| 1817 |
| 1818 v8::Local<v8::Object> obj = v8::Object::New(); |
| 1819 v8::Local<v8::String> key = v8_str("hidden"); |
| 1820 |
| 1821 CompileRun( |
| 1822 "set_called = false;" |
| 1823 "Object.defineProperty(" |
| 1824 " Object.prototype," |
| 1825 " 'hidden'," |
| 1826 " {get: function() { return 45; }," |
| 1827 " set: function() { set_called = true; }})"); |
| 1828 |
| 1829 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
| 1830 // Make sure that the getter and setter from Object.prototype is not invoked. |
| 1831 // If it did we would have full access to the hidden properties in |
| 1832 // the accessor. |
| 1833 CHECK(obj->SetHiddenValue(key, v8::Integer::New(42))); |
| 1834 ExpectFalse("set_called"); |
| 1835 CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); |
| 1836 } |
| 1837 |
| 1838 |
1811 static bool interceptor_for_hidden_properties_called; | 1839 static bool interceptor_for_hidden_properties_called; |
1812 static v8::Handle<Value> InterceptorForHiddenProperties( | 1840 static v8::Handle<Value> InterceptorForHiddenProperties( |
1813 Local<String> name, const AccessorInfo& info) { | 1841 Local<String> name, const AccessorInfo& info) { |
1814 interceptor_for_hidden_properties_called = true; | 1842 interceptor_for_hidden_properties_called = true; |
1815 return v8::Handle<Value>(); | 1843 return v8::Handle<Value>(); |
1816 } | 1844 } |
1817 | 1845 |
1818 | 1846 |
1819 THREADED_TEST(HiddenPropertiesWithInterceptors) { | 1847 THREADED_TEST(HiddenPropertiesWithInterceptors) { |
1820 v8::HandleScope scope; | 1848 v8::HandleScope scope; |
(...skipping 13326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15147 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); | 15175 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); |
15148 | 15176 |
15149 // TODO(1547): Make the following also return "i". | 15177 // TODO(1547): Make the following also return "i". |
15150 // Calling with environment record as base. | 15178 // Calling with environment record as base. |
15151 TestReceiver(o, context->Global(), "func()"); | 15179 TestReceiver(o, context->Global(), "func()"); |
15152 // Calling with no base. | 15180 // Calling with no base. |
15153 TestReceiver(o, context->Global(), "(1,func)()"); | 15181 TestReceiver(o, context->Global(), "(1,func)()"); |
15154 | 15182 |
15155 foreign_context.Dispose(); | 15183 foreign_context.Dispose(); |
15156 } | 15184 } |
OLD | NEW |