OLD | NEW |
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 4901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4912 " }" | 4912 " }" |
4913 "} catch (e) {" | 4913 "} catch (e) {" |
4914 "}"); | 4914 "}"); |
4915 CHECK(result->IsTrue()); | 4915 CHECK(result->IsTrue()); |
4916 } | 4916 } |
4917 | 4917 |
4918 | 4918 |
4919 static void check_reference_error_message(v8::Handle<v8::Message> message, | 4919 static void check_reference_error_message(v8::Handle<v8::Message> message, |
4920 v8::Handle<v8::Value> data) { | 4920 v8::Handle<v8::Value> data) { |
4921 const char* reference_error = "Uncaught ReferenceError: asdf is not defined"; | 4921 const char* reference_error = "Uncaught ReferenceError: asdf is not defined"; |
4922 CHECK(message->Get()->Equals(v8_str(reference_error))); | 4922 const char* reference_error2 = "Uncaught Error: asdf is not defined"; |
| 4923 CHECK(message->Get()->Equals(v8_str(reference_error)) || |
| 4924 message->Get()->Equals(v8_str(reference_error2))); |
4923 } | 4925 } |
4924 | 4926 |
4925 | 4927 |
4926 static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4928 static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { |
4927 ApiTestFuzzer::Fuzz(); | 4929 ApiTestFuzzer::Fuzz(); |
4928 CHECK(false); | 4930 CHECK(false); |
4929 } | 4931 } |
4930 | 4932 |
4931 | 4933 |
4932 // Test that overwritten methods are not invoked on uncaught exception | 4934 // Test that overwritten methods are not invoked on uncaught exception |
(...skipping 6504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11437 | 11439 |
11438 | 11440 |
11439 THREADED_TEST(ObjectGetConstructorName) { | 11441 THREADED_TEST(ObjectGetConstructorName) { |
11440 v8::Isolate* isolate = CcTest::isolate(); | 11442 v8::Isolate* isolate = CcTest::isolate(); |
11441 LocalContext context; | 11443 LocalContext context; |
11442 v8::HandleScope scope(isolate); | 11444 v8::HandleScope scope(isolate); |
11443 v8_compile( | 11445 v8_compile( |
11444 "function Parent() {};" | 11446 "function Parent() {};" |
11445 "function Child() {};" | 11447 "function Child() {};" |
11446 "Child.prototype = new Parent();" | 11448 "Child.prototype = new Parent();" |
| 11449 "Child.prototype.constructor = Child;" |
11447 "var outer = { inner: function() { } };" | 11450 "var outer = { inner: function() { } };" |
11448 "var p = new Parent();" | 11451 "var p = new Parent();" |
11449 "var c = new Child();" | 11452 "var c = new Child();" |
11450 "var x = new outer.inner();" | 11453 "var x = new outer.inner();" |
11451 "var proto = Child.prototype;")->Run(); | 11454 "var proto = Child.prototype;") |
| 11455 ->Run(); |
11452 | 11456 |
11453 Local<v8::Value> p = context->Global()->Get(v8_str("p")); | 11457 Local<v8::Value> p = context->Global()->Get(v8_str("p")); |
11454 CHECK(p->IsObject() && | 11458 CHECK(p->IsObject() && |
11455 p->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Parent"))); | 11459 p->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Parent"))); |
11456 | 11460 |
11457 Local<v8::Value> c = context->Global()->Get(v8_str("c")); | 11461 Local<v8::Value> c = context->Global()->Get(v8_str("c")); |
11458 CHECK(c->IsObject() && | 11462 CHECK(c->IsObject() && |
11459 c->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Child"))); | 11463 c->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Child"))); |
11460 | 11464 |
11461 Local<v8::Value> x = context->Global()->Get(v8_str("x")); | 11465 Local<v8::Value> x = context->Global()->Get(v8_str("x")); |
11462 CHECK(x->IsObject() && | 11466 CHECK(x->IsObject() && |
11463 x->ToObject(isolate)->GetConstructorName()->Equals( | 11467 x->ToObject(isolate)->GetConstructorName()->Equals( |
11464 v8_str("outer.inner"))); | 11468 v8_str("outer.inner"))); |
11465 | 11469 |
11466 Local<v8::Value> child_prototype = context->Global()->Get(v8_str("proto")); | 11470 Local<v8::Value> child_prototype = context->Global()->Get(v8_str("proto")); |
11467 CHECK(child_prototype->IsObject() && | 11471 CHECK(child_prototype->IsObject() && |
11468 child_prototype->ToObject(isolate)->GetConstructorName()->Equals( | 11472 child_prototype->ToObject(isolate)->GetConstructorName()->Equals( |
11469 v8_str("Parent"))); | 11473 v8_str("Parent"))); |
11470 } | 11474 } |
11471 | 11475 |
11472 | 11476 |
| 11477 THREADED_TEST(SubclassGetConstructorName) { |
| 11478 v8::Isolate* isolate = CcTest::isolate(); |
| 11479 LocalContext context; |
| 11480 v8::HandleScope scope(isolate); |
| 11481 v8_compile( |
| 11482 "\"use strict\";" |
| 11483 "class Parent {}" |
| 11484 "class Child extends Parent {}" |
| 11485 "var p = new Parent();" |
| 11486 "var c = new Child();") |
| 11487 ->Run(); |
| 11488 |
| 11489 Local<v8::Value> p = context->Global()->Get(v8_str("p")); |
| 11490 CHECK(p->IsObject() && |
| 11491 p->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Parent"))); |
| 11492 |
| 11493 Local<v8::Value> c = context->Global()->Get(v8_str("c")); |
| 11494 CHECK(c->IsObject() && |
| 11495 c->ToObject(isolate)->GetConstructorName()->Equals(v8_str("Child"))); |
| 11496 } |
| 11497 |
| 11498 |
11473 bool ApiTestFuzzer::fuzzing_ = false; | 11499 bool ApiTestFuzzer::fuzzing_ = false; |
11474 v8::base::Semaphore ApiTestFuzzer::all_tests_done_(0); | 11500 v8::base::Semaphore ApiTestFuzzer::all_tests_done_(0); |
11475 int ApiTestFuzzer::active_tests_; | 11501 int ApiTestFuzzer::active_tests_; |
11476 int ApiTestFuzzer::tests_being_run_; | 11502 int ApiTestFuzzer::tests_being_run_; |
11477 int ApiTestFuzzer::current_; | 11503 int ApiTestFuzzer::current_; |
11478 | 11504 |
11479 | 11505 |
11480 // We are in a callback and want to switch to another thread (if we | 11506 // We are in a callback and want to switch to another thread (if we |
11481 // are currently running the thread fuzzing test). | 11507 // are currently running the thread fuzzing test). |
11482 void ApiTestFuzzer::Fuzz() { | 11508 void ApiTestFuzzer::Fuzz() { |
(...skipping 10597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22080 env2->Global()->Set(v8_str("obj2"), object2); | 22106 env2->Global()->Set(v8_str("obj2"), object2); |
22081 ExpectString("typeof obj2.values", "function"); | 22107 ExpectString("typeof obj2.values", "function"); |
22082 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); | 22108 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); |
22083 | 22109 |
22084 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); | 22110 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); |
22085 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); | 22111 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); |
22086 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); | 22112 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); |
22087 CHECK_EQ(fn2->GetCreationContext(), *ctx2); | 22113 CHECK_EQ(fn2->GetCreationContext(), *ctx2); |
22088 } | 22114 } |
22089 } | 22115 } |
OLD | NEW |