chromium/chrome/browser/extensions/process_management_browsertest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>

#include <tuple>

#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/site_isolation_policy.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
#include "extensions/common/manifest_handlers/web_accessible_resources_info.h"
#include "extensions/common/switches.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"

NavigationController;
WebContents;

namespace extensions {

namespace {

class ProcessManagementTest : public ExtensionBrowserTest {};

// Domain which the Webstore hosted app is associated with in production.
constexpr char kWebstoreURL[] =;
// Domain which the new Webstore is associated with in production.
constexpr char kNewWebstoreURL[] =;
// Domain for testing an overridden Webstore URL.
constexpr char kWebstoreURLOverride[] =;

class ChromeWebStoreProcessTest
    : public ExtensionApiTest,
      public testing::WithParamInterface<const char*> {};

class ChromeWebStoreInIsolatedOriginTest : public ChromeWebStoreProcessTest {};

}  // namespace

// Ensure that hosted apps, extensions, normal web sites, and WebUI never share
// a process with each other, even if we hit the process limit.
// Note: All web and hosted app URLs in this test are same-site, so Site
// Isolation is not directly involved.
IN_PROC_BROWSER_TEST_F(ProcessManagementTest, ProcessOverflow) {}

// Test that pushing both extensions and web processes past the limit creates
// the expected number of processes.
//
// Sets the process limit to 3, with 1 expected extension process when sharing
// is allowed between extensions. The test then creates 3 separate extensions,
// 3 same-site web pages, and 1 cross-site web page.
//
// With extension process sharing, there should be 1 process for all extensions,
// 2 processes for the same-site pages, and an extra process for the cross-site
// page due to Site Isolation.
//
// Without extension process sharing, there should be 3 processes for the
// extensions. The web pages should act as if there were only 1 process used by
// the extensions, so there are 2 web processes for the same-site pages, and an
// extra process for the cross-site page due to Site Isolation.
IN_PROC_BROWSER_TEST_F(ProcessManagementTest, ExtensionAndWebProcessOverflow) {}

IN_PROC_BROWSER_TEST_F(ProcessManagementTest,
                       NavigateExtensionTabToWebViaPost) {}

// Test that the Webstore domain is isolated from a non-webstore subdomain that
// shares the same eTLD+1.
IN_PROC_BROWSER_TEST_P(ChromeWebStoreProcessTest,
                       StoreIsolatedFromRelatedSubdomain) {}

IN_PROC_BROWSER_TEST_P(ChromeWebStoreProcessTest,
                       NavigateWebTabToChromeWebStoreViaPost) {}

INSTANTIATE_TEST_SUITE_P();

// Check that navigations to the Chrome Web Store succeed when the Chrome Web
// Store URL's origin is set as an isolated origin via the
// --isolate-origins flag.  See https://crbug.com/788837.
IN_PROC_BROWSER_TEST_P(ChromeWebStoreInIsolatedOriginTest,
                       NavigationLoadsChromeWebStore) {}

INSTANTIATE_TEST_SUITE_P();

// This test verifies that blocked navigations to extensions pages do not
// overwrite process-per-site map inside content/.
IN_PROC_BROWSER_TEST_F(ProcessManagementTest,
                       NavigateToBlockedExtensionPageInNewTab) {}

// Check that whether we can access the window object of a window.open()'d url
// to an extension is the same regardless of whether the extension is installed.
// https://crbug.com/598265.
IN_PROC_BROWSER_TEST_F(
    ProcessManagementTest,
    TestForkingBehaviorForUninstalledAndNonAccessibleExtensions) {}

}  // namespace extensions