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

Side by Side Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 205563006: Add a status code to install event handled message from Service Worker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/browser/service_worker/embedded_worker_instance.h" 9 #include "content/browser/service_worker/embedded_worker_instance.h"
10 #include "content/browser/service_worker/embedded_worker_registry.h" 10 #include "content/browser/service_worker/embedded_worker_registry.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (registration_) { 210 if (registration_) {
211 registration_->Shutdown(); 211 registration_->Shutdown();
212 registration_ = NULL; 212 registration_ = NULL;
213 } 213 }
214 if (version_) { 214 if (version_) {
215 version_->Shutdown(); 215 version_->Shutdown();
216 version_ = NULL; 216 version_ = NULL;
217 } 217 }
218 } 218 }
219 219
220 void InstallTestHelper(const std::string& worker_url) { 220 void InstallTestHelper(const std::string& worker_url,
221 ServiceWorkerStatusCode expected) {
dominicc (has gone to gerrit) 2014/03/26 01:28:01 Would it be better to name this expected_status? I
falken 2014/03/26 07:53:56 Done.
221 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this, 222 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this,
222 worker_url)); 223 worker_url));
223 224
224 // Dispatch install on a worker. 225 // Dispatch install on a worker.
225 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; 226 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED;
226 base::RunLoop install_run_loop; 227 base::RunLoop install_run_loop;
227 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 228 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
228 base::Bind(&self::InstallOnIOThread, this, 229 base::Bind(&self::InstallOnIOThread, this,
229 install_run_loop.QuitClosure(), 230 install_run_loop.QuitClosure(),
230 &status)); 231 &status));
231 install_run_loop.Run(); 232 install_run_loop.Run();
232 ASSERT_EQ(SERVICE_WORKER_OK, status); 233 ASSERT_EQ(expected, status);
233 234
234 // Stop the worker. 235 // Stop the worker.
235 status = SERVICE_WORKER_ERROR_FAILED; 236 status = SERVICE_WORKER_ERROR_FAILED;
236 base::RunLoop stop_run_loop; 237 base::RunLoop stop_run_loop;
237 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 238 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
238 base::Bind(&self::StopOnIOThread, this, 239 base::Bind(&self::StopOnIOThread, this,
239 stop_run_loop.QuitClosure(), 240 stop_run_loop.QuitClosure(),
240 &status)); 241 &status));
241 stop_run_loop.Run(); 242 stop_run_loop.Run();
242 ASSERT_EQ(SERVICE_WORKER_OK, status); 243 ASSERT_EQ(SERVICE_WORKER_OK, status);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 base::RunLoop start_run_loop; 367 base::RunLoop start_run_loop;
367 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 368 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
368 base::Bind(&self::StartOnIOThread, this, 369 base::Bind(&self::StartOnIOThread, this,
369 start_run_loop.QuitClosure(), 370 start_run_loop.QuitClosure(),
370 &status)); 371 &status));
371 start_run_loop.Run(); 372 start_run_loop.Run();
372 ASSERT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status); 373 ASSERT_EQ(SERVICE_WORKER_ERROR_START_WORKER_FAILED, status);
373 } 374 }
374 375
375 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, Install) { 376 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, Install) {
376 InstallTestHelper("/service_worker/worker.js"); 377 InstallTestHelper("/service_worker/worker.js", SERVICE_WORKER_OK);
377 } 378 }
378 379
379 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, 380 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest,
380 InstallWithWaitUntil_Fulfilled) { 381 InstallWithWaitUntil_Fulfilled) {
381 InstallTestHelper("/service_worker/worker_install_fulfilled.js"); 382 InstallTestHelper("/service_worker/worker_install_fulfilled.js",
383 SERVICE_WORKER_OK);
382 } 384 }
383 385
386 // Temporarily disabled until a Blink change lands that hooks up the install
387 // failure code.
384 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, 388 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest,
385 InstallWithWaitUntil_Rejected) { 389 DISABLED_InstallWithWaitUntil_Rejected) {
386 // TODO(kinuko): This should also report back an error, but we 390 InstallTestHelper("/service_worker/worker_install_rejected.js",
387 // don't have plumbing for it yet. 391 SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED);
388 InstallTestHelper("/service_worker/worker_install_rejected.js");
389 } 392 }
390 393
391 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Response) { 394 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Response) {
392 ServiceWorkerFetchEventResult result; 395 ServiceWorkerFetchEventResult result;
393 ServiceWorkerResponse response; 396 ServiceWorkerResponse response;
394 FetchTestHelper("/service_worker/fetch_event.js", &result, &response); 397 FetchTestHelper("/service_worker/fetch_event.js", &result, &response);
395 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result); 398 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result);
396 EXPECT_EQ(200, response.status_code); 399 EXPECT_EQ(200, response.status_code);
397 EXPECT_EQ("OK", response.status_text); 400 EXPECT_EQ("OK", response.status_text);
398 EXPECT_EQ("GET", response.method); 401 EXPECT_EQ("GET", response.method);
(...skipping 11 matching lines...) Expand all
410 } 413 }
411 414
412 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Rejected) { 415 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Rejected) {
413 ServiceWorkerFetchEventResult result; 416 ServiceWorkerFetchEventResult result;
414 ServiceWorkerResponse response; 417 ServiceWorkerResponse response;
415 FetchTestHelper("/service_worker/fetch_event_error.js", &result, &response); 418 FetchTestHelper("/service_worker/fetch_event_error.js", &result, &response);
416 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, result); 419 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK, result);
417 } 420 }
418 421
419 } // namespace content 422 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698