chromium/chrome/browser/tpcd/http_error_observer/js_error_ukm_browsertest.cc

// Copyright 2023 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/metrics/histogram_tester.h"

#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom.h"

constexpr char kHostA[] =;

namespace {
// Handles Favicon requests so they don't produce a 404 and augment error
// metrics during a test
std::unique_ptr<net::test_server::HttpResponse> HandleFaviconRequest(
    const net::test_server::HttpRequest& request) {}
}  // namespace

class JSErrProcBrowserTest : public InProcessBrowserTest {};

// Test that no error is registered when JS with no errors is embedded
IN_PROC_BROWSER_TEST_F(JSErrProcBrowserTest, NoErr) {}

// Test that JS Error is registered on HTML page containing uncaught JS error
// TODO(b/338241225): Reenable once the UncaughtJSError event is being sent.
IN_PROC_BROWSER_TEST_F(JSErrProcBrowserTest, DISABLED_JSErr) {}

// Test that JS Error is registered on Iframe containing uncaught JS error
// Flaky: https://crbug.com/1503531.
IN_PROC_BROWSER_TEST_F(JSErrProcBrowserTest, DISABLED_IframeJSErr) {}

// Test that no JS Error is registered on embedded script with handled errors
IN_PROC_BROWSER_TEST_F(JSErrProcBrowserTest, HandledJSErr) {}