OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 // the random number generator should be evaluated. | 1642 // the random number generator should be evaluated. |
1643 CHECK_NE(hash, hash2); | 1643 CHECK_NE(hash, hash2); |
1644 i::Heap::CollectAllGarbage(false); | 1644 i::Heap::CollectAllGarbage(false); |
1645 int hash3 = v8::Object::New()->GetIdentityHash(); | 1645 int hash3 = v8::Object::New()->GetIdentityHash(); |
1646 // Make sure that the identity hash is not based on the initial address of | 1646 // Make sure that the identity hash is not based on the initial address of |
1647 // the object alone. If the test below fails the random number generator | 1647 // the object alone. If the test below fails the random number generator |
1648 // should be evaluated. | 1648 // should be evaluated. |
1649 CHECK_NE(hash, hash3); | 1649 CHECK_NE(hash, hash3); |
1650 int hash4 = obj->GetIdentityHash(); | 1650 int hash4 = obj->GetIdentityHash(); |
1651 CHECK_EQ(hash, hash4); | 1651 CHECK_EQ(hash, hash4); |
| 1652 |
| 1653 // Check identity hashes behaviour in the presence of JS accessors. |
| 1654 // Put a getter for 'v8::IdentityHash' on the Object's prototype: |
| 1655 { |
| 1656 CompileRun("Object.prototype['v8::IdentityHash'] = 42;\n"); |
| 1657 Local<v8::Object> o1 = v8::Object::New(); |
| 1658 Local<v8::Object> o2 = v8::Object::New(); |
| 1659 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash()); |
| 1660 } |
| 1661 { |
| 1662 CompileRun( |
| 1663 "function cnst() { return 42; };\n" |
| 1664 "Object.prototype.__defineGetter__('v8::IdentityHash', cnst);\n"); |
| 1665 Local<v8::Object> o1 = v8::Object::New(); |
| 1666 Local<v8::Object> o2 = v8::Object::New(); |
| 1667 CHECK_NE(o1->GetIdentityHash(), o2->GetIdentityHash()); |
| 1668 } |
1652 } | 1669 } |
1653 | 1670 |
1654 | 1671 |
1655 THREADED_TEST(HiddenProperties) { | 1672 THREADED_TEST(HiddenProperties) { |
1656 v8::HandleScope scope; | 1673 v8::HandleScope scope; |
1657 LocalContext env; | 1674 LocalContext env; |
1658 | 1675 |
1659 v8::Local<v8::Object> obj = v8::Object::New(); | 1676 v8::Local<v8::Object> obj = v8::Object::New(); |
1660 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 1677 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
1661 v8::Local<v8::String> empty = v8_str(""); | 1678 v8::Local<v8::String> empty = v8_str(""); |
(...skipping 10896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12558 v8::Handle<v8::Function> define_property = | 12575 v8::Handle<v8::Function> define_property = |
12559 CompileRun("(function() {" | 12576 CompileRun("(function() {" |
12560 " Object.defineProperty(" | 12577 " Object.defineProperty(" |
12561 " this," | 12578 " this," |
12562 " 1," | 12579 " 1," |
12563 " { configurable: true, enumerable: true, value: 3 });" | 12580 " { configurable: true, enumerable: true, value: 3 });" |
12564 "})").As<Function>(); | 12581 "})").As<Function>(); |
12565 context->DetachGlobal(); | 12582 context->DetachGlobal(); |
12566 define_property->Call(proxy, 0, NULL); | 12583 define_property->Call(proxy, 0, NULL); |
12567 } | 12584 } |
OLD | NEW |