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

Unified Diff: Source/modules/serviceworkers/CacheTest.cpp

Issue 694083002: Service Worker Cache: Simplify exception/rejection processing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/serviceworkers/Cache.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/CacheTest.cpp
diff --git a/Source/modules/serviceworkers/CacheTest.cpp b/Source/modules/serviceworkers/CacheTest.cpp
index cf409e80650f9d626388dd47cc6dfecc99e7ef9d..d8f98dd2144b0cfd32f585a9da63b72cb4bded9b 100644
--- a/Source/modules/serviceworkers/CacheTest.cpp
+++ b/Source/modules/serviceworkers/CacheTest.cpp
@@ -262,6 +262,8 @@ private:
TEST_F(ServiceWorkerCacheTest, Basics)
{
+ NonThrowableExceptionState exceptionState;
jsbell 2014/10/31 23:06:19 Should I make this a member of the fixture instead
jkarlin 2014/11/03 18:51:04 I'm in favor of making it a private member as it's
+
ErrorWebCacheForTests* testCache;
Cache* cache = Cache::create(testCache = new NotImplementedErrorCache());
ASSERT(cache);
@@ -269,16 +271,16 @@ TEST_F(ServiceWorkerCacheTest, Basics)
const String url = "http://www.cachetest.org/";
CacheQueryOptions options;
- ScriptPromise matchPromise = cache->match(scriptState(), url, options);
+ ScriptPromise matchPromise = cache->match(scriptState(), url, options, exceptionState);
EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise));
cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorkerCacheErrorNotFound));
- matchPromise = cache->match(scriptState(), url, options);
+ matchPromise = cache->match(scriptState(), url, options, exceptionState);
ScriptValue scriptValue = getResolveValue(matchPromise);
EXPECT_TRUE(scriptValue.isUndefined());
cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorkerCacheErrorExists));
- matchPromise = cache->match(scriptState(), url, options);
+ matchPromise = cache->match(scriptState(), url, options, exceptionState);
EXPECT_EQ("InvalidAccessError: Entry already exists.", getRejectString(matchPromise));
}
@@ -286,6 +288,8 @@ TEST_F(ServiceWorkerCacheTest, Basics)
// which are tested later.
TEST_F(ServiceWorkerCacheTest, BasicArguments)
{
+ NonThrowableExceptionState exceptionState;
+
ErrorWebCacheForTests* testCache;
Cache* cache = Cache::create(testCache = new NotImplementedErrorCache());
ASSERT(cache);
@@ -308,7 +312,7 @@ TEST_F(ServiceWorkerCacheTest, BasicArguments)
EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(matchResult));
- ScriptPromise stringMatchResult = cache->match(scriptState(), url, options);
+ ScriptPromise stringMatchResult = cache->match(scriptState(), url, options, exceptionState);
EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchResult));
@@ -318,7 +322,7 @@ TEST_F(ServiceWorkerCacheTest, BasicArguments)
EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(matchAllResult));
- ScriptPromise stringMatchAllResult = cache->matchAll(scriptState(), url, options);
+ ScriptPromise stringMatchAllResult = cache->matchAll(scriptState(), url, options, exceptionState);
EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchAllResult));
@@ -332,7 +336,7 @@ TEST_F(ServiceWorkerCacheTest, BasicArguments)
EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(keysResult2));
- ScriptPromise stringKeysResult2 = cache->keys(scriptState(), url, options);
+ ScriptPromise stringKeysResult2 = cache->keys(scriptState(), url, options, exceptionState);
EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringKeysResult2));
}
@@ -340,6 +344,8 @@ TEST_F(ServiceWorkerCacheTest, BasicArguments)
// Tests that arguments are faithfully passed to API calls that degrade to batch operations.
TEST_F(ServiceWorkerCacheTest, BatchOperationArguments)
{
+ NonThrowableExceptionState exceptionState;
+
ErrorWebCacheForTests* testCache;
Cache* cache = Cache::create(testCache = new NotImplementedErrorCache());
ASSERT(cache);
@@ -375,7 +381,7 @@ TEST_F(ServiceWorkerCacheTest, BatchOperationArguments)
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(deleteResult));
- ScriptPromise stringDeleteResult = cache->deleteFunction(scriptState(), url, options);
+ ScriptPromise stringDeleteResult = cache->deleteFunction(scriptState(), url, options, exceptionState);
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringDeleteResult));
@@ -395,7 +401,7 @@ TEST_F(ServiceWorkerCacheTest, BatchOperationArguments)
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(putResult));
- ScriptPromise stringPutResult = cache->put(scriptState(), url, response);
+ ScriptPromise stringPutResult = cache->put(scriptState(), url, response, exceptionState);
EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCalled());
EXPECT_EQ(kNotImplementedString, getRejectString(stringPutResult));
@@ -420,6 +426,8 @@ private:
TEST_F(ServiceWorkerCacheTest, MatchResponseTest)
{
+ NonThrowableExceptionState exceptionState;
+
const String requestUrl = "http://request.url/";
const String responseUrl = "http://match.response.test/";
@@ -430,7 +438,7 @@ TEST_F(ServiceWorkerCacheTest, MatchResponseTest)
Cache* cache = Cache::create(new MatchTestCache(webResponse));
CacheQueryOptions options;
- ScriptPromise result = cache->match(scriptState(), requestUrl, options);
+ ScriptPromise result = cache->match(scriptState(), requestUrl, options, exceptionState);
ScriptValue scriptValue = getResolveValue(result);
Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue.v8Value());
ASSERT_TRUE(response);
@@ -504,6 +512,8 @@ private:
TEST_F(ServiceWorkerCacheTest, MatchAllAndBatchResponseTest)
{
+ NonThrowableExceptionState exceptionState;
+
const String url1 = "http://first.response/";
const String url2 = "http://second.response/";
@@ -520,10 +530,9 @@ TEST_F(ServiceWorkerCacheTest, MatchAllAndBatchResponseTest)
Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses));
CacheQueryOptions options;
- ScriptPromise result = cache->matchAll(scriptState(), "http://some.url/", options);
+ ScriptPromise result = cache->matchAll(scriptState(), "http://some.url/", options, exceptionState);
ScriptValue scriptValue = getResolveValue(result);
- NonThrowableExceptionState exceptionState;
Vector<v8::Handle<v8::Value> > responses = toImplArray<v8::Handle<v8::Value> >(scriptValue.v8Value(), 0, isolate(), exceptionState);
EXPECT_EQ(expectedUrls.size(), responses.size());
for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i < minsize; ++i) {
@@ -533,7 +542,7 @@ TEST_F(ServiceWorkerCacheTest, MatchAllAndBatchResponseTest)
EXPECT_EQ(expectedUrls[i], response->url());
}
- result = cache->deleteFunction(scriptState(), "http://some.url/", options);
+ result = cache->deleteFunction(scriptState(), "http://some.url/", options, exceptionState);
scriptValue = getResolveValue(result);
EXPECT_TRUE(scriptValue.v8Value()->IsBoolean());
EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue());
« no previous file with comments | « Source/modules/serviceworkers/Cache.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698