| Index: Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| diff --git a/Source/bindings/core/v8/ScriptStreamerTest.cpp b/Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| index 90a00444a712b816e33efb9bc801ad1ad52c45b4..f3ae67a46ed29ff480a80cd1c140d832be797b7f 100644
|
| --- a/Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| +++ b/Source/bindings/core/v8/ScriptStreamerTest.cpp
|
| @@ -86,11 +86,11 @@ protected:
|
| void appendData(const char* data)
|
| {
|
| m_resource->appendData(data, strlen(data));
|
| - // Yield control to the background thread, so that V8 gets a change to
|
| + // Yield control to the background thread, so that V8 gets a chance to
|
| // process the data before the main thread adds more. Note that we
|
| // cannot fully control in what kind of chunks the data is passed to V8
|
| - // (if the V8 is not requesting more data between two appendData calls,
|
| - // V8 will get both chunks together).
|
| + // (if V8 is not requesting more data between two appendData calls, it
|
| + // will get both chunks together).
|
| Platform::current()->yieldCurrentThread();
|
| }
|
|
|
| @@ -364,6 +364,34 @@ TEST_P(ScriptStreamingTest, EncodingChanges)
|
| EXPECT_FALSE(tryCatch.HasCaught());
|
| }
|
|
|
| +
|
| +TEST_P(ScriptStreamingTest, EncodingFromBOM)
|
| +{
|
| + // Byte order marks should be removed before giving the data to V8. They
|
| + // will also affect encoding detection.
|
| + m_resource->setEncoding("windows-1252"); // This encoding is wrong on purpose.
|
| +
|
| + ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.scriptState(), PendingScript::ParsingBlocking);
|
| + TestScriptResourceClient client;
|
| + pendingScript().watchForLoad(&client);
|
| +
|
| + // \xef\xbb\xbf is the UTF-8 byte order mark. \xec\x92\x81 are the raw bytes
|
| + // for \uc481.
|
| + appendData("\xef\xbb\xbf 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
|
|
|