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;"); |
(...skipping 9834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12232 v8::Context::Scope context_scope(context.local()); | 12237 v8::Context::Scope context_scope(context.local()); |
12233 | 12238 |
12234 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); | 12239 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); |
12235 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); | 12240 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); |
12236 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); | 12241 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); |
12237 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 12242 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
12238 "var result = []; for (var k in o) result.push(k); result")); | 12243 "var result = []; for (var k in o) result.push(k); result")); |
12239 CHECK_EQ(1, result->Length()); | 12244 CHECK_EQ(1, result->Length()); |
12240 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); | 12245 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); |
12241 } | 12246 } |
OLD | NEW |