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

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

Issue 18794003: Test case for missing access checks in object observe. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 19769 matching lines...) Expand 10 before | Expand all | Expand 10 after
19780 context1->Global()->Set(v8_str("array"), array); 19780 context1->Global()->Set(v8_str("array"), array);
19781 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]"); 19781 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]");
19782 array->TurnOnAccessCheck(); 19782 array->TurnOnAccessCheck();
19783 ExpectString("JSON.stringify(array)", "[]"); 19783 ExpectString("JSON.stringify(array)", "[]");
19784 ExpectString("JSON.stringify([array])", "[[]]"); 19784 ExpectString("JSON.stringify([array])", "[[]]");
19785 ExpectString("JSON.stringify({'a' : array})", "{\"a\":[]}"); 19785 ExpectString("JSON.stringify({'a' : array})", "{\"a\":[]}");
19786 } 19786 }
19787 } 19787 }
19788 19788
19789 19789
19790 TEST(Bug2778) {
19791 // Check that Object.observe includes access check.
19792 i::FLAG_harmony_observation = true;
19793 v8::V8::Initialize();
19794 v8::Isolate* isolate = v8::Isolate::GetCurrent();
19795 v8::HandleScope scope(isolate);
19796 // Create an ObjectTemplate for global objects and install access
19797 // check callbacks that will block access.
19798 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
19799 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked,
19800 IndexAccessAlwaysBlocked);
19801
19802 // Create a context and set an x property on it's global object.
19803 LocalContext outer_context(NULL, global_template);
19804 v8::Handle<v8::Object> outer_global = outer_context->Global();
19805 outer_global->Set(v8_str("x"), v8_num(42));
19806
19807 // Enter a new context.
19808 v8::Handle<v8::Context> inner_context = v8::Context::New(isolate);
19809 { v8::Context::Scope inner(inner_context);
19810 v8::Handle<v8::Object> inner_global = inner_context->Global();
19811 inner_global->Set(v8_str("other"), outer_global);
19812 v8::Handle<v8::FunctionTemplate> unreachable =
19813 v8::FunctionTemplate::New(UnreachableCallback);
19814 inner_global->Set(v8_str("unreachable"), unreachable->GetFunction());
19815 ExpectUndefined("other.x"); // Verify that access checks are in place.
19816 CompileRun("Object.observe(other, unreachable);"); // Install observer.
19817 }
19818
19819 ExpectInt32("x", 42);
19820 // This must not be observable by the observer set up in the inner context.
19821 CompileRun("var a = 123;");
19822 }
19823
19824
19790 #endif // WIN32 19825 #endif // WIN32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698