OLD | NEW |
---|---|
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 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2378 | 2378 |
2379 // Test that overwritten methods are not invoked on uncaught exception | 2379 // Test that overwritten methods are not invoked on uncaught exception |
2380 // formatting. However, they are invoked when performing normal error | 2380 // formatting. However, they are invoked when performing normal error |
2381 // string conversions. | 2381 // string conversions. |
2382 TEST(APIThrowMessageOverwrittenToString) { | 2382 TEST(APIThrowMessageOverwrittenToString) { |
2383 v8::HandleScope scope; | 2383 v8::HandleScope scope; |
2384 v8::V8::AddMessageListener(check_reference_error_message); | 2384 v8::V8::AddMessageListener(check_reference_error_message); |
2385 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 2385 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
2386 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail)); | 2386 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail)); |
2387 LocalContext context(NULL, templ); | 2387 LocalContext context(NULL, templ); |
2388 CompileRun("asdf;"); | |
2389 CompileRun("var limit = {};" | |
2390 "limit.valueOf = fail;" | |
2391 "Error.stackTraceLimit = limit;"); | |
2392 CompileRun("asdf"); | |
2388 CompileRun("Array.prototype.pop = fail;"); | 2393 CompileRun("Array.prototype.pop = fail;"); |
2389 CompileRun("Object.prototype.hasOwnProperty = fail;"); | 2394 CompileRun("Object.prototype.hasOwnProperty = fail;"); |
2390 CompileRun("Object.prototype.toString = function f() { return 'Yikes'; }"); | 2395 CompileRun("Object.prototype.toString = function f() { return 'Yikes'; }"); |
2391 CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }"); | 2396 CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }"); |
2392 CompileRun("String.prototype.toString = function f() { return 'Yikes'; }"); | 2397 CompileRun("String.prototype.toString = function f() { return 'Yikes'; }"); |
2393 CompileRun("ReferenceError.prototype.toString =" | 2398 CompileRun("ReferenceError.prototype.toString =" |
2394 " function() { return 'Whoops' }"); | 2399 " function() { return 'Whoops' }"); |
2395 CompileRun("asdf;"); | 2400 CompileRun("asdf;"); |
2396 CompileRun("ReferenceError.prototype.constructor.name = void 0;"); | 2401 CompileRun("ReferenceError.prototype.constructor.name = void 0;"); |
2397 CompileRun("asdf;"); | 2402 CompileRun("asdf;"); |
2398 CompileRun("ReferenceError.prototype.constructor = void 0;"); | 2403 CompileRun("ReferenceError.prototype.constructor = void 0;"); |
2399 CompileRun("asdf;"); | 2404 CompileRun("asdf;"); |
2400 CompileRun("ReferenceError.prototype.__proto__ = new Object();"); | 2405 CompileRun("ReferenceError.prototype.__proto__ = new Object();"); |
2401 CompileRun("asdf;"); | 2406 CompileRun("asdf;"); |
2402 CompileRun("ReferenceError.prototype = new Object();"); | 2407 CompileRun("ReferenceError.prototype = new Object();"); |
2403 CompileRun("asdf;"); | 2408 CompileRun("asdf;"); |
2404 v8::Handle<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }"); | 2409 v8::Handle<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }"); |
2405 CHECK(string->Equals(v8_str("Whoops"))); | 2410 CHECK(string->Equals(v8_str("Whoops"))); |
2406 CompileRun("ReferenceError.prototype.constructor = new Object();" | 2411 CompileRun("ReferenceError.prototype.constructor = new Object();" |
2407 "ReferenceError.prototype.constructor.name = 1;" | 2412 "ReferenceError.prototype.constructor.name = 1;" |
2408 "Number.prototype.toString = function() { return 'Whoops'; };" | 2413 "Number.prototype.toString = function() { return 'Whoops'; };" |
2409 "ReferenceError.prototype.toString = Object.prototype.toString;"); | 2414 "ReferenceError.prototype.toString = Object.prototype.toString;"); |
2410 CompileRun("asdf;"); | |
Søren Thygesen Gjesse
2011/02/02 13:08:17
Why did you remove this?
Mads Ager (chromium)
2011/02/02 13:30:36
Good catch! Thanks, that was unintentional!
| |
2411 v8::V8::RemoveMessageListeners(check_message); | 2415 v8::V8::RemoveMessageListeners(check_message); |
2412 } | 2416 } |
2413 | 2417 |
2414 | 2418 |
2415 static void receive_message(v8::Handle<v8::Message> message, | 2419 static void receive_message(v8::Handle<v8::Message> message, |
2416 v8::Handle<v8::Value> data) { | 2420 v8::Handle<v8::Value> data) { |
2417 message->Get(); | 2421 message->Get(); |
2418 message_received = true; | 2422 message_received = true; |
2419 } | 2423 } |
2420 | 2424 |
(...skipping 9811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12232 v8::Context::Scope context_scope(context.local()); | 12236 v8::Context::Scope context_scope(context.local()); |
12233 | 12237 |
12234 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); | 12238 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); |
12235 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); | 12239 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); |
12236 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); | 12240 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); |
12237 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 12241 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
12238 "var result = []; for (var k in o) result.push(k); result")); | 12242 "var result = []; for (var k in o) result.push(k); result")); |
12239 CHECK_EQ(1, result->Length()); | 12243 CHECK_EQ(1, result->Length()); |
12240 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); | 12244 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); |
12241 } | 12245 } |
OLD | NEW |