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

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

Issue 1909433003: Remove support for Object.observe (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 8 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
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 9028 matching lines...) Expand 10 before | Expand all | Expand 10 after
9039 global->Get(env.local(), v8_str("trouble_caller")).ToLocalChecked(); 9039 global->Get(env.local(), v8_str("trouble_caller")).ToLocalChecked();
9040 CHECK(trouble_caller->IsFunction()); 9040 CHECK(trouble_caller->IsFunction());
9041 Function::Cast(*trouble_caller) 9041 Function::Cast(*trouble_caller)
9042 ->Call(env.local(), global, 0, NULL) 9042 ->Call(env.local(), global, 0, NULL)
9043 .FromMaybe(v8::Local<v8::Value>()); 9043 .FromMaybe(v8::Local<v8::Value>());
9044 CHECK_EQ(1, report_count); 9044 CHECK_EQ(1, report_count);
9045 isolate->RemoveMessageListeners(ApiUncaughtExceptionTestListener); 9045 isolate->RemoveMessageListeners(ApiUncaughtExceptionTestListener);
9046 } 9046 }
9047 9047
9048 9048
9049 TEST(ApiUncaughtExceptionInObjectObserve) {
9050 v8::internal::FLAG_harmony_object_observe = true;
9051 v8::internal::FLAG_stack_size = 150;
9052 report_count = 0;
9053 LocalContext env;
9054 v8::Isolate* isolate = env->GetIsolate();
9055 v8::HandleScope scope(isolate);
9056 isolate->AddMessageListener(ApiUncaughtExceptionTestListener);
9057 CompileRun(
9058 "var obj = {};"
9059 "var observe_count = 0;"
9060 "function observer1() { ++observe_count; };"
9061 "function observer2() { ++observe_count; };"
9062 "function observer_throws() { throw new Error(); };"
9063 "function stack_overflow() { return (function f(x) { f(x+1); })(0); };"
9064 "Object.observe(obj, observer_throws.bind());"
9065 "Object.observe(obj, observer1);"
9066 "Object.observe(obj, stack_overflow);"
9067 "Object.observe(obj, observer2);"
9068 "Object.observe(obj, observer_throws.bind());"
9069 "obj.foo = 'bar';");
9070 CHECK_EQ(3, report_count);
9071 ExpectInt32("observe_count", 2);
9072 isolate->RemoveMessageListeners(ApiUncaughtExceptionTestListener);
9073 }
9074
9075
9076 static const char* script_resource_name = "ExceptionInNativeScript.js"; 9049 static const char* script_resource_name = "ExceptionInNativeScript.js";
9077 static void ExceptionInNativeScriptTestListener(v8::Local<v8::Message> message, 9050 static void ExceptionInNativeScriptTestListener(v8::Local<v8::Message> message,
9078 v8::Local<Value>) { 9051 v8::Local<Value>) {
9079 v8::Local<v8::Value> name_val = message->GetScriptOrigin().ResourceName(); 9052 v8::Local<v8::Value> name_val = message->GetScriptOrigin().ResourceName();
9080 CHECK(!name_val.IsEmpty() && name_val->IsString()); 9053 CHECK(!name_val.IsEmpty() && name_val->IsString());
9081 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName()); 9054 v8::String::Utf8Value name(message->GetScriptOrigin().ResourceName());
9082 CHECK_EQ(0, strcmp(script_resource_name, *name)); 9055 CHECK_EQ(0, strcmp(script_resource_name, *name));
9083 v8::Local<v8::Context> context = 9056 v8::Local<v8::Context> context =
9084 v8::Isolate::GetCurrent()->GetCurrentContext(); 9057 v8::Isolate::GetCurrent()->GetCurrentContext();
9085 CHECK_EQ(3, message->GetLineNumber(context).FromJust()); 9058 CHECK_EQ(3, message->GetLineNumber(context).FromJust());
(...skipping 12185 matching lines...) Expand 10 before | Expand all | Expand 10 after
21271 v8::MicrotasksScope scope(env->GetIsolate(), 21244 v8::MicrotasksScope scope(env->GetIsolate(),
21272 v8::MicrotasksScope::kDoNotRunMicrotasks); 21245 v8::MicrotasksScope::kDoNotRunMicrotasks);
21273 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust()); 21246 CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
21274 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust()); 21247 CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
21275 } 21248 }
21276 21249
21277 env->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kAuto); 21250 env->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kAuto);
21278 } 21251 }
21279 21252
21280 21253
21281 static void DebugEventInObserver(const v8::Debug::EventDetails& event_details) {
21282 v8::DebugEvent event = event_details.GetEvent();
21283 if (event != v8::Break) return;
21284 Local<Object> exec_state = event_details.GetExecutionState();
21285 Local<Context> context = CcTest::isolate()->GetCurrentContext();
21286 Local<Value> break_id =
21287 exec_state->Get(context, v8_str("break_id")).ToLocalChecked();
21288 CompileRun("function f(id) { new FrameDetails(id, 0); }");
21289 Local<Function> fun = Local<Function>::Cast(
21290 CcTest::global()->Get(context, v8_str("f")).ToLocalChecked());
21291 fun->Call(context, CcTest::global(), 1, &break_id).ToLocalChecked();
21292 }
21293
21294
21295 TEST(Regress385349) {
21296 i::FLAG_harmony_object_observe = true;
21297 i::FLAG_allow_natives_syntax = true;
21298 v8::Isolate* isolate = CcTest::isolate();
21299 HandleScope handle_scope(isolate);
21300 isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
21301 Local<Context> context = Context::New(isolate);
21302 v8::Debug::SetDebugEventListener(isolate, DebugEventInObserver);
21303 {
21304 Context::Scope context_scope(context);
21305 CompileRun("var obj = {};"
21306 "Object.observe(obj, function(changes) { debugger; });"
21307 "obj.a = 0;");
21308 }
21309 isolate->RunMicrotasks();
21310 isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kAuto);
21311 v8::Debug::SetDebugEventListener(isolate, nullptr);
21312 }
21313
21314
21315 #ifdef ENABLE_DISASSEMBLER 21254 #ifdef ENABLE_DISASSEMBLER
21316 static int probes_counter = 0; 21255 static int probes_counter = 0;
21317 static int misses_counter = 0; 21256 static int misses_counter = 0;
21318 static int updates_counter = 0; 21257 static int updates_counter = 0;
21319 21258
21320 21259
21321 static int* LookupCounter(const char* name) { 21260 static int* LookupCounter(const char* name) {
21322 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { 21261 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) {
21323 return &probes_counter; 21262 return &probes_counter;
21324 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { 21263 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) {
(...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after
25028 } 24967 }
25029 24968
25030 TEST(PrivateForApiIsNumber) { 24969 TEST(PrivateForApiIsNumber) {
25031 LocalContext context; 24970 LocalContext context;
25032 v8::Isolate* isolate = CcTest::isolate(); 24971 v8::Isolate* isolate = CcTest::isolate();
25033 v8::HandleScope scope(isolate); 24972 v8::HandleScope scope(isolate);
25034 24973
25035 // Shouldn't crash. 24974 // Shouldn't crash.
25036 v8::Private::ForApi(isolate, v8_str("42")); 24975 v8::Private::ForApi(isolate, v8_str("42"));
25037 } 24976 }
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/Generators.golden ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698