Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: test/cctest/test-debug.cc

Issue 56002: Fix issue 289: check external source strings validity in Runtime_DebugGetLoadedScripts (Closed)
Patch Set: Added a comment as Soren suggests Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 30a086a3a787ccb4641c30ca363d99eea1e77107..f21a878aa1d6940cf5951dd419aac7db348bde13 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -3980,3 +3980,42 @@ TEST(DebuggerAgentProtocolOverflowHeader) {
delete client;
delete server;
}
+
+
+// Test for issue http://code.google.com/p/v8/issues/detail?id=289.
+// Make sure that DebugGetLoadedScripts doesn't return scripts
+// with disposed external source.
+class EmptyExternalStringResource : public v8::String::ExternalStringResource {
+ public:
+ EmptyExternalStringResource() { empty_[0] = 0; }
+ virtual ~EmptyExternalStringResource() {};
+ virtual size_t length() const { return empty_.length(); }
+ virtual const uint16_t* data() const { return empty_.start(); }
+ private:
+ ::v8::internal::EmbeddedVector<uint16_t,1> empty_;
+};
+
+
+TEST(DebugGetLoadedScripts) {
+ v8::HandleScope scope;
+ DebugLocalContext env;
+ EmptyExternalStringResource source_ext_str;
+ v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str);
+ v8::Handle<v8::Script> evil_script = v8::Script::Compile(source);
+ Handle<i::ExternalTwoByteString> i_source(
+ i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)));
+ // This situation can happen if source was an external string disposed
+ // by its owner.
+ i_source->set_resource(0);
+
+ bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
+ i::FLAG_allow_natives_syntax = true;
+ CompileRun(
+ "var scripts = %DebugGetLoadedScripts();"
+ "for (var i = 0; i < scripts.length; ++i) {"
+ " scripts[i].line_ends;"
+ "}"
+ );
+ // Must not crash while accessing line_ends.
+ i::FLAG_allow_natives_syntax = allow_natives_syntax;
+}
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698