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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptStreamerTest.cpp

Issue 2020153002: Move ScriptResourceClient to Oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onheap-font-resource-client
Patch Set: Created 4 years, 6 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 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 "bindings/core/v8/ScriptStreamer.h" 6 #include "bindings/core/v8/ScriptStreamer.h"
7 7
8 #include "bindings/core/v8/ScriptSourceCode.h" 8 #include "bindings/core/v8/ScriptSourceCode.h"
9 #include "bindings/core/v8/ScriptStreamerThread.h" 9 #include "bindings/core/v8/ScriptStreamerThread.h"
10 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 V8TestingScope m_scope; 91 V8TestingScope m_scope;
92 OwnPtr<Settings> m_settings; 92 OwnPtr<Settings> m_settings;
93 // The Resource and PendingScript where we stream from. These don't really 93 // The Resource and PendingScript where we stream from. These don't really
94 // fetch any data outside the test; the test controls the data by calling 94 // fetch any data outside the test; the test controls the data by calling
95 // ScriptResource::appendData. 95 // ScriptResource::appendData.
96 ResourceRequest m_resourceRequest; 96 ResourceRequest m_resourceRequest;
97 Persistent<ScriptResource> m_resource; 97 Persistent<ScriptResource> m_resource;
98 Persistent<PendingScript> m_pendingScript; 98 Persistent<PendingScript> m_pendingScript;
99 }; 99 };
100 100
101 class TestScriptResourceClient : public ScriptResourceClient { 101 class TestScriptResourceClient : public GarbageCollectedFinalized<TestScriptReso urceClient>, public ScriptResourceClient {
102 USING_GARBAGE_COLLECTED_MIXIN(TestScriptResourceClient);
102 public: 103 public:
103 TestScriptResourceClient() 104 TestScriptResourceClient()
104 : m_finished(false) { } 105 : m_finished(false) { }
105 106
106 void notifyFinished(Resource*) override { m_finished = true; } 107 void notifyFinished(Resource*) override { m_finished = true; }
107 String debugName() const override { return "TestScriptResourceClient"; } 108 String debugName() const override { return "TestScriptResourceClient"; }
108 109
109 bool finished() const { return m_finished; } 110 bool finished() const { return m_finished; }
110 111
111 private: 112 private:
112 bool m_finished; 113 bool m_finished;
113 }; 114 };
114 115
115 #if OS(MACOSX) && defined(ADDRESS_SANITIZER) 116 #if OS(MACOSX) && defined(ADDRESS_SANITIZER)
116 // TODO(marja): Fix this test, http://crbug.com/572987 117 // TODO(marja): Fix this test, http://crbug.com/572987
117 #define MAYBE_CompilingStreamedScript DISABLED_CompilingStreamedScript 118 #define MAYBE_CompilingStreamedScript DISABLED_CompilingStreamedScript
118 #else 119 #else
119 #define MAYBE_CompilingStreamedScript CompilingStreamedScript 120 #define MAYBE_CompilingStreamedScript CompilingStreamedScript
120 #endif 121 #endif
121 TEST_F(ScriptStreamingTest, MAYBE_CompilingStreamedScript) 122 TEST_F(ScriptStreamingTest, MAYBE_CompilingStreamedScript)
122 { 123 {
123 // Test that we can successfully compile a streamed script. 124 // Test that we can successfully compile a streamed script.
124 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 125 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
125 TestScriptResourceClient client; 126 TestScriptResourceClient* client = new TestScriptResourceClient;
126 getPendingScript()->watchForLoad(&client); 127 getPendingScript()->watchForLoad(client);
127 128
128 appendData("function foo() {"); 129 appendData("function foo() {");
129 appendPadding(); 130 appendPadding();
130 appendData("return 5; }"); 131 appendData("return 5; }");
131 appendPadding(); 132 appendPadding();
132 appendData("foo();"); 133 appendData("foo();");
133 EXPECT_FALSE(client.finished()); 134 EXPECT_FALSE(client->finished());
134 finish(); 135 finish();
135 136
136 // Process tasks on the main thread until the streaming background thread 137 // Process tasks on the main thread until the streaming background thread
137 // has completed its tasks. 138 // has completed its tasks.
138 processTasksUntilStreamingComplete(); 139 processTasksUntilStreamingComplete();
139 EXPECT_TRUE(client.finished()); 140 EXPECT_TRUE(client->finished());
140 bool errorOccurred = false; 141 bool errorOccurred = false;
141 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 142 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
142 EXPECT_FALSE(errorOccurred); 143 EXPECT_FALSE(errorOccurred);
143 EXPECT_TRUE(sourceCode.streamer()); 144 EXPECT_TRUE(sourceCode.streamer());
144 v8::TryCatch tryCatch(isolate()); 145 v8::TryCatch tryCatch(isolate());
145 v8::Local<v8::Script> script; 146 v8::Local<v8::Script> script;
146 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript)); 147 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript));
147 EXPECT_FALSE(tryCatch.HasCaught()); 148 EXPECT_FALSE(tryCatch.HasCaught());
148 } 149 }
149 150
150 TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError) 151 TEST_F(ScriptStreamingTest, CompilingStreamedScriptWithParseError)
151 { 152 {
152 // Test that scripts with parse errors are handled properly. In those cases, 153 // Test that scripts with parse errors are handled properly. In those cases,
153 // the V8 side typically finished before loading finishes: make sure we 154 // the V8 side typically finished before loading finishes: make sure we
154 // handle it gracefully. 155 // handle it gracefully.
155 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 156 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
156 TestScriptResourceClient client; 157 TestScriptResourceClient* client = new TestScriptResourceClient;
157 getPendingScript()->watchForLoad(&client); 158 getPendingScript()->watchForLoad(client);
158 appendData("function foo() {"); 159 appendData("function foo() {");
159 appendData("this is the part which will be a parse error"); 160 appendData("this is the part which will be a parse error");
160 // V8 won't realize the parse error until it actually starts parsing the 161 // V8 won't realize the parse error until it actually starts parsing the
161 // script, and this happens only when its buffer is filled. 162 // script, and this happens only when its buffer is filled.
162 appendPadding(); 163 appendPadding();
163 164
164 EXPECT_FALSE(client.finished()); 165 EXPECT_FALSE(client->finished());
165 166
166 // Force the V8 side to finish before the loading. 167 // Force the V8 side to finish before the loading.
167 processTasksUntilStreamingComplete(); 168 processTasksUntilStreamingComplete();
168 EXPECT_FALSE(client.finished()); 169 EXPECT_FALSE(client->finished());
169 170
170 finish(); 171 finish();
171 EXPECT_TRUE(client.finished()); 172 EXPECT_TRUE(client->finished());
172 173
173 bool errorOccurred = false; 174 bool errorOccurred = false;
174 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 175 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
175 EXPECT_FALSE(errorOccurred); 176 EXPECT_FALSE(errorOccurred);
176 EXPECT_TRUE(sourceCode.streamer()); 177 EXPECT_TRUE(sourceCode.streamer());
177 v8::TryCatch tryCatch(isolate()); 178 v8::TryCatch tryCatch(isolate());
178 v8::Local<v8::Script> script; 179 v8::Local<v8::Script> script;
179 EXPECT_FALSE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&s cript)); 180 EXPECT_FALSE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&s cript));
180 EXPECT_TRUE(tryCatch.HasCaught()); 181 EXPECT_TRUE(tryCatch.HasCaught());
181 } 182 }
182 183
183 TEST_F(ScriptStreamingTest, CancellingStreaming) 184 TEST_F(ScriptStreamingTest, CancellingStreaming)
184 { 185 {
185 // Test that the upper layers (PendingScript and up) can be ramped down 186 // Test that the upper layers (PendingScript and up) can be ramped down
186 // while streaming is ongoing, and ScriptStreamer handles it gracefully. 187 // while streaming is ongoing, and ScriptStreamer handles it gracefully.
187 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 188 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
188 TestScriptResourceClient client; 189 TestScriptResourceClient* client = new TestScriptResourceClient;
189 getPendingScript()->watchForLoad(&client); 190 getPendingScript()->watchForLoad(client);
190 appendData("function foo() {"); 191 appendData("function foo() {");
191 192
192 // In general, we cannot control what the background thread is doing 193 // In general, we cannot control what the background thread is doing
193 // (whether it's parsing or waiting for more data). In this test, we have 194 // (whether it's parsing or waiting for more data). In this test, we have
194 // given it so little data that it's surely waiting for more. 195 // given it so little data that it's surely waiting for more.
195 196
196 // Simulate cancelling the network load (e.g., because the user navigated 197 // Simulate cancelling the network load (e.g., because the user navigated
197 // away). 198 // away).
198 EXPECT_FALSE(client.finished()); 199 EXPECT_FALSE(client->finished());
199 getPendingScript()->stopWatchingForLoad(); 200 getPendingScript()->stopWatchingForLoad();
200 getPendingScript()->releaseElementAndClear(); 201 getPendingScript()->releaseElementAndClear();
201 m_pendingScript = nullptr; // This will destroy m_resource. 202 m_pendingScript = nullptr; // This will destroy m_resource.
202 m_resource = nullptr; 203 m_resource = nullptr;
203 204
204 // The V8 side will complete too. This should not crash. We don't receive 205 // The V8 side will complete too. This should not crash. We don't receive
205 // any results from the streaming and the client doesn't get notified. 206 // any results from the streaming and the client doesn't get notified.
206 processTasksUntilStreamingComplete(); 207 processTasksUntilStreamingComplete();
207 EXPECT_FALSE(client.finished()); 208 EXPECT_FALSE(client->finished());
208 } 209 }
209 210
210 TEST_F(ScriptStreamingTest, SuppressingStreaming) 211 TEST_F(ScriptStreamingTest, SuppressingStreaming)
211 { 212 {
212 // If we notice during streaming that there is a code cache, streaming 213 // If we notice during streaming that there is a code cache, streaming
213 // is suppressed (V8 doesn't parse while the script is loading), and the 214 // is suppressed (V8 doesn't parse while the script is loading), and the
214 // upper layer (ScriptResourceClient) should get a notification when the 215 // upper layer (ScriptResourceClient) should get a notification when the
215 // script is loaded. 216 // script is loaded.
216 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 217 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
217 TestScriptResourceClient client; 218 TestScriptResourceClient* client = new TestScriptResourceClient;
218 getPendingScript()->watchForLoad(&client); 219 getPendingScript()->watchForLoad(client);
219 appendData("function foo() {"); 220 appendData("function foo() {");
220 appendPadding(); 221 appendPadding();
221 222
222 CachedMetadataHandler* cacheHandler = m_resource->cacheHandler(); 223 CachedMetadataHandler* cacheHandler = m_resource->cacheHandler();
223 EXPECT_TRUE(cacheHandler); 224 EXPECT_TRUE(cacheHandler);
224 cacheHandler->setCachedMetadata(V8ScriptRunner::tagForCodeCache(cacheHandler ), "X", 1, CachedMetadataHandler::CacheLocally); 225 cacheHandler->setCachedMetadata(V8ScriptRunner::tagForCodeCache(cacheHandler ), "X", 1, CachedMetadataHandler::CacheLocally);
225 226
226 appendPadding(); 227 appendPadding();
227 finish(); 228 finish();
228 processTasksUntilStreamingComplete(); 229 processTasksUntilStreamingComplete();
229 EXPECT_TRUE(client.finished()); 230 EXPECT_TRUE(client->finished());
230 231
231 bool errorOccurred = false; 232 bool errorOccurred = false;
232 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 233 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
233 EXPECT_FALSE(errorOccurred); 234 EXPECT_FALSE(errorOccurred);
234 // ScriptSourceCode doesn't refer to the streamer, since we have suppressed 235 // ScriptSourceCode doesn't refer to the streamer, since we have suppressed
235 // the streaming and resumed the non-streaming code path for script 236 // the streaming and resumed the non-streaming code path for script
236 // compilation. 237 // compilation.
237 EXPECT_FALSE(sourceCode.streamer()); 238 EXPECT_FALSE(sourceCode.streamer());
238 } 239 }
239 240
240 TEST_F(ScriptStreamingTest, EmptyScripts) 241 TEST_F(ScriptStreamingTest, EmptyScripts)
241 { 242 {
242 // Empty scripts should also be streamed properly, that is, the upper layer 243 // Empty scripts should also be streamed properly, that is, the upper layer
243 // (ScriptResourceClient) should be notified when an empty script has been 244 // (ScriptResourceClient) should be notified when an empty script has been
244 // loaded. 245 // loaded.
245 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 246 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
246 TestScriptResourceClient client; 247 TestScriptResourceClient* client = new TestScriptResourceClient;
247 getPendingScript()->watchForLoad(&client); 248 getPendingScript()->watchForLoad(client);
248 249
249 // Finish the script without sending any data. 250 // Finish the script without sending any data.
250 finish(); 251 finish();
251 // The finished notification should arrive immediately and not be cycled 252 // The finished notification should arrive immediately and not be cycled
252 // through a background thread. 253 // through a background thread.
253 EXPECT_TRUE(client.finished()); 254 EXPECT_TRUE(client->finished());
254 255
255 bool errorOccurred = false; 256 bool errorOccurred = false;
256 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 257 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
257 EXPECT_FALSE(errorOccurred); 258 EXPECT_FALSE(errorOccurred);
258 EXPECT_FALSE(sourceCode.streamer()); 259 EXPECT_FALSE(sourceCode.streamer());
259 } 260 }
260 261
261 TEST_F(ScriptStreamingTest, SmallScripts) 262 TEST_F(ScriptStreamingTest, SmallScripts)
262 { 263 {
263 // Small scripts shouldn't be streamed. 264 // Small scripts shouldn't be streamed.
264 ScriptStreamer::setSmallScriptThresholdForTesting(100); 265 ScriptStreamer::setSmallScriptThresholdForTesting(100);
265 266
266 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 267 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
267 TestScriptResourceClient client; 268 TestScriptResourceClient* client = new TestScriptResourceClient;
268 getPendingScript()->watchForLoad(&client); 269 getPendingScript()->watchForLoad(client);
269 270
270 appendData("function foo() { }"); 271 appendData("function foo() { }");
271 272
272 finish(); 273 finish();
273 274
274 // The finished notification should arrive immediately and not be cycled 275 // The finished notification should arrive immediately and not be cycled
275 // through a background thread. 276 // through a background thread.
276 EXPECT_TRUE(client.finished()); 277 EXPECT_TRUE(client->finished());
277 278
278 bool errorOccurred = false; 279 bool errorOccurred = false;
279 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 280 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
280 EXPECT_FALSE(errorOccurred); 281 EXPECT_FALSE(errorOccurred);
281 EXPECT_FALSE(sourceCode.streamer()); 282 EXPECT_FALSE(sourceCode.streamer());
282 } 283 }
283 284
284 #if OS(MACOSX) && defined(ADDRESS_SANITIZER) 285 #if OS(MACOSX) && defined(ADDRESS_SANITIZER)
285 // TODO(marja): Fix this test, http://crbug.com/572987 286 // TODO(marja): Fix this test, http://crbug.com/572987
286 #define MAYBE_ScriptsWithSmallFirstChunk DISABLED_ScriptsWithSmallFirstChunk 287 #define MAYBE_ScriptsWithSmallFirstChunk DISABLED_ScriptsWithSmallFirstChunk
287 #else 288 #else
288 #define MAYBE_ScriptsWithSmallFirstChunk ScriptsWithSmallFirstChunk 289 #define MAYBE_ScriptsWithSmallFirstChunk ScriptsWithSmallFirstChunk
289 #endif 290 #endif
290 TEST_F(ScriptStreamingTest, MAYBE_ScriptsWithSmallFirstChunk) 291 TEST_F(ScriptStreamingTest, MAYBE_ScriptsWithSmallFirstChunk)
291 { 292 {
292 // If a script is long enough, if should be streamed, even if the first data 293 // If a script is long enough, if should be streamed, even if the first data
293 // chunk is small. 294 // chunk is small.
294 ScriptStreamer::setSmallScriptThresholdForTesting(100); 295 ScriptStreamer::setSmallScriptThresholdForTesting(100);
295 296
296 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 297 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
297 TestScriptResourceClient client; 298 TestScriptResourceClient* client = new TestScriptResourceClient;
298 getPendingScript()->watchForLoad(&client); 299 getPendingScript()->watchForLoad(client);
299 300
300 // This is the first data chunk which is small. 301 // This is the first data chunk which is small.
301 appendData("function foo() { }"); 302 appendData("function foo() { }");
302 appendPadding(); 303 appendPadding();
303 appendPadding(); 304 appendPadding();
304 appendPadding(); 305 appendPadding();
305 306
306 finish(); 307 finish();
307 308
308 processTasksUntilStreamingComplete(); 309 processTasksUntilStreamingComplete();
309 EXPECT_TRUE(client.finished()); 310 EXPECT_TRUE(client->finished());
310 bool errorOccurred = false; 311 bool errorOccurred = false;
311 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 312 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
312 EXPECT_FALSE(errorOccurred); 313 EXPECT_FALSE(errorOccurred);
313 EXPECT_TRUE(sourceCode.streamer()); 314 EXPECT_TRUE(sourceCode.streamer());
314 v8::TryCatch tryCatch(isolate()); 315 v8::TryCatch tryCatch(isolate());
315 v8::Local<v8::Script> script; 316 v8::Local<v8::Script> script;
316 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript)); 317 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript));
317 EXPECT_FALSE(tryCatch.HasCaught()); 318 EXPECT_FALSE(tryCatch.HasCaught());
318 } 319 }
319 320
320 #if OS(MACOSX) && defined(ADDRESS_SANITIZER) 321 #if OS(MACOSX) && defined(ADDRESS_SANITIZER)
321 // TODO(marja): Fix this test, http://crbug.com/572987 322 // TODO(marja): Fix this test, http://crbug.com/572987
322 #define MAYBE_EncodingChanges DISABLED_EncodingChanges 323 #define MAYBE_EncodingChanges DISABLED_EncodingChanges
323 #else 324 #else
324 #define MAYBE_EncodingChanges EncodingChanges 325 #define MAYBE_EncodingChanges EncodingChanges
325 #endif 326 #endif
326 TEST_F(ScriptStreamingTest, MAYBE_EncodingChanges) 327 TEST_F(ScriptStreamingTest, MAYBE_EncodingChanges)
327 { 328 {
328 // It's possible that the encoding of the Resource changes after we start 329 // It's possible that the encoding of the Resource changes after we start
329 // loading it. 330 // loading it.
330 m_resource->setEncoding("windows-1252"); 331 m_resource->setEncoding("windows-1252");
331 332
332 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 333 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
333 TestScriptResourceClient client; 334 TestScriptResourceClient* client = new TestScriptResourceClient;
334 getPendingScript()->watchForLoad(&client); 335 getPendingScript()->watchForLoad(client);
335 336
336 m_resource->setEncoding("UTF-8"); 337 m_resource->setEncoding("UTF-8");
337 // \xec\x92\x81 are the raw bytes for \uc481. 338 // \xec\x92\x81 are the raw bytes for \uc481.
338 appendData("function foo() { var foob\xec\x92\x81r = 13; return foob\xec\x92 \x81r; } foo();"); 339 appendData("function foo() { var foob\xec\x92\x81r = 13; return foob\xec\x92 \x81r; } foo();");
339 340
340 finish(); 341 finish();
341 342
342 processTasksUntilStreamingComplete(); 343 processTasksUntilStreamingComplete();
343 EXPECT_TRUE(client.finished()); 344 EXPECT_TRUE(client->finished());
344 bool errorOccurred = false; 345 bool errorOccurred = false;
345 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 346 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
346 EXPECT_FALSE(errorOccurred); 347 EXPECT_FALSE(errorOccurred);
347 EXPECT_TRUE(sourceCode.streamer()); 348 EXPECT_TRUE(sourceCode.streamer());
348 v8::TryCatch tryCatch(isolate()); 349 v8::TryCatch tryCatch(isolate());
349 v8::Local<v8::Script> script; 350 v8::Local<v8::Script> script;
350 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript)); 351 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript));
351 EXPECT_FALSE(tryCatch.HasCaught()); 352 EXPECT_FALSE(tryCatch.HasCaught());
352 } 353 }
353 354
354 355
355 #if OS(MACOSX) && defined(ADDRESS_SANITIZER) 356 #if OS(MACOSX) && defined(ADDRESS_SANITIZER)
356 // TODO(marja): Fix this test, http://crbug.com/572987 357 // TODO(marja): Fix this test, http://crbug.com/572987
357 #define MAYBE_EncodingFromBOM DISABLED_EncodingFromBOM 358 #define MAYBE_EncodingFromBOM DISABLED_EncodingFromBOM
358 #else 359 #else
359 #define MAYBE_EncodingFromBOM EncodingFromBOM 360 #define MAYBE_EncodingFromBOM EncodingFromBOM
360 #endif 361 #endif
361 TEST_F(ScriptStreamingTest, MAYBE_EncodingFromBOM) 362 TEST_F(ScriptStreamingTest, MAYBE_EncodingFromBOM)
362 { 363 {
363 // Byte order marks should be removed before giving the data to V8. They 364 // Byte order marks should be removed before giving the data to V8. They
364 // will also affect encoding detection. 365 // will also affect encoding detection.
365 m_resource->setEncoding("windows-1252"); // This encoding is wrong on purpos e. 366 m_resource->setEncoding("windows-1252"); // This encoding is wrong on purpos e.
366 367
367 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner); 368 ScriptStreamer::startStreaming(getPendingScript(), ScriptStreamer::ParsingBl ocking, m_settings.get(), m_scope.getScriptState(), m_loadingTaskRunner);
368 TestScriptResourceClient client; 369 TestScriptResourceClient* client = new TestScriptResourceClient;
369 getPendingScript()->watchForLoad(&client); 370 getPendingScript()->watchForLoad(client);
370 371
371 // \xef\xbb\xbf is the UTF-8 byte order mark. \xec\x92\x81 are the raw bytes 372 // \xef\xbb\xbf is the UTF-8 byte order mark. \xec\x92\x81 are the raw bytes
372 // for \uc481. 373 // for \uc481.
373 appendData("\xef\xbb\xbf function foo() { var foob\xec\x92\x81r = 13; return foob\xec\x92\x81r; } foo();"); 374 appendData("\xef\xbb\xbf function foo() { var foob\xec\x92\x81r = 13; return foob\xec\x92\x81r; } foo();");
374 375
375 finish(); 376 finish();
376 processTasksUntilStreamingComplete(); 377 processTasksUntilStreamingComplete();
377 EXPECT_TRUE(client.finished()); 378 EXPECT_TRUE(client->finished());
378 bool errorOccurred = false; 379 bool errorOccurred = false;
379 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred); 380 ScriptSourceCode sourceCode = getPendingScript()->getSource(KURL(), errorOcc urred);
380 EXPECT_FALSE(errorOccurred); 381 EXPECT_FALSE(errorOccurred);
381 EXPECT_TRUE(sourceCode.streamer()); 382 EXPECT_TRUE(sourceCode.streamer());
382 v8::TryCatch tryCatch(isolate()); 383 v8::TryCatch tryCatch(isolate());
383 v8::Local<v8::Script> script; 384 v8::Local<v8::Script> script;
384 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript)); 385 EXPECT_TRUE(V8ScriptRunner::compileScript(sourceCode, isolate()).ToLocal(&sc ript));
385 EXPECT_FALSE(tryCatch.HasCaught()); 386 EXPECT_FALSE(tryCatch.HasCaught());
386 } 387 }
387 388
388 } // namespace 389 } // namespace
389 390
390 } // namespace blink 391 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/PendingScript.h » ('j') | third_party/WebKit/Source/core/dom/PendingScript.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698