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 16762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16773 } | 16773 } |
16774 } | 16774 } |
16775 } | 16775 } |
16776 | 16776 |
16777 | 16777 |
16778 // Failed access check callback that performs a GC on each invocation. | 16778 // Failed access check callback that performs a GC on each invocation. |
16779 void FailedAccessCheckCallbackGC(Local<v8::Object> target, | 16779 void FailedAccessCheckCallbackGC(Local<v8::Object> target, |
16780 v8::AccessType type, | 16780 v8::AccessType type, |
16781 Local<v8::Value> data) { | 16781 Local<v8::Value> data) { |
16782 CcTest::heap()->CollectAllGarbage(); | 16782 CcTest::heap()->CollectAllGarbage(); |
16783 CcTest::isolate()->ThrowException( | |
16784 v8::Exception::Error(v8_str("cross context"))); | |
16785 } | 16783 } |
16786 | 16784 |
16787 | 16785 |
16788 TEST(GCInFailedAccessCheckCallback) { | 16786 TEST(GCInFailedAccessCheckCallback) { |
16789 // Install a failed access check callback that performs a GC on each | 16787 // Install a failed access check callback that performs a GC on each |
16790 // invocation. Then force the callback to be called from va | 16788 // invocation. Then force the callback to be called from va |
16791 | 16789 |
16792 v8::V8::Initialize(); | 16790 v8::V8::Initialize(); |
16793 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); | 16791 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); |
16794 | 16792 |
(...skipping 10 matching lines...) Expand all Loading... |
16805 // Create a context and set an x property on it's global object. | 16803 // Create a context and set an x property on it's global object. |
16806 LocalContext context0(NULL, global_template); | 16804 LocalContext context0(NULL, global_template); |
16807 context0->Global()->Set(v8_str("x"), v8_num(42)); | 16805 context0->Global()->Set(v8_str("x"), v8_num(42)); |
16808 v8::Handle<v8::Object> global0 = context0->Global(); | 16806 v8::Handle<v8::Object> global0 = context0->Global(); |
16809 | 16807 |
16810 // Create a context with a different security token so that the | 16808 // Create a context with a different security token so that the |
16811 // failed access check callback will be called on each access. | 16809 // failed access check callback will be called on each access. |
16812 LocalContext context1(NULL, global_template); | 16810 LocalContext context1(NULL, global_template); |
16813 context1->Global()->Set(v8_str("other"), global0); | 16811 context1->Global()->Set(v8_str("other"), global0); |
16814 | 16812 |
16815 v8::TryCatch try_catch(isolate); | |
16816 | |
16817 // Get property with failed access check. | 16813 // Get property with failed access check. |
16818 CHECK(CompileRun("other.x").IsEmpty()); | 16814 ExpectUndefined("other.x"); |
16819 CHECK(try_catch.HasCaught()); | |
16820 try_catch.Reset(); | |
16821 | 16815 |
16822 // Get element with failed access check. | 16816 // Get element with failed access check. |
16823 CHECK(CompileRun("other[0]").IsEmpty()); | 16817 ExpectUndefined("other[0]"); |
16824 CHECK(try_catch.HasCaught()); | |
16825 try_catch.Reset(); | |
16826 | 16818 |
16827 // Set property with failed access check. | 16819 // Set property with failed access check. |
16828 CHECK(CompileRun("other.x = new Object()").IsEmpty()); | 16820 v8::Handle<v8::Value> result = CompileRun("other.x = new Object()"); |
16829 CHECK(try_catch.HasCaught()); | 16821 CHECK(result->IsObject()); |
16830 try_catch.Reset(); | |
16831 | 16822 |
16832 // Set element with failed access check. | 16823 // Set element with failed access check. |
16833 CHECK(CompileRun("other[0] = new Object()").IsEmpty()); | 16824 result = CompileRun("other[0] = new Object()"); |
16834 CHECK(try_catch.HasCaught()); | 16825 CHECK(result->IsObject()); |
16835 try_catch.Reset(); | |
16836 | 16826 |
16837 // Get property attribute with failed access check. | 16827 // Get property attribute with failed access check. |
16838 CHECK(CompileRun("\'x\' in other").IsEmpty()); | 16828 ExpectFalse("\'x\' in other"); |
16839 CHECK(try_catch.HasCaught()); | |
16840 try_catch.Reset(); | |
16841 | 16829 |
16842 // Get property attribute for element with failed access check. | 16830 // Get property attribute for element with failed access check. |
16843 CHECK(CompileRun("0 in other").IsEmpty()); | 16831 ExpectFalse("0 in other"); |
16844 CHECK(try_catch.HasCaught()); | |
16845 try_catch.Reset(); | |
16846 | 16832 |
16847 // Delete property. | 16833 // Delete property. |
16848 CHECK(CompileRun("delete other.x").IsEmpty()); | 16834 ExpectFalse("delete other.x"); |
16849 CHECK(try_catch.HasCaught()); | |
16850 try_catch.Reset(); | |
16851 | 16835 |
16852 // Delete element. | 16836 // Delete element. |
16853 CHECK_EQ(false, global0->Delete(0)); | 16837 CHECK_EQ(false, global0->Delete(0)); |
16854 | 16838 |
16855 // DefineAccessor. | 16839 // DefineAccessor. |
16856 CHECK_EQ(false, | 16840 CHECK_EQ(false, |
16857 global0->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("x"))); | 16841 global0->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("x"))); |
16858 | 16842 |
16859 // Define JavaScript accessor. | 16843 // Define JavaScript accessor. |
16860 CHECK(CompileRun( | 16844 ExpectUndefined("Object.prototype.__defineGetter__.call(" |
16861 "Object.prototype.__defineGetter__.call(" | 16845 " other, \'x\', function() { return 42; })"); |
16862 " other, \'x\', function() { return 42; })").IsEmpty()); | |
16863 CHECK(try_catch.HasCaught()); | |
16864 try_catch.Reset(); | |
16865 | 16846 |
16866 // LookupAccessor. | 16847 // LookupAccessor. |
16867 CHECK(CompileRun( | 16848 ExpectUndefined("Object.prototype.__lookupGetter__.call(" |
16868 "Object.prototype.__lookupGetter__.call(" | 16849 " other, \'x\')"); |
16869 " other, \'x\')").IsEmpty()); | |
16870 CHECK(try_catch.HasCaught()); | |
16871 try_catch.Reset(); | |
16872 | 16850 |
16873 // HasOwnElement. | 16851 // HasOwnElement. |
16874 CHECK(CompileRun( | 16852 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')"); |
16875 "Object.prototype.hasOwnProperty.call(" | |
16876 "other, \'0\')").IsEmpty()); | |
16877 CHECK(try_catch.HasCaught()); | |
16878 try_catch.Reset(); | |
16879 | 16853 |
16880 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); | 16854 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); |
16881 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); | 16855 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); |
16882 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); | 16856 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); |
16883 | 16857 |
16884 // Reset the failed access check callback so it does not influence | 16858 // Reset the failed access check callback so it does not influence |
16885 // the other tests. | 16859 // the other tests. |
16886 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); | 16860 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); |
16887 } | 16861 } |
16888 | 16862 |
(...skipping 4647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21536 CHECK_EQ(2U, set->Size()); | 21510 CHECK_EQ(2U, set->Size()); |
21537 | 21511 |
21538 v8::Local<v8::Array> keys = set->AsArray(); | 21512 v8::Local<v8::Array> keys = set->AsArray(); |
21539 CHECK_EQ(2U, keys->Length()); | 21513 CHECK_EQ(2U, keys->Length()); |
21540 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); | 21514 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); |
21541 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); | 21515 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); |
21542 | 21516 |
21543 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); | 21517 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); |
21544 CHECK_EQ(2U, set->Size()); | 21518 CHECK_EQ(2U, set->Size()); |
21545 } | 21519 } |
OLD | NEW |