OLD | NEW |
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 15540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15551 ApiTestFuzzer::Fuzz(); | 15551 ApiTestFuzzer::Fuzz(); |
15552 return false; | 15552 return false; |
15553 } | 15553 } |
15554 | 15554 |
15555 | 15555 |
15556 THREADED_TEST(AllowCodeGenFromStrings) { | 15556 THREADED_TEST(AllowCodeGenFromStrings) { |
15557 v8::HandleScope scope; | 15557 v8::HandleScope scope; |
15558 LocalContext context; | 15558 LocalContext context; |
15559 | 15559 |
15560 // eval and the Function constructor allowed by default. | 15560 // eval and the Function constructor allowed by default. |
| 15561 CHECK(context->CodeGenerationFromStringsAllowed()); |
15561 CheckCodeGenerationAllowed(); | 15562 CheckCodeGenerationAllowed(); |
15562 | 15563 |
15563 // Disallow eval and the Function constructor. | 15564 // Disallow eval and the Function constructor. |
15564 context->AllowCodeGenerationFromStrings(false); | 15565 context->AllowCodeGenerationFromStrings(false); |
| 15566 CHECK(!context->CodeGenerationFromStringsAllowed()); |
15565 CheckCodeGenerationDisallowed(); | 15567 CheckCodeGenerationDisallowed(); |
15566 | 15568 |
15567 // Allow again. | 15569 // Allow again. |
15568 context->AllowCodeGenerationFromStrings(true); | 15570 context->AllowCodeGenerationFromStrings(true); |
15569 CheckCodeGenerationAllowed(); | 15571 CheckCodeGenerationAllowed(); |
15570 | 15572 |
15571 // Disallow but setting a global callback that will allow the calls. | 15573 // Disallow but setting a global callback that will allow the calls. |
15572 context->AllowCodeGenerationFromStrings(false); | 15574 context->AllowCodeGenerationFromStrings(false); |
15573 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationAllowed); | 15575 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationAllowed); |
| 15576 CHECK(!context->CodeGenerationFromStringsAllowed()); |
15574 CheckCodeGenerationAllowed(); | 15577 CheckCodeGenerationAllowed(); |
15575 | 15578 |
15576 // Set a callback that disallows the code generation. | 15579 // Set a callback that disallows the code generation. |
15577 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); | 15580 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); |
| 15581 CHECK(!context->CodeGenerationFromStringsAllowed()); |
15578 CheckCodeGenerationDisallowed(); | 15582 CheckCodeGenerationDisallowed(); |
15579 } | 15583 } |
15580 | 15584 |
15581 | 15585 |
15582 static v8::Handle<Value> NonObjectThis(const v8::Arguments& args) { | 15586 static v8::Handle<Value> NonObjectThis(const v8::Arguments& args) { |
15583 return v8::Undefined(); | 15587 return v8::Undefined(); |
15584 } | 15588 } |
15585 | 15589 |
15586 | 15590 |
15587 THREADED_TEST(CallAPIFunctionOnNonObject) { | 15591 THREADED_TEST(CallAPIFunctionOnNonObject) { |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15941 CompileRun("throw 'exception';"); | 15945 CompileRun("throw 'exception';"); |
15942 } | 15946 } |
15943 | 15947 |
15944 | 15948 |
15945 TEST(CallCompletedCallbackTwoExceptions) { | 15949 TEST(CallCompletedCallbackTwoExceptions) { |
15946 v8::HandleScope scope; | 15950 v8::HandleScope scope; |
15947 LocalContext env; | 15951 LocalContext env; |
15948 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); | 15952 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); |
15949 CompileRun("throw 'first exception';"); | 15953 CompileRun("throw 'first exception';"); |
15950 } | 15954 } |
OLD | NEW |