chromium/components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc

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

#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 {

// Helper class to know how far in the loading process the current WebContents
// has come. It will call the callback either after
// DidCommitProvisionalLoadForFrame or DOMContentLoaded is called for the
// main frame, based on the value of |wait_for_document_loaded|.
class WebContentsMainFrameHelper : public content::WebContentsObserver {};

}  // namespace

namespace dom_distiller {

const char* kSimpleArticlePath =;
const char* kVideoArticlePath =;

class DistillerPageWebContentsTest : public ContentBrowserTest {};

// Use this class to be able to leak the WebContents, which is needed for when
// the current WebContents is used for distillation.
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) {}

}  // namespace dom_distiller