Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/test/cctest/test-api-interceptors.cc b/test/cctest/test-api-interceptors.cc
index a1894fa..1636e4b 100644
--- a/test/cctest/test-api-interceptors.cc
+++ b/test/cctest/test-api-interceptors.cc
@@ -854,6 +854,66 @@
CHECK_EQ(42 * 10, value->Int32Value(context.local()).FromJust());
}
+// Test load of a non-existing global when a global object has an interceptor.
+THREADED_TEST(InterceptorLoadGlobalICGlobalWithInterceptor) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::ObjectTemplate> templ_global = v8::ObjectTemplate::New(isolate);
+ templ_global->SetHandler(v8::NamedPropertyHandlerConfiguration(
+ EmptyInterceptorGetter, EmptyInterceptorSetter));
+
+ LocalContext context(nullptr, templ_global);
+ i::Handle<i::JSReceiver> global_proxy =
+ v8::Utils::OpenHandle<Object, i::JSReceiver>(context->Global());
+ CHECK(global_proxy->IsJSGlobalProxy());
+ i::Handle<i::JSGlobalObject> global(
+ i::JSGlobalObject::cast(global_proxy->map()->prototype()));
+ CHECK(global->map()->has_named_interceptor());
+
+ v8::Local<Value> value = CompileRun(
+ "var f = function() { "
+ " try {"
+ " x1;"
+ " } catch(e) {"
+ " }"
+ " return typeof x1 === 'undefined';"
+ "};"
+ "for (var i = 0; i < 10; i++) {"
+ " f();"
+ "};"
+ "f();");
+ CHECK_EQ(true, value->BooleanValue(context.local()).FromJust());
+
+ value = CompileRun(
+ "var f = function() { "
+ " try {"
+ " x2;"
+ " return false;"
+ " } catch(e) {"
+ " return true;"
+ " }"
+ "};"
+ "for (var i = 0; i < 10; i++) {"
+ " f();"
+ "};"
+ "f();");
+ CHECK_EQ(true, value->BooleanValue(context.local()).FromJust());
+
+ value = CompileRun(
+ "var f = function() { "
+ " try {"
+ " typeof(x3);"
+ " return true;"
+ " } catch(e) {"
+ " return false;"
+ " }"
+ "};"
+ "for (var i = 0; i < 10; i++) {"
+ " f();"
+ "};"
+ "f();");
+ CHECK_EQ(true, value->BooleanValue(context.local()).FromJust());
+}
static void InterceptorLoadICGetter0(
Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
@@ -2270,33 +2330,34 @@
// This order is not mandated by the spec, so this test is just
// documenting our behavior.
CHECK_EQ(17u, result->Length());
- // Indexed properties + indexed interceptor properties in numerical order.
- CHECK(v8_str("0")
+ // Indexed properties.
+ CHECK(v8_str("5")
->Equals(context.local(),
result->Get(context.local(), v8::Integer::New(isolate, 0))
.ToLocalChecked())
.FromJust());
- CHECK(v8_str("1")
+ CHECK(v8_str("10")
->Equals(context.local(),
result->Get(context.local(), v8::Integer::New(isolate, 1))
.ToLocalChecked())
.FromJust());
- CHECK(v8_str("5")
+ CHECK(v8_str("140000")
->Equals(context.local(),
result->Get(context.local(), v8::Integer::New(isolate, 2))
.ToLocalChecked())
.FromJust());
- CHECK(v8_str("10")
+ CHECK(v8_str("4294967294")
->Equals(context.local(),
result->Get(context.local(), v8::Integer::New(isolate, 3))
.ToLocalChecked())
.FromJust());
- CHECK(v8_str("140000")
+ // Indexed Interceptor properties
+ CHECK(v8_str("0")
->Equals(context.local(),
result->Get(context.local(), v8::Integer::New(isolate, 4))
.ToLocalChecked())
.FromJust());
- CHECK(v8_str("4294967294")
+ CHECK(v8_str("1")
->Equals(context.local(),
result->Get(context.local(), v8::Integer::New(isolate, 5))
.ToLocalChecked())
@@ -3245,6 +3306,25 @@
CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();");
}
+THREADED_TEST(Regress625155) {
+ LocalContext context;
+ v8::HandleScope scope(context->GetIsolate());
+ Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
+ AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
+ context->Global()
+ ->Set(context.local(), v8_str("Bug"),
+ templ->GetFunction(context.local()).ToLocalChecked())
+ .FromJust();
+ CompileRun(
+ "Number.prototype.__proto__ = new Bug;"
+ "var x;"
+ "x = 0xdead;"
+ "x.boom = 0;"
+ "x = 's';"
+ "x.boom = 0;"
+ "x = 1.5;"
+ "x.boom = 0;");
+}
THREADED_TEST(Regress125988) {
v8::HandleScope scope(CcTest::isolate());