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

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp

Issue 1743763004: Use v8::MicrotasksScope internally in V8RecursionScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8rs-2-endofscope
Patch Set: v8_helpers 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 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 #include "modules/cachestorage/Cache.h" 5 #include "modules/cachestorage/Cache.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptFunction.h" 8 #include "bindings/core/v8/ScriptFunction.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 Request* request = Request::create(getScriptState(), url, exceptionState ); 242 Request* request = Request::create(getScriptState(), url, exceptionState );
243 EXPECT_FALSE(exceptionState.hadException()); 243 EXPECT_FALSE(exceptionState.hadException());
244 return exceptionState.hadException() ? 0 : request; 244 return exceptionState.hadException() ? 0 : request;
245 } 245 }
246 246
247 // Convenience methods for testing the returned promises. 247 // Convenience methods for testing the returned promises.
248 ScriptValue getRejectValue(ScriptPromise& promise) 248 ScriptValue getRejectValue(ScriptPromise& promise)
249 { 249 {
250 ScriptValue onReject; 250 ScriptValue onReject;
251 promise.then(UnreachableFunction::create(getScriptState()), TestFunction ::create(getScriptState(), &onReject)); 251 promise.then(UnreachableFunction::create(getScriptState()), TestFunction ::create(getScriptState(), &onReject));
252 isolate()->RunMicrotasks(); 252 v8::MicrotasksScope::PerformCheckpoint(isolate());
253 return onReject; 253 return onReject;
254 } 254 }
255 255
256 std::string getRejectString(ScriptPromise& promise) 256 std::string getRejectString(ScriptPromise& promise)
257 { 257 {
258 ScriptValue onReject = getRejectValue(promise); 258 ScriptValue onReject = getRejectValue(promise);
259 return toCoreString(onReject.v8Value()->ToString(context()).ToLocalCheck ed()).ascii().data(); 259 return toCoreString(onReject.v8Value()->ToString(context()).ToLocalCheck ed()).ascii().data();
260 } 260 }
261 261
262 ScriptValue getResolveValue(ScriptPromise& promise) 262 ScriptValue getResolveValue(ScriptPromise& promise)
263 { 263 {
264 ScriptValue onResolve; 264 ScriptValue onResolve;
265 promise.then(TestFunction::create(getScriptState(), &onResolve), Unreach ableFunction::create(getScriptState())); 265 promise.then(TestFunction::create(getScriptState(), &onResolve), Unreach ableFunction::create(getScriptState()));
266 isolate()->RunMicrotasks(); 266 v8::MicrotasksScope::PerformCheckpoint(isolate());
267 return onResolve; 267 return onResolve;
268 } 268 }
269 269
270 std::string getResolveString(ScriptPromise& promise) 270 std::string getResolveString(ScriptPromise& promise)
271 { 271 {
272 ScriptValue onResolve = getResolveValue(promise); 272 ScriptValue onResolve = getResolveValue(promise);
273 return toCoreString(onResolve.v8Value()->ToString(context()).ToLocalChec ked()).ascii().data(); 273 return toCoreString(onResolve.v8Value()->ToString(context()).ToLocalChec ked()).ascii().data();
274 } 274 }
275 275
276 ExceptionState& exceptionState() 276 ExceptionState& exceptionState()
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo( request), exceptionState()); 657 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo( request), exceptionState());
658 658
659 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 659 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
660 EXPECT_EQ(1, fetcher->fetchCount()); 660 EXPECT_EQ(1, fetcher->fetchCount());
661 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed()); 661 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed());
662 } 662 }
663 663
664 } // namespace 664 } // namespace
665 } // namespace blink 665 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698