chromium/components/dom_distiller/content/browser/test/dom_distiller_js_browsertest.cc

// Copyright 2015 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/cfi_buildflags.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.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/test/test_timeouts.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_switches.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/embedded_test_server.h"
#include "ui/base/resource/resource_bundle.h"

namespace {

// Helper class to know how far in the loading process the current WebContents
// has come. It will call the callback after DOMContentLoaded is called for
// the main frame.
class WebContentsMainFrameHelper : public content::WebContentsObserver {};

}  // namespace

namespace dom_distiller {

const char* kExternalTestResourcesPath =;
// TODO(crbug.com/40590818): Remove filter once image construction happens
// synchronously and asserts do not flake anymore when exposed to different
// garbage collection heuristics.
const char* kTestFilePath =;
const char* kRunJsTestsJs =;

class DomDistillerJsTest : public content::ContentBrowserTest {};

// Disabled on MSan as well as Android and Linux CFI bots.
// https://crbug.com/845180
// https://crbug.com/1434395
// Then disabled more generally on Android: https://crbug.com/979685
// TODO(jaebaek):  HTMLImageElement::LayoutBoxWidth() returns a value that has
// a small error from the real one (i.e., the real is 38, but it returns 37)
// and it results in the failure of
// EmbedExtractorTest.testImageExtractorWithAttributesCSSHeightCM (See
// crrev.com/c/916021). We must solve this precision issue.
#if defined(MEMORY_SANITIZER) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID) || \
    BUILDFLAG(IS_FUCHSIA) ||                                                   \
    ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) &&                        \
     (BUILDFLAG(CFI_CAST_CHECK) || BUILDFLAG(CFI_ICALL_CHECK) ||               \
      BUILDFLAG(CFI_ENFORCEMENT_DIAGNOSTIC) ||                                 \
      BUILDFLAG(CFI_ENFORCEMENT_TRAP)))
#define MAYBE_RunJsTests
#else
#define MAYBE_RunJsTests
#endif
IN_PROC_BROWSER_TEST_F(DomDistillerJsTest, MAYBE_RunJsTests) {}

}  // namespace dom_distiller