Reviewers: dcarney,
Description:
Add a test that JSGlobalProxy properly causes Object.observe to trigger
access
check callbacks
Note that this is mainly for demonstration purposes, as after the attached
bug
is fixed
Object.observe should no longer be calling into the embedder for access
checks.
[email protected]
BUG=367817
Please review this at https://codereview.chromium.org/251583005/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+40, -0 lines):
M test/cctest/test-object-observe.cc
Index: test/cctest/test-object-observe.cc
diff --git a/test/cctest/test-object-observe.cc
b/test/cctest/test-object-observe.cc
index
a8cbaf6ea75a49902e63bd75607fdc8860c62ca2..0ade6aa04f9395c152f8c10e3416461a90b4a4c1
100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -712,6 +712,46 @@ TEST(AccessCheckDisallowApiModifications) {
}
+static bool NamedAccessAlwaysDisallowed(Local<Object>, Local<Value>,
AccessType,
+ Local<Value>) {
+ return false;
+}
+
+
+static bool IndexedAccessAlwaysDisallowed(Local<Object>, uint32_t,
AccessType,
+ Local<Value>) {
+ return false;
+}
+
+
+TEST(AccessCheckedGlobalProxy) {
+ HandleScope scope(CcTest::isolate());
+ Handle<ObjectTemplate> global_template =
+ ObjectTemplate::New(CcTest::isolate());
+ global_template->SetAccessCheckCallbacks(NamedAccessAlwaysDisallowed,
+ IndexedAccessAlwaysDisallowed);
+ Handle<Context> context =
+ Context::New(CcTest::isolate(), NULL, global_template);
+ Handle<Object> global_proxy = context->Global();
+ {
+ LocalContext context2(CcTest::isolate());
+
context2->Global()->Set(String::NewFromUtf8(CcTest::isolate(), "global"),
+ global_proxy);
+ CompileRun("var records = null;"
+ "var observer = function(r) { records = r };"
+ "Object.observe(global, observer);");
+
+ {
+ Context::Scope context_scope(context);
+ CompileRun("foo = 42");
+ CHECK_EQ(42, CompileRun("foo")->Int32Value());
+ }
+ CHECK(CompileRun("records")->IsNull());
+ CHECK(CompileRun("global.foo")->IsUndefined());
+ }
+}
+
+
TEST(HiddenPropertiesLeakage) {
HandleScope scope(CcTest::isolate());
LocalContext context(CcTest::isolate());
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.