| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 550 } |
| 551 | 551 |
| 552 // Use the prototype as the holder for the interceptors. | 552 // Use the prototype as the holder for the interceptors. |
| 553 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { | 553 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { |
| 554 return function->PrototypeTemplate(); | 554 return function->PrototypeTemplate(); |
| 555 } | 555 } |
| 556 }; | 556 }; |
| 557 | 557 |
| 558 | 558 |
| 559 TEST(ExistsInPrototype) { | 559 TEST(ExistsInPrototype) { |
| 560 i::FLAG_es52_globals = true; | |
| 561 HandleScope scope(CcTest::isolate()); | 560 HandleScope scope(CcTest::isolate()); |
| 562 | 561 |
| 563 // Sanity check to make sure that the holder of the interceptor | 562 // Sanity check to make sure that the holder of the interceptor |
| 564 // really is the prototype object. | 563 // really is the prototype object. |
| 565 { ExistsInPrototypeContext context; | 564 { ExistsInPrototypeContext context; |
| 566 context.Check("this.x = 87; this.x", | 565 context.Check("this.x = 87; this.x", |
| 567 0, | 566 0, |
| 568 0, | 567 0, |
| 569 0, | 568 0, |
| 570 EXPECT_RESULT, Number::New(CcTest::isolate(), 87)); | 569 EXPECT_RESULT, Number::New(CcTest::isolate(), 87)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 612 } |
| 614 | 613 |
| 615 // Use the prototype as the holder for the interceptors. | 614 // Use the prototype as the holder for the interceptors. |
| 616 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { | 615 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { |
| 617 return function->PrototypeTemplate(); | 616 return function->PrototypeTemplate(); |
| 618 } | 617 } |
| 619 }; | 618 }; |
| 620 | 619 |
| 621 | 620 |
| 622 TEST(AbsentInPrototype) { | 621 TEST(AbsentInPrototype) { |
| 623 i::FLAG_es52_globals = true; | |
| 624 v8::V8::Initialize(); | 622 v8::V8::Initialize(); |
| 625 HandleScope scope(CcTest::isolate()); | 623 HandleScope scope(CcTest::isolate()); |
| 626 | 624 |
| 627 { AbsentInPrototypeContext context; | 625 { AbsentInPrototypeContext context; |
| 628 context.Check("if (false) { var x = 0; }; x", | 626 context.Check("if (false) { var x = 0; }; x", |
| 629 0, | 627 0, |
| 630 0, | 628 0, |
| 631 0, | 629 0, |
| 632 EXPECT_RESULT, Undefined(CcTest::isolate())); | 630 EXPECT_RESULT, Undefined(CcTest::isolate())); |
| 633 } | 631 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 661 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { | 659 virtual Local<ObjectTemplate> GetHolder(Local<FunctionTemplate> function) { |
| 662 return hidden_proto_->InstanceTemplate(); | 660 return hidden_proto_->InstanceTemplate(); |
| 663 } | 661 } |
| 664 | 662 |
| 665 private: | 663 private: |
| 666 Local<FunctionTemplate> hidden_proto_; | 664 Local<FunctionTemplate> hidden_proto_; |
| 667 }; | 665 }; |
| 668 | 666 |
| 669 | 667 |
| 670 TEST(ExistsInHiddenPrototype) { | 668 TEST(ExistsInHiddenPrototype) { |
| 671 i::FLAG_es52_globals = true; | |
| 672 HandleScope scope(CcTest::isolate()); | 669 HandleScope scope(CcTest::isolate()); |
| 673 | 670 |
| 674 { ExistsInHiddenPrototypeContext context; | 671 { ExistsInHiddenPrototypeContext context; |
| 675 context.Check("var x; x", | 672 context.Check("var x; x", |
| 676 1, // access | 673 1, // access |
| 677 0, | 674 0, |
| 678 2, // declaration + initialization | 675 2, // declaration + initialization |
| 679 EXPECT_EXCEPTION); // x is not defined! | 676 EXPECT_EXCEPTION); // x is not defined! |
| 680 } | 677 } |
| 681 | 678 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 Number::New(CcTest::isolate(), 1)); | 863 Number::New(CcTest::isolate(), 1)); |
| 867 // TODO(rossberg): All tests should actually be errors in Harmony, | 864 // TODO(rossberg): All tests should actually be errors in Harmony, |
| 868 // but we currently do not detect the cases where the first declaration | 865 // but we currently do not detect the cases where the first declaration |
| 869 // is not lexical. | 866 // is not lexical. |
| 870 context.Check(seconds[j], | 867 context.Check(seconds[j], |
| 871 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, | 868 i < 2 ? EXPECT_RESULT : EXPECT_ERROR, |
| 872 Number::New(CcTest::isolate(), 2)); | 869 Number::New(CcTest::isolate(), 2)); |
| 873 } | 870 } |
| 874 } | 871 } |
| 875 } | 872 } |
| OLD | NEW |