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

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

Issue 1801203002: Parser: Make skipping HTML comments optional. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 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/parsing/scanner.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index dab80d7c33cbd5259ab28b43ec9cd7633bb88737..2c02ceb916bba89275a758500a853379feaaa2aa 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -24858,3 +24858,40 @@ TEST(Proxy) {
CHECK(proxy->GetTarget()->SameValue(target));
CHECK(proxy->GetHandler()->IsNull());
}
+
+TEST(HTMLCommentInJavascript) {
+ // Regression test for crbug.com/573887.
+ LocalContext context;
+ v8::HandleScope scope(CcTest::isolate());
+
+ // Inline scripts - i.e. the contents of <script> tags - need to obey HTML
+ // comments, but JS sources - i.e., everything else - shouldn't.
+ const char* source = "<!--\n var result = 2 + 2;\n-->\n result";
+
+ v8::ScriptOrigin inline_script(v8_str(""));
+
+ v8::ScriptOrigin source_script(
+ v8_str("http://some-resource.net/"), Local<v8::Integer>(),
+ Local<v8::Integer>(), Local<Boolean>(), Local<v8::Integer>(),
+ Local<Boolean>(), Local<Value>(), Local<Boolean>(),
+ v8::False(CcTest::isolate()));
+
+ // Case 1: An inline script.
+ {
+ v8::MaybeLocal<v8::Script> script =
+ v8::Script::Compile(context.local(), v8_str(source), &inline_script);
+ CHECK(!script.IsEmpty());
+ CHECK_EQ(4, script.ToLocalChecked()
+ ->Run(context.local())
+ .ToLocalChecked()
+ ->Int32Value(context.local())
+ .FromJust());
+ }
+
+ // Case 2: Js source file.
+ {
+ v8::MaybeLocal<v8::Script> script =
+ v8::Script::Compile(context.local(), v8_str(source), &source_script);
+ CHECK(script.IsEmpty());
+ }
+}
« no previous file with comments | « src/parsing/scanner.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698