#include "components/dom_distiller/content/browser/distiller_page_web_contents.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
#include "components/dom_distiller/content/browser/test/test_util.h"
#include "components/dom_distiller/core/distiller_page.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
#include "components/dom_distiller/core/proto/distilled_page.pb.h"
#include "components/dom_distiller/core/viewer.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "content/shell/browser/shell.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/dom_distiller_js/dom_distiller.pb.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
ContentBrowserTest;
ContainsRegex;
HasSubstr;
Not;
namespace {
class WebContentsMainFrameHelper : public content::WebContentsObserver { … };
}
namespace dom_distiller {
const char* kSimpleArticlePath = …;
const char* kVideoArticlePath = …;
class DistillerPageWebContentsTest : public ContentBrowserTest { … };
class TestDistillerPageWebContents : public DistillerPageWebContents { … };
#if BUILDFLAG(IS_WIN)
#define MAYBE_BasicDistillationWorks …
#else
#define MAYBE_BasicDistillationWorks …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_BasicDistillationWorks) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_HandlesRelativeLinks …
#else
#define MAYBE_HandlesRelativeLinks …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_HandlesRelativeLinks) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_HandlesRelativeImages …
#else
#define MAYBE_HandlesRelativeImages …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_HandlesRelativeImages) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_HandlesRelativeVideos …
#else
#define MAYBE_HandlesRelativeVideos …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_HandlesRelativeVideos) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_VisibilityDetection …
#else
#define MAYBE_VisibilityDetection …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_VisibilityDetection) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_UsingCurrentWebContentsWrongUrl …
#else
#define MAYBE_UsingCurrentWebContentsWrongUrl …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_UsingCurrentWebContentsWrongUrl) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_UsingCurrentWebContentsNotFinishedLoadingYet …
#else
#define MAYBE_UsingCurrentWebContentsNotFinishedLoadingYet …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_UsingCurrentWebContentsNotFinishedLoadingYet) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_UsingCurrentWebContentsReadyForDistillation …
#else
#define MAYBE_UsingCurrentWebContentsReadyForDistillation …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_UsingCurrentWebContentsReadyForDistillation) { … }
void DistillerPageWebContentsTest::RunUseCurrentWebContentsTest(
const std::string& url,
bool expect_new_web_contents,
bool wait_for_document_loaded) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_PageDestroyedBeforeFinishDistillation …
#else
#define MAYBE_PageDestroyedBeforeFinishDistillation …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
MAYBE_PageDestroyedBeforeFinishDistillation) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_MarkupInfo …
#else
#define MAYBE_MarkupInfo …
#endif
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest, MAYBE_MarkupInfo) { … }
IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
TestNoContentDoesNotCrash) { … }
}