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

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

Issue 6287041: Avoid callbacks to user code during error formatting in a couple of (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
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 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 2362
2363 2363
2364 static void check_reference_error_message( 2364 static void check_reference_error_message(
2365 v8::Handle<v8::Message> message, 2365 v8::Handle<v8::Message> message,
2366 v8::Handle<v8::Value> data) { 2366 v8::Handle<v8::Value> data) {
2367 const char* reference_error = "Uncaught ReferenceError: asdf is not defined"; 2367 const char* reference_error = "Uncaught ReferenceError: asdf is not defined";
2368 CHECK(message->Get()->Equals(v8_str(reference_error))); 2368 CHECK(message->Get()->Equals(v8_str(reference_error)));
2369 } 2369 }
2370 2370
2371 2371
2372 // Test that overwritten toString methods are not invoked on uncaught 2372 static v8::Handle<Value> Fail(const v8::Arguments& args) {
2373 // exception formatting. However, they are invoked when performing 2373 ApiTestFuzzer::Fuzz();
2374 // normal error string conversions. 2374 CHECK(false);
2375 return v8::Undefined();
2376 }
2377
2378
2379 // Test that overwritten methods are not invoked on uncaught exception
2380 // formatting. However, they are invoked when performing normal error
2381 // string conversions.
2375 TEST(APIThrowMessageOverwrittenToString) { 2382 TEST(APIThrowMessageOverwrittenToString) {
2376 v8::HandleScope scope; 2383 v8::HandleScope scope;
2377 v8::V8::AddMessageListener(check_reference_error_message); 2384 v8::V8::AddMessageListener(check_reference_error_message);
2378 LocalContext context; 2385 Local<ObjectTemplate> templ = ObjectTemplate::New();
2386 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail));
2387 LocalContext context(NULL, templ);
2388 CompileRun("Array.prototype.pop = fail;");
2389 CompileRun("Object.prototype.hasOwnProperty = fail;");
2390 CompileRun("Object.prototype.toString = function f() { return 'Yikes'; }");
2379 CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }"); 2391 CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }");
2380 CompileRun("String.prototype.toString = function f() { return 'Yikes'; }"); 2392 CompileRun("String.prototype.toString = function f() { return 'Yikes'; }");
2381 CompileRun("ReferenceError.prototype.toString =" 2393 CompileRun("ReferenceError.prototype.toString ="
2382 " function() { return 'Whoops' }"); 2394 " function() { return 'Whoops' }");
2383 CompileRun("asdf;"); 2395 CompileRun("asdf;");
2384 CompileRun("ReferenceError.prototype.constructor.name = void 0;"); 2396 CompileRun("ReferenceError.prototype.constructor.name = void 0;");
2385 CompileRun("asdf;"); 2397 CompileRun("asdf;");
2386 CompileRun("ReferenceError.prototype.constructor = void 0;"); 2398 CompileRun("ReferenceError.prototype.constructor = void 0;");
2387 CompileRun("asdf;"); 2399 CompileRun("asdf;");
2388 CompileRun("ReferenceError.prototype.__proto__ = new Object();"); 2400 CompileRun("ReferenceError.prototype.__proto__ = new Object();");
(...skipping 9831 matching lines...) Expand 10 before | Expand all | Expand 10 after
12220 v8::Context::Scope context_scope(context.local()); 12232 v8::Context::Scope context_scope(context.local());
12221 12233
12222 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12234 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12223 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12235 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12224 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12236 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12225 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12237 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12226 "var result = []; for (var k in o) result.push(k); result")); 12238 "var result = []; for (var k in o) result.push(k); result"));
12227 CHECK_EQ(1, result->Length()); 12239 CHECK_EQ(1, result->Length());
12228 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12240 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12229 } 12241 }
OLDNEW
« src/array.js ('K') | « src/mirror-debugger.js ('k') | test/mjsunit/mirror-error.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698