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

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

Issue 1995323002: Revert of Refactor script position calculation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@20160517_refactor_position_info
Patch Set: Created 4 years, 7 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 | « test/cctest/test-api.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 3b4f79a9ad05313e3e4de98525edc6981de46e60..440c6f15c490254016b5789fda65c6b508ceb19a 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -6081,48 +6081,53 @@
::v8::internal::EmbeddedVector<uint16_t, 1> empty_;
};
-TEST(DebugScriptLineEndsAreAscending) {
- DebugLocalContext env;
- v8::Isolate* isolate = env->GetIsolate();
- v8::HandleScope scope(isolate);
+
+TEST(DebugGetLoadedScripts) {
+ DebugLocalContext env;
+ v8::HandleScope scope(env->GetIsolate());
env.ExposeDebug();
- // Compile a test script.
- v8::Local<v8::String> script = v8_str(isolate,
- "function f() {\n"
- " debugger;\n"
- "}\n");
-
- v8::ScriptOrigin origin1 = v8::ScriptOrigin(v8_str(isolate, "name"));
- v8::Local<v8::Script> script1 =
- v8::Script::Compile(env.context(), script, &origin1).ToLocalChecked();
- USE(script1);
-
- Handle<v8::internal::FixedArray> instances;
- {
- v8::internal::Debug* debug = CcTest::i_isolate()->debug();
- v8::internal::DebugScope debug_scope(debug);
- CHECK(!debug_scope.failed());
- instances = debug->GetLoadedScripts();
- }
-
- CHECK_GT(instances->length(), 0);
- for (int i = 0; i < instances->length(); i++) {
- Handle<v8::internal::Script> script = Handle<v8::internal::Script>(
- v8::internal::Script::cast(instances->get(i)));
-
- v8::internal::Script::InitLineEnds(script);
- v8::internal::FixedArray* ends =
- v8::internal::FixedArray::cast(script->line_ends());
- CHECK_GT(ends->length(), 0);
-
- int prev_end = -1;
- for (int j = 0; j < ends->length(); j++) {
- const int curr_end = v8::internal::Smi::cast(ends->get(j))->value();
- CHECK_GT(curr_end, prev_end);
- prev_end = curr_end;
- }
- }
+ v8::Local<v8::Context> context = env.context();
+ EmptyExternalStringResource source_ext_str;
+ v8::Local<v8::String> source =
+ v8::String::NewExternalTwoByte(env->GetIsolate(), &source_ext_str)
+ .ToLocalChecked();
+ CHECK(v8::Script::Compile(context, source).IsEmpty());
+ 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;
+ EnableDebugger(env->GetIsolate());
+ v8::MaybeLocal<v8::Value> result =
+ CompileRun(env.context(),
+ "var scripts = %DebugGetLoadedScripts();"
+ "var count = scripts.length;"
+ "for (var i = 0; i < count; ++i) {"
+ " var lines = scripts[i].lineCount();"
+ " if (lines < 1) throw 'lineCount';"
+ " var last = -1;"
+ " for (var j = 0; j < lines; ++j) {"
+ " var end = scripts[i].lineEnd(j);"
+ " if (last >= end) throw 'lineEnd';"
+ " last = end;"
+ " }"
+ "}");
+ CHECK(!result.IsEmpty());
+ DisableDebugger(env->GetIsolate());
+ // Must not crash while accessing line_ends.
+ i::FLAG_allow_natives_syntax = allow_natives_syntax;
+
+ // Some scripts are retrieved - at least the number of native scripts.
+ CHECK_GT(env->Global()
+ ->Get(context, v8_str(env->GetIsolate(), "count"))
+ .ToLocalChecked()
+ ->Int32Value(context)
+ .FromJust(),
+ 8);
}
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698