Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: test/cctest/test-api.cc

Issue 1178673003: Use the LookupIterator in SetAccessor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make sure we propagate the exception rather than just returning object Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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")));
16783 } 16785 }
16784 16786
16785 16787
16786 TEST(GCInFailedAccessCheckCallback) { 16788 TEST(GCInFailedAccessCheckCallback) {
16787 // Install a failed access check callback that performs a GC on each 16789 // Install a failed access check callback that performs a GC on each
16788 // invocation. Then force the callback to be called from va 16790 // invocation. Then force the callback to be called from va
16789 16791
16790 v8::V8::Initialize(); 16792 v8::V8::Initialize();
16791 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); 16793 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC);
16792 16794
(...skipping 10 matching lines...) Expand all
16803 // Create a context and set an x property on it's global object. 16805 // Create a context and set an x property on it's global object.
16804 LocalContext context0(NULL, global_template); 16806 LocalContext context0(NULL, global_template);
16805 context0->Global()->Set(v8_str("x"), v8_num(42)); 16807 context0->Global()->Set(v8_str("x"), v8_num(42));
16806 v8::Handle<v8::Object> global0 = context0->Global(); 16808 v8::Handle<v8::Object> global0 = context0->Global();
16807 16809
16808 // Create a context with a different security token so that the 16810 // Create a context with a different security token so that the
16809 // failed access check callback will be called on each access. 16811 // failed access check callback will be called on each access.
16810 LocalContext context1(NULL, global_template); 16812 LocalContext context1(NULL, global_template);
16811 context1->Global()->Set(v8_str("other"), global0); 16813 context1->Global()->Set(v8_str("other"), global0);
16812 16814
16815 v8::TryCatch try_catch(isolate);
16816
16813 // Get property with failed access check. 16817 // Get property with failed access check.
16814 ExpectUndefined("other.x"); 16818 CHECK(CompileRun("other.x").IsEmpty());
16819 CHECK(try_catch.HasCaught());
16820 try_catch.Reset();
16815 16821
16816 // Get element with failed access check. 16822 // Get element with failed access check.
16817 ExpectUndefined("other[0]"); 16823 CHECK(CompileRun("other[0]").IsEmpty());
16824 CHECK(try_catch.HasCaught());
16825 try_catch.Reset();
16818 16826
16819 // Set property with failed access check. 16827 // Set property with failed access check.
16820 v8::Handle<v8::Value> result = CompileRun("other.x = new Object()"); 16828 CHECK(CompileRun("other.x = new Object()").IsEmpty());
16821 CHECK(result->IsObject()); 16829 CHECK(try_catch.HasCaught());
16830 try_catch.Reset();
16822 16831
16823 // Set element with failed access check. 16832 // Set element with failed access check.
16824 result = CompileRun("other[0] = new Object()"); 16833 CHECK(CompileRun("other[0] = new Object()").IsEmpty());
16825 CHECK(result->IsObject()); 16834 CHECK(try_catch.HasCaught());
16835 try_catch.Reset();
16826 16836
16827 // Get property attribute with failed access check. 16837 // Get property attribute with failed access check.
16828 ExpectFalse("\'x\' in other"); 16838 CHECK(CompileRun("\'x\' in other").IsEmpty());
16839 CHECK(try_catch.HasCaught());
16840 try_catch.Reset();
16829 16841
16830 // Get property attribute for element with failed access check. 16842 // Get property attribute for element with failed access check.
16831 ExpectFalse("0 in other"); 16843 CHECK(CompileRun("0 in other").IsEmpty());
16844 CHECK(try_catch.HasCaught());
16845 try_catch.Reset();
16832 16846
16833 // Delete property. 16847 // Delete property.
16834 ExpectFalse("delete other.x"); 16848 CHECK(CompileRun("delete other.x").IsEmpty());
16849 CHECK(try_catch.HasCaught());
16850 try_catch.Reset();
16835 16851
16836 // Delete element. 16852 // Delete element.
16837 CHECK_EQ(false, global0->Delete(0)); 16853 CHECK_EQ(false, global0->Delete(0));
16838 16854
16839 // DefineAccessor. 16855 // DefineAccessor.
16840 CHECK_EQ(false, 16856 CHECK_EQ(false,
16841 global0->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("x"))); 16857 global0->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("x")));
16842 16858
16843 // Define JavaScript accessor. 16859 // Define JavaScript accessor.
16844 ExpectUndefined("Object.prototype.__defineGetter__.call(" 16860 CHECK(CompileRun(
16845 " other, \'x\', function() { return 42; })"); 16861 "Object.prototype.__defineGetter__.call("
16862 " other, \'x\', function() { return 42; })").IsEmpty());
16863 CHECK(try_catch.HasCaught());
16864 try_catch.Reset();
16846 16865
16847 // LookupAccessor. 16866 // LookupAccessor.
16848 ExpectUndefined("Object.prototype.__lookupGetter__.call(" 16867 CHECK(CompileRun(
16849 " other, \'x\')"); 16868 "Object.prototype.__lookupGetter__.call("
16869 " other, \'x\')").IsEmpty());
16870 CHECK(try_catch.HasCaught());
16871 try_catch.Reset();
16850 16872
16851 // HasOwnElement. 16873 // HasOwnElement.
16852 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')"); 16874 CHECK(CompileRun(
16875 "Object.prototype.hasOwnProperty.call("
16876 "other, \'0\')").IsEmpty());
16877 CHECK(try_catch.HasCaught());
16878 try_catch.Reset();
16853 16879
16854 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); 16880 CHECK_EQ(false, global0->HasRealIndexedProperty(0));
16855 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); 16881 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x")));
16856 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); 16882 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x")));
16857 16883
16858 // Reset the failed access check callback so it does not influence 16884 // Reset the failed access check callback so it does not influence
16859 // the other tests. 16885 // the other tests.
16860 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 16886 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
16861 } 16887 }
16862 16888
(...skipping 4647 matching lines...) Expand 10 before | Expand all | Expand 10 after
21510 CHECK_EQ(2U, set->Size()); 21536 CHECK_EQ(2U, set->Size());
21511 21537
21512 v8::Local<v8::Array> keys = set->AsArray(); 21538 v8::Local<v8::Array> keys = set->AsArray();
21513 CHECK_EQ(2U, keys->Length()); 21539 CHECK_EQ(2U, keys->Length());
21514 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); 21540 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value());
21515 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); 21541 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value());
21516 21542
21517 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); 21543 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked();
21518 CHECK_EQ(2U, set->Size()); 21544 CHECK_EQ(2U, set->Size());
21519 } 21545 }
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698