#include <stddef.h>
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/permissions/permissions_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_management_test_util.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/test/test_browser_closed_waiter.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/profile_destruction_waiter.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/service_worker_context_observer.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/service_worker_test_helpers.h"
#include "extensions/browser/api/test/test_api.h"
#include "extensions/browser/background_script_executor.h"
#include "extensions/browser/browsertest_util.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/service_worker/service_worker_keepalive.h"
#include "extensions/browser/service_worker/service_worker_test_utils.h"
#include "extensions/common/extension.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "url/gurl.h"
namespace extensions {
namespace {
constexpr char kTestOpenerExtensionId[] = …;
constexpr char kTestOpenerExtensionUrl[] = …;
constexpr char kTestOpenerExtensionRelativePath[] = …;
constexpr char kTestReceiverExtensionId[] = …;
constexpr char kTestReceiverExtensionUrl[] = …;
constexpr char kTestReceiverExtensionRelativePath[] = …;
constexpr char kPersistentPortConnectedMessage[] = …;
constexpr char kPersistentPortDisconnectedMessage[] = …;
testing::Matcher<ProcessManager::ServiceWorkerKeepaliveData>
GetKeepaliveMatcher(const WorkerId& worker_id,
Activity::Type type,
const std::string& activity_extra_data) { … }
testing::Matcher<ProcessManager::ServiceWorkerKeepaliveData>
GetKeepaliveMatcher(const WorkerId& worker_id, Activity::Type type) { … }
size_t GetExternalRequestCountForWorker(content::BrowserContext& context,
const Extension& extension) { … }
}
TestServiceWorkerContextObserver;
class ServiceWorkerLifetimeKeepaliveBrowsertest : public ExtensionApiTest { … };
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ServiceWorkersTimeOutWithoutPolicy) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ServiceWorkersDoNotTimeOutWithPolicy) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ServiceWorkersTimeOutWhenOnlyOneHasExtendedLifetime) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ServiceWorkersTimeOutWhenPortIsDisconnected) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
KeepalivesForCertainExtensionFunctions) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ExtensionFunctionGetsResolvedAfterWorkerTermination) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
DebuggerAttachKeepsServiceWorkerAlive) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ServiceWorkerKeepaliveUtility) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ShutdownWithActiveMessagePipe) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerLifetimeKeepaliveBrowsertest,
ShutdownWithActiveMessagePipe_SplitModeExtension) { … }
IN_PROC_BROWSER_TEST_F(
ServiceWorkerLifetimeKeepaliveBrowsertest,
ShutdownWithActiveMessagePipe_BetweenExtensionsInDifferentContexts) { … }
}