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

Side by Side 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: . 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include "config.h" 6 #include "config.h"
7 #include "bindings/core/v8/ScriptStreamer.h" 7 #include "bindings/core/v8/ScriptStreamer.h"
8 8
9 #include "bindings/core/v8/ScriptSourceCode.h" 9 #include "bindings/core/v8/ScriptSourceCode.h"
10 #include "bindings/core/v8/ScriptStreamerThread.h" 10 #include "bindings/core/v8/ScriptStreamerThread.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 bool errorOccurred = false; 329 bool errorOccurred = false;
330 ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurre d); 330 ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurre d);
331 EXPECT_FALSE(errorOccurred); 331 EXPECT_FALSE(errorOccurred);
332 EXPECT_TRUE(sourceCode.streamer()); 332 EXPECT_TRUE(sourceCode.streamer());
333 v8::TryCatch tryCatch; 333 v8::TryCatch tryCatch;
334 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(sourceCode, is olate()); 334 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(sourceCode, is olate());
335 EXPECT_FALSE(script.IsEmpty()); 335 EXPECT_FALSE(script.IsEmpty());
336 EXPECT_FALSE(tryCatch.HasCaught()); 336 EXPECT_FALSE(tryCatch.HasCaught());
337 } 337 }
338 338
339 TEST_P(ScriptStreamingTest, EncodingChanges)
340 {
341 // It's possible that the encoding of the Resource changes after we start
342 // loading it.
343 m_resource->setEncoding("windows-1252");
344
345 ScriptStreamer::startStreaming(pendingScript(), m_settings.get(), m_scope.sc riptState(), PendingScript::ParsingBlocking);
346 TestScriptResourceClient client;
347 pendingScript().watchForLoad(&client);
348
349 m_resource->setEncoding("UTF-8");
350 // \xec\x92\x81 are the raw bytes for \uc481.
351 appendData("function foo() { var foob\xec\x92\x81r = 13; return foob\xec\x92 \x81r; } foo();");
352
353 finish();
354
355 processTasksUntilStreamingComplete();
356 EXPECT_TRUE(client.finished());
357 bool errorOccurred = false;
358 ScriptSourceCode sourceCode = pendingScript().getSource(KURL(), errorOccurre d);
359 EXPECT_FALSE(errorOccurred);
360 EXPECT_TRUE(sourceCode.streamer());
361 v8::TryCatch tryCatch;
362 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(sourceCode, is olate());
363 EXPECT_FALSE(script.IsEmpty());
364 EXPECT_FALSE(tryCatch.HasCaught());
365 }
366
339 INSTANTIATE_TEST_CASE_P(ScriptStreamingInstantiation, ScriptStreamingTest, ::tes ting::Values(false, true)); 367 INSTANTIATE_TEST_CASE_P(ScriptStreamingInstantiation, ScriptStreamingTest, ::tes ting::Values(false, true));
340 368
341 } // namespace 369 } // namespace
342 370
343 } // namespace blink 371 } // namespace blink
OLDNEW
« Source/bindings/core/v8/ScriptStreamer.cpp ('K') | « Source/bindings/core/v8/ScriptStreamer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698