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

Unified Diff: Source/bindings/core/v8/ScriptStreamerTest.cpp

Issue 700543002: Script streaming: detect encoding later. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review (haraken@) (more) Created 6 years, 1 month 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 | « Source/bindings/core/v8/ScriptStreamer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/ScriptStreamerTest.cpp
diff --git a/Source/bindings/core/v8/ScriptStreamerTest.cpp b/Source/bindings/core/v8/ScriptStreamerTest.cpp
index 3f7f9157f4c918b850c506ad6a2201d5b957022f..90a00444a712b816e33efb9bc801ad1ad52c45b4 100644
--- a/Source/bindings/core/v8/ScriptStreamerTest.cpp
+++ b/Source/bindings/core/v8/ScriptStreamerTest.cpp
@@ -336,6 +336,34 @@ TEST_P(ScriptStreamingTest, ScriptsWithSmallFirstChunk)
EXPECT_FALSE(tryCatch.HasCaught());
}
+TEST_P(ScriptStreamingTest, EncodingChanges)
+{
+ // It's possible that the encoding of the Resource changes after we start
+ // loading it.
+ m_resource->setEncoding("windows-1252");
+
+ ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState(), PendingScript::ParsingBlocking);
+ TestScriptResourceClient client;
+ pendingScript().watchForLoad(&client);
+
+ m_resource->setEncoding("UTF-8");
+ // \xec\x92\x81 are the raw bytes for \uc481.
+ appendData("function foo() { var foob\xec\x92\x81r = 13; return foob\xec\x92\x81r; } foo();");
+
+ finish();
+
+ processTasksUntilStreamingComplete();
+ EXPECT_TRUE(client.finished());
+ bool errorOccurred = false;
+ ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurred);
+ EXPECT_FALSE(errorOccurred);
+ EXPECT_TRUE(sourceCode.streamer());
+ v8::TryCatch tryCatch;
+ v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(sourceCode, isolate());
+ EXPECT_FALSE(script.IsEmpty());
+ EXPECT_FALSE(tryCatch.HasCaught());
+}
+
INSTANTIATE_TEST_CASE_P(ScriptStreamingInstantiation, ScriptStreamingTest, ::testing::Values(false, true));
} // namespace
« no previous file with comments | « Source/bindings/core/v8/ScriptStreamer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698