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 21882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21893 } | 21893 } |
21894 { | 21894 { |
21895 v8::TryCatch try_catch; | 21895 v8::TryCatch try_catch; |
21896 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 21896 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
21897 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 21897 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
21898 length).IsEmpty()); | 21898 length).IsEmpty()); |
21899 CHECK(!try_catch.HasCaught()); | 21899 CHECK(!try_catch.HasCaught()); |
21900 } | 21900 } |
21901 free(buffer); | 21901 free(buffer); |
21902 } | 21902 } |
| 21903 |
| 21904 |
| 21905 TEST(SealHandleScope) { |
| 21906 v8::Isolate* isolate = CcTest::isolate(); |
| 21907 v8::HandleScope handle_scope(isolate); |
| 21908 LocalContext env; |
| 21909 |
| 21910 v8::SealHandleScope seal(isolate); |
| 21911 |
| 21912 // Should fail |
| 21913 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
| 21914 |
| 21915 USE(obj); |
| 21916 } |
| 21917 |
| 21918 |
| 21919 TEST(SealHandleScopeNested) { |
| 21920 v8::Isolate* isolate = CcTest::isolate(); |
| 21921 v8::HandleScope handle_scope(isolate); |
| 21922 LocalContext env; |
| 21923 |
| 21924 v8::SealHandleScope seal(isolate); |
| 21925 |
| 21926 { |
| 21927 v8::HandleScope handle_scope(isolate); |
| 21928 |
| 21929 // Should work |
| 21930 v8::Local<v8::Object> obj = v8::Object::New(isolate); |
| 21931 |
| 21932 USE(obj); |
| 21933 } |
| 21934 } |
OLD | NEW |