chromium/chrome/browser/ui/views/site_data/page_specific_site_data_dialog_browsertest.cc

// Copyright 2022 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 "base/memory/raw_ptr.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/site_data/page_specific_site_data_dialog.h"
#include "chrome/browser/ui/views/site_data/page_specific_site_data_dialog_controller.h"
#include "chrome/browser/ui/views/site_data/site_data_row_view.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/browsing_data/core/browsing_data_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/infobars/content/content_infobar_manager.h"
#include "components/page_info/core/features.h"
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/widget/any_widget_observer.h"

namespace {

const char kCookiesInUseDialogOpenedActionName[] =;

const char kDeleteBrowsingDataActionName[] =;

void ClickButton(views::Button* button) {}

}  // namespace

class PageSpecificSiteDataDialogBrowserTest
    : public InProcessBrowserTest,
      public ::testing::WithParamInterface<bool> {};

///////////////////////////////////////////////////////////////////////////////
// Testing the dialog lifecycle, if the dialog is properly destroyed in
// different scenarious.

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest, CloseDialog) {}

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest,
                       NavigateSameOrigin) {}

// TODO(crbug.com/40231917): Figure out why the dialog isn't closed when
// nnavigating away on Linux and overall flaky on other platforms.
IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest,
                       DISABLED_NavigateAway) {}

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest,
                       ChangeAndCloseTab) {}

// Closing the widget asynchronously destroys the CollectedCookiesViews object,
// but synchronously removes it from the WebContentsModalDialogManager. Make
// sure there's no crash when trying to re-open the dialog right
// after closing it. Regression test for https://crbug.com/989888
IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest,
                       CloseDialogAndReopen) {}

// TODO(crbug.com/40231917): Add testing dialog functionality such as showing
// infobar after changes, changing content settings, deleting data.

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest, DeleteMenuItem) {}

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest, BlockMenuItem) {}

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest, AllowMenuItem) {}

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest,
                       ClearOnExitMenuItem) {}

class PageSpecificSiteDataDialogPre3pcdBrowserTest
    : public PageSpecificSiteDataDialogBrowserTest {};

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogPre3pcdBrowserTest,
                       PartitionedCookiesAndAllowedThirdParty) {}

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest,
                       PartitionedCookiesAndBlockedThirdParty) {}

IN_PROC_BROWSER_TEST_F(PageSpecificSiteDataDialogBrowserTest,
                       SameOriginNavigationDeletion) {}