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

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

Issue 1546903002: Version 4.8.271.11 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.8
Patch Set: Created 5 years 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/code-stubs-hydrogen.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 10364 matching lines...) Expand 10 before | Expand all | Expand 10 after
10375 Local<Function> function = function_template->GetFunction(); 10375 Local<Function> function = function_template->GetFunction();
10376 Local<Object> instance = function; 10376 Local<Object> instance = function;
10377 v8::TryCatch try_catch(isolate); 10377 v8::TryCatch try_catch(isolate);
10378 10378
10379 CHECK(instance->IsCallable()); 10379 CHECK(instance->IsCallable());
10380 CHECK(!try_catch.HasCaught()); 10380 CHECK(!try_catch.HasCaught());
10381 } 10381 }
10382 } 10382 }
10383 10383
10384 10384
10385 THREADED_TEST(Regress567998) {
10386 LocalContext env;
10387 v8::HandleScope scope(env->GetIsolate());
10388
10389 Local<v8::FunctionTemplate> desc =
10390 v8::FunctionTemplate::New(env->GetIsolate());
10391 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
10392 desc->InstanceTemplate()->SetCallAsFunctionHandler(ReturnThis); // callable
10393
10394 Local<v8::Object> obj = desc->GetFunction(env.local())
10395 .ToLocalChecked()
10396 ->NewInstance(env.local())
10397 .ToLocalChecked();
10398 CHECK(
10399 env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());
10400
10401 ExpectString("undetectable.toString()", "[object Object]");
10402 ExpectString("typeof undetectable", "undefined");
10403 ExpectString("typeof(undetectable)", "undefined");
10404 ExpectBoolean("typeof undetectable == 'undefined'", true);
10405 ExpectBoolean("typeof undetectable == 'object'", false);
10406 ExpectBoolean("if (undetectable) { true; } else { false; }", false);
10407 ExpectBoolean("!undetectable", true);
10408
10409 ExpectObject("true&&undetectable", obj);
10410 ExpectBoolean("false&&undetectable", false);
10411 ExpectBoolean("true||undetectable", true);
10412 ExpectObject("false||undetectable", obj);
10413
10414 ExpectObject("undetectable&&true", obj);
10415 ExpectObject("undetectable&&false", obj);
10416 ExpectBoolean("undetectable||true", true);
10417 ExpectBoolean("undetectable||false", false);
10418
10419 ExpectBoolean("undetectable==null", true);
10420 ExpectBoolean("null==undetectable", true);
10421 ExpectBoolean("undetectable==undefined", true);
10422 ExpectBoolean("undefined==undetectable", true);
10423 ExpectBoolean("undetectable==undetectable", true);
10424
10425 ExpectBoolean("undetectable===null", false);
10426 ExpectBoolean("null===undetectable", false);
10427 ExpectBoolean("undetectable===undefined", false);
10428 ExpectBoolean("undefined===undetectable", false);
10429 ExpectBoolean("undetectable===undetectable", true);
10430 }
10431
10432
10385 static int Recurse(v8::Isolate* isolate, int depth, int iterations) { 10433 static int Recurse(v8::Isolate* isolate, int depth, int iterations) {
10386 v8::HandleScope scope(isolate); 10434 v8::HandleScope scope(isolate);
10387 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate); 10435 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate);
10388 for (int i = 0; i < iterations; i++) { 10436 for (int i = 0; i < iterations; i++) {
10389 Local<v8::Number> n(v8::Integer::New(isolate, 42)); 10437 Local<v8::Number> n(v8::Integer::New(isolate, 42));
10390 } 10438 }
10391 return Recurse(isolate, depth - 1, iterations); 10439 return Recurse(isolate, depth - 1, iterations);
10392 } 10440 }
10393 10441
10394 10442
(...skipping 11685 matching lines...) Expand 10 before | Expand all | Expand 10 after
22080 env2->Global()->Set(v8_str("obj2"), object2); 22128 env2->Global()->Set(v8_str("obj2"), object2);
22081 ExpectString("typeof obj2.values", "function"); 22129 ExpectString("typeof obj2.values", "function");
22082 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); 22130 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values")));
22083 22131
22084 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); 22132 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values")));
22085 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); 22133 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2));
22086 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); 22134 auto ctx2 = v8::Utils::OpenHandle(*env2.local());
22087 CHECK_EQ(fn2->GetCreationContext(), *ctx2); 22135 CHECK_EQ(fn2->GetCreationContext(), *ctx2);
22088 } 22136 }
22089 } 22137 }
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698