| Index: chrome/browser/extensions/service_worker_apitest.cc
|
| diff --git a/chrome/browser/extensions/service_worker_apitest.cc b/chrome/browser/extensions/service_worker_apitest.cc
|
| index 54dc7462cf1f94b9dd4d7bf0aad1ec034f52eea8..b08c47fa96841a1b4a2b55131839e319f0c94e33 100644
|
| --- a/chrome/browser/extensions/service_worker_apitest.cc
|
| +++ b/chrome/browser/extensions/service_worker_apitest.cc
|
| @@ -36,6 +36,7 @@
|
| #include "content/public/common/page_type.h"
|
| #include "content/public/test/background_sync_test_util.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| +#include "content/public/test/service_worker_test_helpers.h"
|
| #include "extensions/browser/extension_host.h"
|
| #include "extensions/browser/extension_registry.h"
|
| #include "extensions/browser/process_manager.h"
|
| @@ -43,6 +44,7 @@
|
| #include "extensions/test/extension_test_message_listener.h"
|
| #include "net/dns/mock_host_resolver.h"
|
| #include "net/test/embedded_test_server/embedded_test_server.h"
|
| +#include "url/url_constants.h"
|
|
|
| namespace extensions {
|
|
|
| @@ -682,6 +684,40 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, Events) {
|
| ASSERT_EQ("chrome.tabs.onUpdated callback", result);
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, EventsToStoppedWorker) {
|
| + // Extensions APIs from SW are only enabled on trunk.
|
| + ScopedCurrentChannel current_channel_override(version_info::Channel::UNKNOWN);
|
| + const Extension* extension = LoadExtensionWithFlags(
|
| + test_data_dir_.AppendASCII("service_worker/events_to_stopped_worker"),
|
| + kFlagNone);
|
| + ASSERT_TRUE(extension);
|
| + ui_test_utils::NavigateToURL(browser(),
|
| + extension->GetResourceURL("page.html"));
|
| + content::WebContents* web_contents =
|
| + browser()->tab_strip_model()->GetActiveWebContents();
|
| + {
|
| + std::string result;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + web_contents, "window.runServiceWorker()", &result));
|
| + ASSERT_EQ("ready", result);
|
| +
|
| + base::RunLoop run_loop;
|
| + content::StoragePartition* storage_partition =
|
| + content::BrowserContext::GetDefaultStoragePartition(
|
| + browser()->profile());
|
| + content::StopServiceWorkerForPattern(
|
| + storage_partition->GetServiceWorkerContext(),
|
| + // The service worker is registered at the top level scope.
|
| + extension->url(), run_loop.QuitClosure());
|
| + run_loop.Run();
|
| + }
|
| +
|
| + std::string result;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + web_contents, "window.createTabThenUpdate()", &result));
|
| + ASSERT_EQ("chrome.tabs.onUpdated callback", result);
|
| +}
|
| +
|
| // Tests that worker ref count increments while extension API function is
|
| // active.
|
|
|
|
|