OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 3970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3981 delete server; | 3981 delete server; |
3982 } | 3982 } |
3983 | 3983 |
3984 | 3984 |
3985 // Test for issue http://code.google.com/p/v8/issues/detail?id=289. | 3985 // Test for issue http://code.google.com/p/v8/issues/detail?id=289. |
3986 // Make sure that DebugGetLoadedScripts doesn't return scripts | 3986 // Make sure that DebugGetLoadedScripts doesn't return scripts |
3987 // with disposed external source. | 3987 // with disposed external source. |
3988 class EmptyExternalStringResource : public v8::String::ExternalStringResource { | 3988 class EmptyExternalStringResource : public v8::String::ExternalStringResource { |
3989 public: | 3989 public: |
3990 EmptyExternalStringResource() { empty_[0] = 0; } | 3990 EmptyExternalStringResource() { empty_[0] = 0; } |
3991 virtual ~EmptyExternalStringResource() {}; | 3991 virtual ~EmptyExternalStringResource() {} |
3992 virtual size_t length() const { return empty_.length(); } | 3992 virtual size_t length() const { return empty_.length(); } |
3993 virtual const uint16_t* data() const { return empty_.start(); } | 3993 virtual const uint16_t* data() const { return empty_.start(); } |
3994 private: | 3994 private: |
3995 ::v8::internal::EmbeddedVector<uint16_t,1> empty_; | 3995 ::v8::internal::EmbeddedVector<uint16_t, 1> empty_; |
3996 }; | 3996 }; |
3997 | 3997 |
3998 | 3998 |
3999 TEST(DebugGetLoadedScripts) { | 3999 TEST(DebugGetLoadedScripts) { |
4000 v8::HandleScope scope; | 4000 v8::HandleScope scope; |
4001 DebugLocalContext env; | 4001 DebugLocalContext env; |
4002 EmptyExternalStringResource source_ext_str; | 4002 EmptyExternalStringResource source_ext_str; |
4003 v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str); | 4003 v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str); |
4004 v8::Handle<v8::Script> evil_script = v8::Script::Compile(source); | 4004 v8::Handle<v8::Script> evil_script = v8::Script::Compile(source); |
4005 Handle<i::ExternalTwoByteString> i_source( | 4005 Handle<i::ExternalTwoByteString> i_source( |
4006 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); | 4006 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); |
4007 // This situation can happen if source was an external string disposed | 4007 // This situation can happen if source was an external string disposed |
4008 // by its owner. | 4008 // by its owner. |
4009 i_source->set_resource(0); | 4009 i_source->set_resource(0); |
4010 | 4010 |
4011 bool allow_natives_syntax = i::FLAG_allow_natives_syntax; | 4011 bool allow_natives_syntax = i::FLAG_allow_natives_syntax; |
4012 i::FLAG_allow_natives_syntax = true; | 4012 i::FLAG_allow_natives_syntax = true; |
4013 CompileRun( | 4013 CompileRun( |
4014 "var scripts = %DebugGetLoadedScripts();" | 4014 "var scripts = %DebugGetLoadedScripts();" |
4015 "for (var i = 0; i < scripts.length; ++i) {" | 4015 "for (var i = 0; i < scripts.length; ++i) {" |
4016 " scripts[i].line_ends;" | 4016 " scripts[i].line_ends;" |
4017 "}" | 4017 "}"); |
4018 ); | |
4019 // Must not crash while accessing line_ends. | 4018 // Must not crash while accessing line_ends. |
4020 i::FLAG_allow_natives_syntax = allow_natives_syntax; | 4019 i::FLAG_allow_natives_syntax = allow_natives_syntax; |
4021 } | 4020 } |
OLD | NEW |