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

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

Issue 1527863003: [stubs] Fix TypeOfStub to properly return "undefined" for undetectable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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 11636 matching lines...) Expand 10 before | Expand all | Expand 10 after
11647 function_template->GetFunction(context.local()).ToLocalChecked(); 11647 function_template->GetFunction(context.local()).ToLocalChecked();
11648 Local<Object> instance = function; 11648 Local<Object> instance = function;
11649 v8::TryCatch try_catch(isolate); 11649 v8::TryCatch try_catch(isolate);
11650 11650
11651 CHECK(instance->IsCallable()); 11651 CHECK(instance->IsCallable());
11652 CHECK(!try_catch.HasCaught()); 11652 CHECK(!try_catch.HasCaught());
11653 } 11653 }
11654 } 11654 }
11655 11655
11656 11656
11657 THREADED_TEST(Regress567998) {
11658 LocalContext env;
11659 v8::HandleScope scope(env->GetIsolate());
11660
11661 Local<v8::FunctionTemplate> desc =
11662 v8::FunctionTemplate::New(env->GetIsolate());
11663 desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
11664 desc->InstanceTemplate()->SetCallAsFunctionHandler(ReturnThis); // callable
11665
11666 Local<v8::Object> obj = desc->GetFunction(env.local())
11667 .ToLocalChecked()
11668 ->NewInstance(env.local())
11669 .ToLocalChecked();
11670 CHECK(
11671 env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());
11672
11673 ExpectString("undetectable.toString()", "[object Object]");
11674 ExpectString("typeof undetectable", "undefined");
11675 ExpectString("typeof(undetectable)", "undefined");
11676 ExpectBoolean("typeof undetectable == 'undefined'", true);
11677 ExpectBoolean("typeof undetectable == 'object'", false);
11678 ExpectBoolean("if (undetectable) { true; } else { false; }", false);
11679 ExpectBoolean("!undetectable", true);
11680
11681 ExpectObject("true&&undetectable", obj);
11682 ExpectBoolean("false&&undetectable", false);
11683 ExpectBoolean("true||undetectable", true);
11684 ExpectObject("false||undetectable", obj);
11685
11686 ExpectObject("undetectable&&true", obj);
11687 ExpectObject("undetectable&&false", obj);
11688 ExpectBoolean("undetectable||true", true);
11689 ExpectBoolean("undetectable||false", false);
11690
11691 ExpectBoolean("undetectable==null", true);
11692 ExpectBoolean("null==undetectable", true);
11693 ExpectBoolean("undetectable==undefined", true);
11694 ExpectBoolean("undefined==undetectable", true);
11695 ExpectBoolean("undetectable==undetectable", true);
11696
11697 ExpectBoolean("undetectable===null", false);
11698 ExpectBoolean("null===undetectable", false);
11699 ExpectBoolean("undetectable===undefined", false);
11700 ExpectBoolean("undefined===undetectable", false);
11701 ExpectBoolean("undetectable===undetectable", true);
11702 }
11703
11704
11657 static int Recurse(v8::Isolate* isolate, int depth, int iterations) { 11705 static int Recurse(v8::Isolate* isolate, int depth, int iterations) {
11658 v8::HandleScope scope(isolate); 11706 v8::HandleScope scope(isolate);
11659 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate); 11707 if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate);
11660 for (int i = 0; i < iterations; i++) { 11708 for (int i = 0; i < iterations; i++) {
11661 Local<v8::Number> n(v8::Integer::New(isolate, 42)); 11709 Local<v8::Number> n(v8::Integer::New(isolate, 42));
11662 } 11710 }
11663 return Recurse(isolate, depth - 1, iterations); 11711 return Recurse(isolate, depth - 1, iterations);
11664 } 11712 }
11665 11713
11666 11714
(...skipping 12565 matching lines...) Expand 10 before | Expand all | Expand 10 after
24232 CHECK_NE(*object->Get(env2.local(), v8_str("values")).ToLocalChecked(), 24280 CHECK_NE(*object->Get(env2.local(), v8_str("values")).ToLocalChecked(),
24233 *object2->Get(env2.local(), v8_str("values")).ToLocalChecked()); 24281 *object2->Get(env2.local(), v8_str("values")).ToLocalChecked());
24234 24282
24235 auto values2 = Local<Function>::Cast( 24283 auto values2 = Local<Function>::Cast(
24236 object2->Get(env2.local(), v8_str("values")).ToLocalChecked()); 24284 object2->Get(env2.local(), v8_str("values")).ToLocalChecked());
24237 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); 24285 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2));
24238 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); 24286 auto ctx2 = v8::Utils::OpenHandle(*env2.local());
24239 CHECK_EQ(fn2->GetCreationContext(), *ctx2); 24287 CHECK_EQ(fn2->GetCreationContext(), *ctx2);
24240 } 24288 }
24241 } 24289 }
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