| OLD | NEW |
| 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 Loading... |
| 242 Request* request = Request::create(scriptState(), url, exceptionState); | 242 Request* request = Request::create(scriptState(), 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(scriptState()), TestFunction::c
reate(scriptState(), &onReject)); | 251 promise.then(UnreachableFunction::create(scriptState()), TestFunction::c
reate(scriptState(), &onReject)); |
| 252 v8::MicrotasksScope::PerformCheckpoint(isolate()); | 252 isolate()->RunMicrotasks(); |
| 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(scriptState(), &onResolve), Unreachabl
eFunction::create(scriptState())); | 265 promise.then(TestFunction::create(scriptState(), &onResolve), Unreachabl
eFunction::create(scriptState())); |
| 266 v8::MicrotasksScope::PerformCheckpoint(isolate()); | 266 isolate()->RunMicrotasks(); |
| 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 Loading... |
| 656 | 656 |
| 657 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req
uest), exceptionState()); | 657 ScriptPromise addResult = cache->add(scriptState(), requestToRequestInfo(req
uest), 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 |
| OLD | NEW |