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

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

Issue 594058: Add GetScriptOrigin and GetScriptLineNumber functions for Timeline panel. (Closed)
Patch Set: Created 10 years, 10 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
« 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 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 9463 matching lines...) Expand 10 before | Expand all | Expand 10 after
9474 CompileRun(source_exception); 9474 CompileRun(source_exception);
9475 other_context->Exit(); 9475 other_context->Exit();
9476 v8::internal::Heap::CollectAllGarbage(false); 9476 v8::internal::Heap::CollectAllGarbage(false);
9477 if (GetGlobalObjectsCount() == 1) break; 9477 if (GetGlobalObjectsCount() == 1) break;
9478 } 9478 }
9479 CHECK_GE(2, gc_count); 9479 CHECK_GE(2, gc_count);
9480 CHECK_EQ(1, GetGlobalObjectsCount()); 9480 CHECK_EQ(1, GetGlobalObjectsCount());
9481 9481
9482 other_context.Dispose(); 9482 other_context.Dispose();
9483 } 9483 }
9484
9485
9486 TEST(ScriptOrigin) {
9487 v8::HandleScope scope;
9488 LocalContext env;
9489 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
9490 v8::Handle<v8::String> script = v8::String::New(
9491 "function f() {}\n\nfunction g() {}");
9492 v8::Script::Compile(script, &origin)->Run();
9493 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
9494 env->Global()->Get(v8::String::New("f")));
9495 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
9496 env->Global()->Get(v8::String::New("g")));
9497
9498 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin();
9499 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_f.ResourceName()));
9500 CHECK_EQ(0, script_origin_f.ResourceLineOffset()->Int32Value());
9501
9502 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin();
9503 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_g.ResourceName()));
9504 CHECK_EQ(0, script_origin_g.ResourceLineOffset()->Int32Value());
9505 }
9506
9507
9508 TEST(ScriptLineNumber) {
9509 v8::HandleScope scope;
9510 LocalContext env;
9511 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
9512 v8::Handle<v8::String> script = v8::String::New(
9513 "function f() {}\n\nfunction g() {}");
9514 v8::Script::Compile(script, &origin)->Run();
9515 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
9516 env->Global()->Get(v8::String::New("f")));
9517 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
9518 env->Global()->Get(v8::String::New("g")));
9519 CHECK_EQ(0, f->GetScriptLineNumber());
9520 CHECK_EQ(2, g->GetScriptLineNumber());
9521 }
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