OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/service_worker/service_worker_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
12 #include "content/browser/service_worker/service_worker_context_core.h" | 12 #include "content/browser/service_worker/service_worker_context_core.h" |
| 13 #include "content/browser/service_worker/service_worker_registration_handle.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 class ServiceWorkerRegistrationTest : public testing::Test { | 19 class ServiceWorkerRegistrationTest : public testing::Test { |
19 public: | 20 public: |
20 ServiceWorkerRegistrationTest() | 21 ServiceWorkerRegistrationTest() |
21 : io_thread_(BrowserThread::IO, &message_loop_) {} | 22 : io_thread_(BrowserThread::IO, &message_loop_) {} |
22 | 23 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 140 |
140 EXPECT_FALSE(registration->waiting_version()); | 141 EXPECT_FALSE(registration->waiting_version()); |
141 EXPECT_EQ(ChangedVersionAttributesMask::WAITING_VERSION, | 142 EXPECT_EQ(ChangedVersionAttributesMask::WAITING_VERSION, |
142 listener.observed_changed_mask_.changed()); | 143 listener.observed_changed_mask_.changed()); |
143 EXPECT_EQ(version_1_id, listener.observed_info_.active_version.version_id); | 144 EXPECT_EQ(version_1_id, listener.observed_info_.active_version.version_id); |
144 EXPECT_TRUE(listener.observed_info_.waiting_version.is_null); | 145 EXPECT_TRUE(listener.observed_info_.waiting_version.is_null); |
145 EXPECT_TRUE(listener.observed_info_.installing_version.is_null); | 146 EXPECT_TRUE(listener.observed_info_.installing_version.is_null); |
146 EXPECT_TRUE(listener.observed_info_.controlling_version.is_null); | 147 EXPECT_TRUE(listener.observed_info_.controlling_version.is_null); |
147 } | 148 } |
148 | 149 |
| 150 TEST_F(ServiceWorkerRegistrationTest, FailedRegistrationNoCrash) { |
| 151 const GURL kScope("http://www.example.not/"); |
| 152 const GURL kScript("http://www.example.not/service_worker.js"); |
| 153 int64 kRegistrationId = 1L; |
| 154 int kProviderId = 1; |
| 155 scoped_refptr<ServiceWorkerRegistration> registration = |
| 156 new ServiceWorkerRegistration( |
| 157 kScope, |
| 158 kScript, |
| 159 kRegistrationId, |
| 160 context_ptr_); |
| 161 scoped_ptr<ServiceWorkerRegistrationHandle> handle( |
| 162 new ServiceWorkerRegistrationHandle(context_ptr_, |
| 163 NULL, |
| 164 kProviderId, |
| 165 registration.get())); |
| 166 registration->NotifyRegistrationFailed(); |
| 167 // Don't crash when handle gets destructed. |
| 168 } |
| 169 |
149 } // namespace content | 170 } // namespace content |
OLD | NEW |