chromium/chrome/browser/iframe_browsertest.cc

// Copyright 2012 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/files/file_path.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "url/gurl.h"

class IFrameTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(IFrameTest, Crash) {}

IN_PROC_BROWSER_TEST_F(IFrameTest, InEmptyFrame) {}

// Test for https://crbug.com/621076. It ensures that file chooser triggered
// by an iframe, which is destroyed before the chooser is closed, does not
// result in a use-after-free condition.
//
// TODO(alexmos): Investigate if there's a way to get this test working in
// Lacros. It seems that the crosapi::mojom::SelectFile interface used by
// SelectFileDialogLacros is unavailable in tests.
// Note: This test is disabled temporarily to track down a memory leak reported
// by the ASan bots. It will be enabled once the root cause is found.
// TODO(crbug.com/40904458): Re-enable this test
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
    BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_FileChooserInDestroyedSubframe
#else
#define MAYBE_FileChooserInDestroyedSubframe
#endif
IN_PROC_BROWSER_TEST_F(IFrameTest, MAYBE_FileChooserInDestroyedSubframe) {}