chromium/chrome/browser/media/unified_autoplay_browsertest.cc

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

#include "base/test/scoped_feature_list.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "content/public/browser/navigation_handle.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/web_contents_observer.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_frame_navigation_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "media/base/media_switches.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "net/dns/mock_host_resolver.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "third_party/blink/public/mojom/autoplay/autoplay.mojom.h"

namespace {

static constexpr char const kFramedTestPagePath[] =;

static constexpr char const kTestPagePath[] =;

class ChromeContentBrowserClientOverrideWebAppScope
    : public ChromeContentBrowserClient {};

}  // anonymous namespace

// Integration tests for the unified autoplay policy that require the //chrome
// layer.
// These tests are called "UnifiedAutoplayBrowserTest" in order to avoid name
// conflict with "AutoplayBrowserTest" in extensions code.
class UnifiedAutoplayBrowserTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenSameOriginOutsideMenu) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenSameOriginFromMenu) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenCrossOriginFromMenu) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenCrossDomainFromMenu) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenWindowFromContextMenu) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenWindowNotContextMenu) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenFromRendererGesture) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, OpenFromRendererNoGesture) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, NoBypassUsingAutoplayFlag) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, BypassUsingAutoplayFlag) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       BypassUsingAutoplayFlag_SameDocument) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, ForceWasActivated_Default) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest, ForceWasActivated_Yes) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       Redirect_SameOrigin_WithGesture) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       Redirect_SameOrigin_WithoutGesture) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       Redirect_CrossOrigin_WithGesture) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       Redirect_CrossOrigin_WithoutGesture) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       MatchingWebAppScopeAllowsAutoplay_Origin) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       MatchingWebAppScopeAllowsAutoplay_Path) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplayBrowserTest,
                       NotMatchingWebAppScopeDoesNotAllowAutoplay) {}

// Integration tests for the new unified autoplay sound settings UI.

class UnifiedAutoplaySettingBrowserTest : public UnifiedAutoplayBrowserTest {};

// Flaky. See https://crbug.com/1101524.
IN_PROC_BROWSER_TEST_F(UnifiedAutoplaySettingBrowserTest, DISABLED_Allow) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplaySettingBrowserTest, Allow_Wildcard) {}

// Flaky. See https://crbug.com/1106521.
IN_PROC_BROWSER_TEST_F(UnifiedAutoplaySettingBrowserTest, DISABLED_Block) {}

IN_PROC_BROWSER_TEST_F(UnifiedAutoplaySettingBrowserTest, Block_Wildcard) {}

// Flaky. See https://crbug.com/1101524.
IN_PROC_BROWSER_TEST_F(UnifiedAutoplaySettingBrowserTest,
                       DISABLED_DefaultAllow) {}