| 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 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 } | 2369 } |
| 2370 | 2370 |
| 2371 | 2371 |
| 2372 // Test that overwritten toString methods are not invoked on uncaught | 2372 // Test that overwritten toString methods are not invoked on uncaught |
| 2373 // exception formatting. However, they are invoked when performing | 2373 // exception formatting. However, they are invoked when performing |
| 2374 // normal error string conversions. | 2374 // normal error string conversions. |
| 2375 TEST(APIThrowMessageOverwrittenToString) { | 2375 TEST(APIThrowMessageOverwrittenToString) { |
| 2376 v8::HandleScope scope; | 2376 v8::HandleScope scope; |
| 2377 v8::V8::AddMessageListener(check_reference_error_message); | 2377 v8::V8::AddMessageListener(check_reference_error_message); |
| 2378 LocalContext context; | 2378 LocalContext context; |
| 2379 CompileRun("Number.prototype.toString = function f() { return 'Yikes'; }"); |
| 2380 CompileRun("String.prototype.toString = function f() { return 'Yikes'; }"); |
| 2379 CompileRun("ReferenceError.prototype.toString =" | 2381 CompileRun("ReferenceError.prototype.toString =" |
| 2380 " function() { return 'Whoops' }"); | 2382 " function() { return 'Whoops' }"); |
| 2381 CompileRun("asdf;"); | 2383 CompileRun("asdf;"); |
| 2382 CompileRun("ReferenceError.prototype.constructor.name = void 0;"); | 2384 CompileRun("ReferenceError.prototype.constructor.name = void 0;"); |
| 2383 CompileRun("asdf;"); | 2385 CompileRun("asdf;"); |
| 2384 CompileRun("ReferenceError.prototype.constructor = void 0;"); | 2386 CompileRun("ReferenceError.prototype.constructor = void 0;"); |
| 2385 CompileRun("asdf;"); | 2387 CompileRun("asdf;"); |
| 2386 CompileRun("ReferenceError.prototype.__proto__ = new Object();"); | 2388 CompileRun("ReferenceError.prototype.__proto__ = new Object();"); |
| 2387 CompileRun("asdf;"); | 2389 CompileRun("asdf;"); |
| 2388 CompileRun("ReferenceError.prototype = new Object();"); | 2390 CompileRun("ReferenceError.prototype = new Object();"); |
| (...skipping 3850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6239 Local<Function> cons = templ->GetFunction(); | 6241 Local<Function> cons = templ->GetFunction(); |
| 6240 context->Global()->Set(v8_str("Fun"), cons); | 6242 context->Global()->Set(v8_str("Fun"), cons); |
| 6241 Local<Value> value = CompileRun( | 6243 Local<Value> value = CompileRun( |
| 6242 "function test() {" | 6244 "function test() {" |
| 6243 " try {" | 6245 " try {" |
| 6244 " (new Fun()).blah()" | 6246 " (new Fun()).blah()" |
| 6245 " } catch (e) {" | 6247 " } catch (e) {" |
| 6246 " var str = String(e);" | 6248 " var str = String(e);" |
| 6247 " if (str.indexOf('TypeError') == -1) return 1;" | 6249 " if (str.indexOf('TypeError') == -1) return 1;" |
| 6248 " if (str.indexOf('[object Fun]') != -1) return 2;" | 6250 " if (str.indexOf('[object Fun]') != -1) return 2;" |
| 6249 " if (str.indexOf('#<a Fun>') == -1) return 3;" | 6251 " if (str.indexOf('#<Fun>') == -1) return 3;" |
| 6250 " return 0;" | 6252 " return 0;" |
| 6251 " }" | 6253 " }" |
| 6252 " return 4;" | 6254 " return 4;" |
| 6253 "}" | 6255 "}" |
| 6254 "test();"); | 6256 "test();"); |
| 6255 CHECK_EQ(0, value->Int32Value()); | 6257 CHECK_EQ(0, value->Int32Value()); |
| 6256 } | 6258 } |
| 6257 | 6259 |
| 6258 | 6260 |
| 6259 THREADED_TEST(EvalAliasedDynamic) { | 6261 THREADED_TEST(EvalAliasedDynamic) { |
| (...skipping 5950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12210 v8::Context::Scope context_scope(context.local()); | 12212 v8::Context::Scope context_scope(context.local()); |
| 12211 | 12213 |
| 12212 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); | 12214 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); |
| 12213 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); | 12215 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); |
| 12214 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); | 12216 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); |
| 12215 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 12217 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
| 12216 "var result = []; for (var k in o) result.push(k); result")); | 12218 "var result = []; for (var k in o) result.push(k); result")); |
| 12217 CHECK_EQ(1, result->Length()); | 12219 CHECK_EQ(1, result->Length()); |
| 12218 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); | 12220 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); |
| 12219 } | 12221 } |
| OLD | NEW |