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

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

Issue 363893003: Stack traces exposed to Javascript should omit extensions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('k') | test/mjsunit/stack-traces-overflow.js » ('j') | 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 6676 matching lines...) Expand 10 before | Expand all | Expand 10 after
6687 const char* extension_names[] = { "simpletest" }; 6687 const char* extension_names[] = { "simpletest" };
6688 v8::ExtensionConfiguration extensions(1, extension_names); 6688 v8::ExtensionConfiguration extensions(1, extension_names);
6689 v8::Handle<Context> context = 6689 v8::Handle<Context> context =
6690 Context::New(CcTest::isolate(), &extensions); 6690 Context::New(CcTest::isolate(), &extensions);
6691 Context::Scope lock(context); 6691 Context::Scope lock(context);
6692 v8::Handle<Value> result = CompileRun("Foo()"); 6692 v8::Handle<Value> result = CompileRun("Foo()");
6693 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); 6693 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4));
6694 } 6694 }
6695 6695
6696 6696
6697 static const char* kStackTraceFromExtensionSource =
6698 "function foo() {"
6699 " throw new Error();"
6700 "}"
6701 "function bar() {"
6702 " foo();"
6703 "}";
6704
6705
6706 TEST(StackTraceInExtension) {
6707 v8::HandleScope handle_scope(CcTest::isolate());
6708 v8::RegisterExtension(new Extension("stacktracetest",
6709 kStackTraceFromExtensionSource));
6710 const char* extension_names[] = { "stacktracetest" };
6711 v8::ExtensionConfiguration extensions(1, extension_names);
6712 v8::Handle<Context> context =
6713 Context::New(CcTest::isolate(), &extensions);
6714 Context::Scope lock(context);
6715 CompileRun("function user() { bar(); }"
6716 "var error;"
6717 "try{ user(); } catch (e) { error = e; }");
6718 CHECK_EQ(-1, CompileRun("error.stack.indexOf('foo')")->Int32Value());
6719 CHECK_EQ(-1, CompileRun("error.stack.indexOf('bar')")->Int32Value());
6720 CHECK_NE(-1, CompileRun("error.stack.indexOf('user')")->Int32Value());
6721 }
6722
6723
6697 TEST(NullExtensions) { 6724 TEST(NullExtensions) {
6698 v8::HandleScope handle_scope(CcTest::isolate()); 6725 v8::HandleScope handle_scope(CcTest::isolate());
6699 v8::RegisterExtension(new Extension("nulltest", NULL)); 6726 v8::RegisterExtension(new Extension("nulltest", NULL));
6700 const char* extension_names[] = { "nulltest" }; 6727 const char* extension_names[] = { "nulltest" };
6701 v8::ExtensionConfiguration extensions(1, extension_names); 6728 v8::ExtensionConfiguration extensions(1, extension_names);
6702 v8::Handle<Context> context = 6729 v8::Handle<Context> context =
6703 Context::New(CcTest::isolate(), &extensions); 6730 Context::New(CcTest::isolate(), &extensions);
6704 Context::Scope lock(context); 6731 Context::Scope lock(context);
6705 v8::Handle<Value> result = CompileRun("1+3"); 6732 v8::Handle<Value> result = CompileRun("1+3");
6706 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); 6733 CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4));
(...skipping 16129 matching lines...) Expand 10 before | Expand all | Expand 10 after
22836 SourceURLHelper("function foo() {}\n" 22863 SourceURLHelper("function foo() {}\n"
22837 "//# sourceURL=bar19\".js \n" 22864 "//# sourceURL=bar19\".js \n"
22838 "//# sourceMappingURL=bar20\".js \n", 22865 "//# sourceMappingURL=bar20\".js \n",
22839 NULL, NULL); 22866 NULL, NULL);
22840 22867
22841 // Not too much whitespace. 22868 // Not too much whitespace.
22842 SourceURLHelper("function foo() {}\n" 22869 SourceURLHelper("function foo() {}\n"
22843 "//# sourceURL= bar21.js \n" 22870 "//# sourceURL= bar21.js \n"
22844 "//# sourceMappingURL= bar22.js \n", "bar21.js", "bar22.js"); 22871 "//# sourceMappingURL= bar22.js \n", "bar21.js", "bar22.js");
22845 } 22872 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | test/mjsunit/stack-traces-overflow.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698