OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/dom_storage/dom_storage_cached_area.h" | 5 #include "content/renderer/dom_storage/dom_storage_cached_area.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "content/renderer/dom_storage/dom_storage_proxy.h" | 11 #include "content/renderer/dom_storage/dom_storage_proxy.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 namespace { | 16 namespace { |
17 // A mock implementation of the DomStorageProxy interface. | 17 // A mock implementation of the DOMStorageProxy interface. |
18 class MockProxy : public DomStorageProxy { | 18 class MockProxy : public DOMStorageProxy { |
19 public: | 19 public: |
20 MockProxy() { | 20 MockProxy() { |
21 ResetObservations(); | 21 ResetObservations(); |
22 } | 22 } |
23 | 23 |
24 // DomStorageProxy interface for use by DomStorageCachedArea. | 24 // DOMStorageProxy interface for use by DOMStorageCachedArea. |
25 | 25 |
26 virtual void LoadArea(int connection_id, | 26 virtual void LoadArea(int connection_id, |
27 dom_storage::ValuesMap* values, | 27 DOMStorageValuesMap* values, |
28 const CompletionCallback& callback) OVERRIDE { | 28 const CompletionCallback& callback) OVERRIDE { |
29 pending_callbacks_.push_back(callback); | 29 pending_callbacks_.push_back(callback); |
30 observed_load_area_ = true; | 30 observed_load_area_ = true; |
31 observed_connection_id_ = connection_id; | 31 observed_connection_id_ = connection_id; |
32 *values = load_area_return_values_; | 32 *values = load_area_return_values_; |
33 } | 33 } |
34 | 34 |
35 virtual void SetItem(int connection_id, | 35 virtual void SetItem(int connection_id, |
36 const base::string16& key, | 36 const base::string16& key, |
37 const base::string16& value, | 37 const base::string16& value, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 void CompleteOnePendingCallback(bool success) { | 86 void CompleteOnePendingCallback(bool success) { |
87 ASSERT_TRUE(!pending_callbacks_.empty()); | 87 ASSERT_TRUE(!pending_callbacks_.empty()); |
88 pending_callbacks_.front().Run(success); | 88 pending_callbacks_.front().Run(success); |
89 pending_callbacks_.pop_front(); | 89 pending_callbacks_.pop_front(); |
90 } | 90 } |
91 | 91 |
92 typedef std::list<CompletionCallback> CallbackList; | 92 typedef std::list<CompletionCallback> CallbackList; |
93 | 93 |
94 dom_storage::ValuesMap load_area_return_values_; | 94 DOMStorageValuesMap load_area_return_values_; |
95 CallbackList pending_callbacks_; | 95 CallbackList pending_callbacks_; |
96 bool observed_load_area_; | 96 bool observed_load_area_; |
97 bool observed_set_item_; | 97 bool observed_set_item_; |
98 bool observed_remove_item_; | 98 bool observed_remove_item_; |
99 bool observed_clear_area_; | 99 bool observed_clear_area_; |
100 int observed_connection_id_; | 100 int observed_connection_id_; |
101 base::string16 observed_key_; | 101 base::string16 observed_key_; |
102 base::string16 observed_value_; | 102 base::string16 observed_value_; |
103 GURL observed_page_url_; | 103 GURL observed_page_url_; |
104 | 104 |
105 private: | 105 private: |
106 virtual ~MockProxy() {} | 106 virtual ~MockProxy() {} |
107 }; | 107 }; |
108 | 108 |
109 } // namespace | 109 } // namespace |
110 | 110 |
111 class DomStorageCachedAreaTest : public testing::Test { | 111 class DOMStorageCachedAreaTest : public testing::Test { |
112 public: | 112 public: |
113 DomStorageCachedAreaTest() | 113 DOMStorageCachedAreaTest() |
114 : kNamespaceId(10), | 114 : kNamespaceId(10), |
115 kOrigin("http://dom_storage/"), | 115 kOrigin("http://dom_storage/"), |
116 kKey(ASCIIToUTF16("key")), | 116 kKey(ASCIIToUTF16("key")), |
117 kValue(ASCIIToUTF16("value")), | 117 kValue(ASCIIToUTF16("value")), |
118 kPageUrl("http://dom_storage/page") { | 118 kPageUrl("http://dom_storage/page") { |
119 } | 119 } |
120 | 120 |
121 const int64 kNamespaceId; | 121 const int64 kNamespaceId; |
122 const GURL kOrigin; | 122 const GURL kOrigin; |
123 const base::string16 kKey; | 123 const base::string16 kKey; |
124 const base::string16 kValue; | 124 const base::string16 kValue; |
125 const GURL kPageUrl; | 125 const GURL kPageUrl; |
126 | 126 |
127 virtual void SetUp() { | 127 virtual void SetUp() { |
128 mock_proxy_ = new MockProxy(); | 128 mock_proxy_ = new MockProxy(); |
129 } | 129 } |
130 | 130 |
131 bool IsPrimed(DomStorageCachedArea* cached_area) { | 131 bool IsPrimed(DOMStorageCachedArea* cached_area) { |
132 return cached_area->map_.get(); | 132 return cached_area->map_.get(); |
133 } | 133 } |
134 | 134 |
135 bool IsIgnoringAllMutations(DomStorageCachedArea* cached_area) { | 135 bool IsIgnoringAllMutations(DOMStorageCachedArea* cached_area) { |
136 return cached_area->ignore_all_mutations_; | 136 return cached_area->ignore_all_mutations_; |
137 } | 137 } |
138 | 138 |
139 bool IsIgnoringKeyMutations(DomStorageCachedArea* cached_area, | 139 bool IsIgnoringKeyMutations(DOMStorageCachedArea* cached_area, |
140 const base::string16& key) { | 140 const base::string16& key) { |
141 return cached_area->should_ignore_key_mutation(key); | 141 return cached_area->should_ignore_key_mutation(key); |
142 } | 142 } |
143 | 143 |
144 void ResetAll(DomStorageCachedArea* cached_area) { | 144 void ResetAll(DOMStorageCachedArea* cached_area) { |
145 cached_area->Reset(); | 145 cached_area->Reset(); |
146 mock_proxy_->ResetObservations(); | 146 mock_proxy_->ResetObservations(); |
147 mock_proxy_->pending_callbacks_.clear(); | 147 mock_proxy_->pending_callbacks_.clear(); |
148 } | 148 } |
149 | 149 |
150 void ResetCacheOnly(DomStorageCachedArea* cached_area) { | 150 void ResetCacheOnly(DOMStorageCachedArea* cached_area) { |
151 cached_area->Reset(); | 151 cached_area->Reset(); |
152 } | 152 } |
153 | 153 |
154 protected: | 154 protected: |
155 scoped_refptr<MockProxy> mock_proxy_; | 155 scoped_refptr<MockProxy> mock_proxy_; |
156 }; | 156 }; |
157 | 157 |
158 TEST_F(DomStorageCachedAreaTest, Basics) { | 158 TEST_F(DOMStorageCachedAreaTest, Basics) { |
159 EXPECT_TRUE(mock_proxy_->HasOneRef()); | 159 EXPECT_TRUE(mock_proxy_->HasOneRef()); |
160 scoped_refptr<DomStorageCachedArea> cached_area = | 160 scoped_refptr<DOMStorageCachedArea> cached_area = |
161 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); | 161 new DOMStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
162 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); | 162 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); |
163 EXPECT_EQ(kOrigin, cached_area->origin()); | 163 EXPECT_EQ(kOrigin, cached_area->origin()); |
164 EXPECT_FALSE(mock_proxy_->HasOneRef()); | 164 EXPECT_FALSE(mock_proxy_->HasOneRef()); |
165 cached_area->ApplyMutation(base::NullableString16(kKey, false), | 165 cached_area->ApplyMutation(base::NullableString16(kKey, false), |
166 base::NullableString16(kValue, false)); | 166 base::NullableString16(kValue, false)); |
167 EXPECT_FALSE(IsPrimed(cached_area.get())); | 167 EXPECT_FALSE(IsPrimed(cached_area.get())); |
168 | 168 |
169 ResetAll(cached_area.get()); | 169 ResetAll(cached_area.get()); |
170 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); | 170 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); |
171 EXPECT_EQ(kOrigin, cached_area->origin()); | 171 EXPECT_EQ(kOrigin, cached_area->origin()); |
172 | 172 |
173 const int kConnectionId = 1; | 173 const int kConnectionId = 1; |
174 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); | 174 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); |
175 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 175 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
176 EXPECT_EQ(1u, cached_area->GetLength(kConnectionId)); | 176 EXPECT_EQ(1u, cached_area->GetLength(kConnectionId)); |
177 EXPECT_EQ(kKey, cached_area->GetKey(kConnectionId, 0).string()); | 177 EXPECT_EQ(kKey, cached_area->GetKey(kConnectionId, 0).string()); |
178 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); | 178 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); |
179 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 179 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
180 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); | 180 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); |
181 } | 181 } |
182 | 182 |
183 TEST_F(DomStorageCachedAreaTest, Getters) { | 183 TEST_F(DOMStorageCachedAreaTest, Getters) { |
184 const int kConnectionId = 7; | 184 const int kConnectionId = 7; |
185 scoped_refptr<DomStorageCachedArea> cached_area = | 185 scoped_refptr<DOMStorageCachedArea> cached_area = |
186 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); | 186 new DOMStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
187 | 187 |
188 // GetLength, we expect to see one call to load in the proxy. | 188 // GetLength, we expect to see one call to load in the proxy. |
189 EXPECT_FALSE(IsPrimed(cached_area.get())); | 189 EXPECT_FALSE(IsPrimed(cached_area.get())); |
190 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); | 190 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); |
191 EXPECT_TRUE(IsPrimed(cached_area.get())); | 191 EXPECT_TRUE(IsPrimed(cached_area.get())); |
192 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 192 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
193 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 193 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
194 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); | 194 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); |
195 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); | 195 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
196 mock_proxy_->CompleteAllPendingCallbacks(); | 196 mock_proxy_->CompleteAllPendingCallbacks(); |
(...skipping 11 matching lines...) Expand all Loading... |
208 // GetItem, ditto. | 208 // GetItem, ditto. |
209 ResetAll(cached_area.get()); | 209 ResetAll(cached_area.get()); |
210 EXPECT_FALSE(IsPrimed(cached_area.get())); | 210 EXPECT_FALSE(IsPrimed(cached_area.get())); |
211 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); | 211 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); |
212 EXPECT_TRUE(IsPrimed(cached_area.get())); | 212 EXPECT_TRUE(IsPrimed(cached_area.get())); |
213 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 213 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
214 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 214 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
215 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); | 215 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); |
216 } | 216 } |
217 | 217 |
218 TEST_F(DomStorageCachedAreaTest, Setters) { | 218 TEST_F(DOMStorageCachedAreaTest, Setters) { |
219 const int kConnectionId = 7; | 219 const int kConnectionId = 7; |
220 scoped_refptr<DomStorageCachedArea> cached_area = | 220 scoped_refptr<DOMStorageCachedArea> cached_area = |
221 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); | 221 new DOMStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
222 | 222 |
223 // SetItem, we expect a call to load followed by a call to set item | 223 // SetItem, we expect a call to load followed by a call to set item |
224 // in the proxy. | 224 // in the proxy. |
225 EXPECT_FALSE(IsPrimed(cached_area.get())); | 225 EXPECT_FALSE(IsPrimed(cached_area.get())); |
226 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 226 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
227 EXPECT_TRUE(IsPrimed(cached_area.get())); | 227 EXPECT_TRUE(IsPrimed(cached_area.get())); |
228 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 228 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
229 EXPECT_TRUE(mock_proxy_->observed_set_item_); | 229 EXPECT_TRUE(mock_proxy_->observed_set_item_); |
230 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 230 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
231 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); | 231 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 263 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
264 EXPECT_TRUE(IsPrimed(cached_area.get())); | 264 EXPECT_TRUE(IsPrimed(cached_area.get())); |
265 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 265 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
266 EXPECT_TRUE(mock_proxy_->observed_remove_item_); | 266 EXPECT_TRUE(mock_proxy_->observed_remove_item_); |
267 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 267 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
268 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); | 268 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); |
269 EXPECT_EQ(kKey, mock_proxy_->observed_key_); | 269 EXPECT_EQ(kKey, mock_proxy_->observed_key_); |
270 EXPECT_EQ(2u, mock_proxy_->pending_callbacks_.size()); | 270 EXPECT_EQ(2u, mock_proxy_->pending_callbacks_.size()); |
271 } | 271 } |
272 | 272 |
273 TEST_F(DomStorageCachedAreaTest, MutationsAreIgnoredUntilLoadCompletion) { | 273 TEST_F(DOMStorageCachedAreaTest, MutationsAreIgnoredUntilLoadCompletion) { |
274 const int kConnectionId = 7; | 274 const int kConnectionId = 7; |
275 scoped_refptr<DomStorageCachedArea> cached_area = | 275 scoped_refptr<DOMStorageCachedArea> cached_area = |
276 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); | 276 new DOMStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
277 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); | 277 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); |
278 EXPECT_TRUE(IsPrimed(cached_area.get())); | 278 EXPECT_TRUE(IsPrimed(cached_area.get())); |
279 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); | 279 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
280 | 280 |
281 // Before load completion, the mutation should be ignored. | 281 // Before load completion, the mutation should be ignored. |
282 cached_area->ApplyMutation(base::NullableString16(kKey, false), | 282 cached_area->ApplyMutation(base::NullableString16(kKey, false), |
283 base::NullableString16(kValue, false)); | 283 base::NullableString16(kValue, false)); |
284 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); | 284 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); |
285 | 285 |
286 // Call the load completion callback. | 286 // Call the load completion callback. |
287 mock_proxy_->CompleteOnePendingCallback(true); | 287 mock_proxy_->CompleteOnePendingCallback(true); |
288 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); | 288 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
289 | 289 |
290 // Verify that mutations are now applied. | 290 // Verify that mutations are now applied. |
291 cached_area->ApplyMutation(base::NullableString16(kKey, false), | 291 cached_area->ApplyMutation(base::NullableString16(kKey, false), |
292 base::NullableString16(kValue, false)); | 292 base::NullableString16(kValue, false)); |
293 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); | 293 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); |
294 } | 294 } |
295 | 295 |
296 TEST_F(DomStorageCachedAreaTest, MutationsAreIgnoredUntilClearCompletion) { | 296 TEST_F(DOMStorageCachedAreaTest, MutationsAreIgnoredUntilClearCompletion) { |
297 const int kConnectionId = 4; | 297 const int kConnectionId = 4; |
298 scoped_refptr<DomStorageCachedArea> cached_area = | 298 scoped_refptr<DOMStorageCachedArea> cached_area = |
299 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); | 299 new DOMStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
300 cached_area->Clear(kConnectionId, kPageUrl); | 300 cached_area->Clear(kConnectionId, kPageUrl); |
301 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); | 301 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
302 mock_proxy_->CompleteOnePendingCallback(true); | 302 mock_proxy_->CompleteOnePendingCallback(true); |
303 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); | 303 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
304 | 304 |
305 // Verify that calling Clear twice works as expected, the first | 305 // Verify that calling Clear twice works as expected, the first |
306 // completion callback should have been cancelled. | 306 // completion callback should have been cancelled. |
307 ResetCacheOnly(cached_area.get()); | 307 ResetCacheOnly(cached_area.get()); |
308 cached_area->Clear(kConnectionId, kPageUrl); | 308 cached_area->Clear(kConnectionId, kPageUrl); |
309 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); | 309 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
310 cached_area->Clear(kConnectionId, kPageUrl); | 310 cached_area->Clear(kConnectionId, kPageUrl); |
311 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); | 311 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
312 mock_proxy_->CompleteOnePendingCallback(true); | 312 mock_proxy_->CompleteOnePendingCallback(true); |
313 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); | 313 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
314 mock_proxy_->CompleteOnePendingCallback(true); | 314 mock_proxy_->CompleteOnePendingCallback(true); |
315 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); | 315 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
316 } | 316 } |
317 | 317 |
318 TEST_F(DomStorageCachedAreaTest, KeyMutationsAreIgnoredUntilCompletion) { | 318 TEST_F(DOMStorageCachedAreaTest, KeyMutationsAreIgnoredUntilCompletion) { |
319 const int kConnectionId = 8; | 319 const int kConnectionId = 8; |
320 scoped_refptr<DomStorageCachedArea> cached_area = | 320 scoped_refptr<DOMStorageCachedArea> cached_area = |
321 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); | 321 new DOMStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
322 | 322 |
323 // SetItem | 323 // SetItem |
324 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 324 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
325 mock_proxy_->CompleteOnePendingCallback(true); // load completion | 325 mock_proxy_->CompleteOnePendingCallback(true); // load completion |
326 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); | 326 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
327 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 327 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
328 cached_area->ApplyMutation(base::NullableString16(kKey, false), | 328 cached_area->ApplyMutation(base::NullableString16(kKey, false), |
329 base::NullableString16()); | 329 base::NullableString16()); |
330 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); | 330 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); |
331 mock_proxy_->CompleteOnePendingCallback(true); // set completion | 331 mock_proxy_->CompleteOnePendingCallback(true); // set completion |
(...skipping 14 matching lines...) Expand all Loading... |
346 mock_proxy_->CompleteOnePendingCallback(true); // remove completion | 346 mock_proxy_->CompleteOnePendingCallback(true); // remove completion |
347 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 347 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
348 | 348 |
349 // A failed set item operation should Reset the cache. | 349 // A failed set item operation should Reset the cache. |
350 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 350 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
351 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 351 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
352 mock_proxy_->CompleteOnePendingCallback(false); | 352 mock_proxy_->CompleteOnePendingCallback(false); |
353 EXPECT_FALSE(IsPrimed(cached_area.get())); | 353 EXPECT_FALSE(IsPrimed(cached_area.get())); |
354 } | 354 } |
355 | 355 |
356 } // namespace dom_storage | 356 } // namespace content |
OLD | NEW |