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

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

Issue 30443006: Revert "Expose v8::Function::GetDisplayName to public API." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/api.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 17486 matching lines...) Expand 10 before | Expand all | Expand 10 after
17497 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); 17497 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
17498 v8::Handle<v8::String> script = v8::String::New( 17498 v8::Handle<v8::String> script = v8::String::New(
17499 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;"); 17499 "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;");
17500 v8::Script::Compile(script, &origin)->Run(); 17500 v8::Script::Compile(script, &origin)->Run();
17501 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 17501 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
17502 env->Global()->Get(v8::String::New("f"))); 17502 env->Global()->Get(v8::String::New("f")));
17503 CHECK_EQ("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName())); 17503 CHECK_EQ("foo.bar.baz", *v8::String::Utf8Value(f->GetInferredName()));
17504 } 17504 }
17505 17505
17506 17506
17507 THREADED_TEST(FunctionGetDisplayName) {
17508 LocalContext env;
17509 v8::HandleScope scope(env->GetIsolate());
17510 const char* code = "var error = false;"
17511 "function a() { this.x = 1; };"
17512 "a.displayName = 'display_a';"
17513 "var b = (function() {"
17514 " var f = function() { this.x = 2; };"
17515 " f.displayName = 'display_b';"
17516 " return f;"
17517 "})();"
17518 "var c = function() {};"
17519 "c.__defineGetter__('displayName', function() {"
17520 " error = true;"
17521 " throw new Error();"
17522 "});"
17523 "function d() {};"
17524 "d.__defineGetter__('displayName', function() {"
17525 " error = true;"
17526 " return 'wrong_display_name';"
17527 "});"
17528 "function e() {};"
17529 "e.displayName = 'wrong_display_name';"
17530 "e.__defineSetter__('displayName', function() {"
17531 " error = true;"
17532 " throw new Error();"
17533 "});"
17534 "function f() {};"
17535 "f.displayName = { 'foo': 6, toString: function() {"
17536 " error = true;"
17537 " return 'wrong_display_name';"
17538 "}};"
17539 "var g = function() {"
17540 " arguments.callee.displayName = 'set_in_runtime';"
17541 "}; g();"
17542 "a.prototype.displayName = 'prototype_display_a';"
17543 "var hClass = function() {};"
17544 "hClass.prototype.__proto__ = a.prototype;"
17545 "var h = new hClass();"
17546 ;
17547 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
17548 v8::Script::Compile(v8::String::New(code), &origin)->Run();
17549 v8::Local<v8::Value> error = env->Global()->Get(v8::String::New("error"));
17550 v8::Local<v8::Function> a = v8::Local<v8::Function>::Cast(
17551 env->Global()->Get(v8::String::New("a")));
17552 v8::Local<v8::Function> b = v8::Local<v8::Function>::Cast(
17553 env->Global()->Get(v8::String::New("b")));
17554 v8::Local<v8::Function> c = v8::Local<v8::Function>::Cast(
17555 env->Global()->Get(v8::String::New("c")));
17556 v8::Local<v8::Function> d = v8::Local<v8::Function>::Cast(
17557 env->Global()->Get(v8::String::New("d")));
17558 v8::Local<v8::Function> e = v8::Local<v8::Function>::Cast(
17559 env->Global()->Get(v8::String::New("e")));
17560 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
17561 env->Global()->Get(v8::String::New("f")));
17562 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
17563 env->Global()->Get(v8::String::New("g")));
17564 v8::Local<v8::Function> h = v8::Local<v8::Function>::Cast(
17565 env->Global()->Get(v8::String::New("h")));
17566 CHECK_EQ(false, error->BooleanValue());
17567 CHECK_EQ("display_a", *v8::String::Utf8Value(a->GetDisplayName()));
17568 CHECK_EQ("display_b", *v8::String::Utf8Value(b->GetDisplayName()));
17569 CHECK(c->GetDisplayName()->IsUndefined());
17570 CHECK(d->GetDisplayName()->IsUndefined());
17571 CHECK(e->GetDisplayName()->IsUndefined());
17572 CHECK(f->GetDisplayName()->IsUndefined());
17573 CHECK_EQ("set_in_runtime", *v8::String::Utf8Value(g->GetDisplayName()));
17574 CHECK_EQ("prototype_display_a", *v8::String::Utf8Value(h->GetDisplayName()));
17575 }
17576
17577
17578 THREADED_TEST(ScriptLineNumber) { 17507 THREADED_TEST(ScriptLineNumber) {
17579 LocalContext env; 17508 LocalContext env;
17580 v8::HandleScope scope(env->GetIsolate()); 17509 v8::HandleScope scope(env->GetIsolate());
17581 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); 17510 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
17582 v8::Handle<v8::String> script = v8::String::New( 17511 v8::Handle<v8::String> script = v8::String::New(
17583 "function f() {}\n\nfunction g() {}"); 17512 "function f() {}\n\nfunction g() {}");
17584 v8::Script::Compile(script, &origin)->Run(); 17513 v8::Script::Compile(script, &origin)->Run();
17585 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast( 17514 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
17586 env->Global()->Get(v8::String::New("f"))); 17515 env->Global()->Get(v8::String::New("f")));
17587 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast( 17516 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
(...skipping 3130 matching lines...) Expand 10 before | Expand all | Expand 10 after
20718 } 20647 }
20719 for (int i = 0; i < runs; i++) { 20648 for (int i = 0; i < runs; i++) {
20720 Local<String> expected; 20649 Local<String> expected;
20721 if (i != 0) { 20650 if (i != 0) {
20722 CHECK_EQ(v8_str("escape value"), values[i]); 20651 CHECK_EQ(v8_str("escape value"), values[i]);
20723 } else { 20652 } else {
20724 CHECK(values[i].IsEmpty()); 20653 CHECK(values[i].IsEmpty());
20725 } 20654 }
20726 } 20655 }
20727 } 20656 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698