#include "chrome/browser/printing/print_browsertest.h"
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/auto_reset.h"
#include "base/base64.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/notreached.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/printing/browser_printing_context_factory_for_test.h"
#include "chrome/browser/printing/print_compositor_util.h"
#include "chrome/browser/printing/print_error_dialog.h"
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_sticky_settings.h"
#include "chrome/browser/printing/print_test_utils.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/print_view_manager_common.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/printing/test_print_preview_observer.h"
#include "chrome/browser/printing/test_print_view_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "components/printing/browser/print_composite_client.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print.mojom-test-utils.h"
#include "components/printing/common/print.mojom.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "extensions/common/extension.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "printing/backend/test_print_backend.h"
#include "printing/buildflags/buildflags.h"
#include "printing/mojom/print.mojom.h"
#include "printing/page_setup.h"
#include "printing/print_settings.h"
#include "printing/printing_context.h"
#include "printing/printing_context_factory_for_test.h"
#include "printing/printing_features.h"
#include "printing/test_printing_context.h"
#include "printing/units.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/scheduler/web_scheduler_tracked_feature.h"
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
#if BUILDFLAG(ENABLE_OOP_PRINTING)
#include "chrome/browser/printing/print_backend_service_manager.h"
#include "chrome/browser/printing/print_backend_service_test_impl.h"
#include "chrome/browser/printing/print_job_worker_oop.h"
#include "chrome/browser/printing/printer_query_oop.h"
#include "chrome/services/printing/public/mojom/print_backend_service.mojom.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "printing/printing_utils.h"
#include "sandbox/policy/features.h"
#include "sandbox/policy/switches.h"
#endif
namespace printing {
_;
OnDidCreatePrintJobCallback;
namespace {
constexpr int kTestPrinterCapabilitiesMaxCopies = …;
const int kDefaultDocumentCookie = …;
constexpr char kStickySettingsWithExtensionPrinter[] = …;
constexpr char kStickySettingsWithExtensionPrinterMissingPrintableArea[] = …;
class PrintPreviewDoneObserver
: public mojom::PrintRenderFrameInterceptorForTesting { … };
}
class TestPrintRenderFrame
: public mojom::PrintRenderFrameInterceptorForTesting { … };
class TestPrintViewManagerForDLP : public TestPrintViewManager { … };
PrintBrowserTest::WorkerHelper::WorkerHelper(
base::WeakPtr<PrintBrowserTest> owner)
: … { … }
PrintBrowserTest::KillPrintRenderFrame::KillPrintRenderFrame(
content::RenderProcessHost* rph)
: … { … }
PrintBrowserTest::KillPrintRenderFrame::KillPrintRenderFrame(
content::RenderProcessHost* rph,
mojom::PrintRenderFrame* print_render_frame)
: … { … }
PrintBrowserTest::KillPrintRenderFrame::~KillPrintRenderFrame() = default;
void PrintBrowserTest::KillPrintRenderFrame::OverrideBinderForTesting(
content::RenderFrameHost* render_frame_host) { … }
void PrintBrowserTest::KillPrintRenderFrame::KillRenderProcess(
int document_cookie,
mojom::DidPrintContentParamsPtr param,
PrintFrameContentCallback callback) const { … }
void PrintBrowserTest::KillPrintRenderFrame::Bind(
mojo::ScopedInterfaceEndpointHandle handle) { … }
mojom::PrintRenderFrame*
PrintBrowserTest::KillPrintRenderFrame::GetForwardingInterface() { … }
void PrintBrowserTest::KillPrintRenderFrame::PrintFrameContent(
mojom::PrintFrameContentParamsPtr params,
PrintFrameContentCallback callback) { … }
PrintBrowserTest::WorkerHelper::~WorkerHelper() = default;
void PrintBrowserTest::WorkerHelper::OnNewDocument(
#if BUILDFLAG(IS_MAC)
bool destination_is_preview,
#endif
const PrintSettings& settings) { … }
PrintBrowserTest::PrintBrowserTest() = default;
PrintBrowserTest::~PrintBrowserTest() = default;
void PrintBrowserTest::SetUp() { … }
void PrintBrowserTest::SetUpOnMainThread() { … }
void PrintBrowserTest::TearDownOnMainThread() { … }
void PrintBrowserTest::TearDown() { … }
void PrintBrowserTest::AddPrinter(const std::string& printer_name) { … }
void PrintBrowserTest::SetPrinterNameForSubsequentContexts(
const std::string& printer_name) { … }
#if BUILDFLAG(IS_WIN)
void PrintBrowserTest::SetPrinterLanguageTypeForSubsequentContexts(
mojom::PrinterLanguageType printer_language_type) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
test_printing_context_factory_.SetPrinterLanguageTypeForSubsequentContexts(
printer_language_type);
}
#endif
void PrintBrowserTest::SetUserSettingsPageRangesForSubsequentContext(
const PageRanges& page_ranges) { … }
void PrintBrowserTest::SetNewDocumentJobId(int job_id) { … }
void PrintBrowserTest::PrintAndWaitUntilPreviewIsReady() { … }
content::WebContents* PrintBrowserTest::PrintAndWaitUntilPreviewIsReady(
const PrintParams& params) { … }
content::WebContents*
PrintBrowserTest::PrintAndWaitUntilPreviewIsReadyAndLoaded() { … }
content::WebContents*
PrintBrowserTest::PrintAndWaitUntilPreviewIsReadyAndLoaded(
const PrintParams& params) { … }
content::WebContents*
PrintBrowserTest::PrintAndWaitUntilPreviewIsReadyAndMaybeLoaded(
const PrintParams& params,
bool wait_for_loaded) { … }
void PrintBrowserTest::SetNumExpectedMessages(unsigned int num) { … }
void PrintBrowserTest::ResetNumReceivedMessages() { … }
void PrintBrowserTest::WaitUntilCallbackReceived() { … }
void PrintBrowserTest::CheckForQuit() { … }
void PrintBrowserTest::CreateTestPrintRenderFrame(
content::RenderFrameHost* frame_host,
content::WebContents* web_contents) { … }
mojom::PrintFrameContentParamsPtr
PrintBrowserTest::GetDefaultPrintFrameParams() { … }
const mojo::AssociatedRemote<mojom::PrintRenderFrame>&
PrintBrowserTest::GetPrintRenderFrame(content::RenderFrameHost* rfh) { … }
TestPrintRenderFrame* PrintBrowserTest::GetFrameContent(
content::RenderFrameHost* host) const { … }
void PrintBrowserTest::OverrideBinderForTesting(
content::RenderFrameHost* render_frame_host) { … }
void PrintBrowserTest::PrepareRunloop() { … }
void PrintBrowserTest::OnNewDocument(
#if BUILDFLAG(IS_MAC)
bool destination_is_preview,
#endif
const PrintSettings& settings) { … }
void PrintBrowserTest::ShowPrintErrorDialog() { … }
class SitePerProcessPrintBrowserTest : public PrintBrowserTest { … };
class IsolateOriginsPrintBrowserTest : public PrintBrowserTest { … };
class BackForwardCachePrintBrowserTest : public PrintBrowserTest { … };
constexpr char IsolateOriginsPrintBrowserTest::kIsolatedSite[];
class PrintExtensionBrowserTest : public extensions::ExtensionBrowserTest { … };
class SitePerProcessPrintExtensionBrowserTest
: public PrintExtensionBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, SelectionContainsIframe) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, NoScrolling) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DISABLED_NoScrollingFrameset) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, NoScrollingVerticalRl) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, LegacyLayoutEngineFallback) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, LazyLoadedImagesFetched) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, LazyLoadedIframeFetched) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest,
DISABLED_LazyLoadedIframeFetchedCrossOrigin) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, LazyLoadedImagesFetchedScriptedPrint) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, ResetPageScaleAfterPrintPreview) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, PrintFrameContent) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, PrintSubframeContent) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, PrintSubframeChain) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, PrintSubframeABA) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest,
PrintSubframeContentBeforeCompositeClientCreation) { … }
IN_PROC_BROWSER_TEST_F(SitePerProcessPrintBrowserTest, BasicPrint) { … }
IN_PROC_BROWSER_TEST_F(SitePerProcessPrintBrowserTest,
SubframeUnavailableBeforePrint) { … }
IN_PROC_BROWSER_TEST_F(SitePerProcessPrintBrowserTest,
SubframeUnavailableDuringPrint) { … }
IN_PROC_BROWSER_TEST_F(IsolateOriginsPrintBrowserTest, PrintIsolatedSubframe) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, RegularPrinting) { … }
#if BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DLPWarnAllowed) {
ASSERT_TRUE(embedded_test_server()->Started());
GURL url(embedded_test_server()->GetURL("/printing/test1.html"));
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(web_contents);
TestPrintViewManagerForDLP* print_view_manager =
TestPrintViewManagerForDLP::CreateForWebContents(
web_contents,
TestPrintViewManagerForDLP::RestrictionLevel::kWarnAllow);
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kUnknown);
test::StartPrint(browser()->tab_strip_model()->GetActiveWebContents());
print_view_manager->WaitUntilPreviewIsShownOrCancelled();
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kAllowed);
}
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DLPWarnCanceled) {
ASSERT_TRUE(embedded_test_server()->Started());
GURL url(embedded_test_server()->GetURL("/printing/test1.html"));
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(web_contents);
TestPrintViewManagerForDLP* print_view_manager =
TestPrintViewManagerForDLP::CreateForWebContents(
web_contents,
TestPrintViewManagerForDLP::RestrictionLevel::kWarnCancel);
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kUnknown);
test::StartPrint(browser()->tab_strip_model()->GetActiveWebContents());
print_view_manager->WaitUntilPreviewIsShownOrCancelled();
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kDisallowed);
}
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DLPBlocked) {
ASSERT_TRUE(embedded_test_server()->Started());
GURL url(embedded_test_server()->GetURL("/printing/test1.html"));
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(web_contents);
TestPrintViewManagerForDLP* print_view_manager =
TestPrintViewManagerForDLP::CreateForWebContents(
web_contents, TestPrintViewManagerForDLP::RestrictionLevel::kBlock);
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kUnknown);
test::StartPrint(browser()->tab_strip_model()->GetActiveWebContents());
print_view_manager->WaitUntilPreviewIsShownOrCancelled();
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kDisallowed);
}
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DLPWarnAllowedWithWindowDotPrint) {
ASSERT_TRUE(embedded_test_server()->Started());
GURL url(embedded_test_server()->GetURL("/printing/test1.html"));
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(web_contents);
TestPrintViewManagerForDLP* print_view_manager =
TestPrintViewManagerForDLP::CreateForWebContents(
web_contents,
TestPrintViewManagerForDLP::RestrictionLevel::kWarnAllow);
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kUnknown);
content::ExecuteScriptAsync(web_contents->GetPrimaryMainFrame(),
"window.print();");
print_view_manager->WaitUntilPreviewIsShownOrCancelled();
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kAllowed);
}
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DLPWarnCanceledWithWindowDotPrint) {
ASSERT_TRUE(embedded_test_server()->Started());
GURL url(embedded_test_server()->GetURL("/printing/test1.html"));
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(web_contents);
TestPrintViewManagerForDLP* print_view_manager =
TestPrintViewManagerForDLP::CreateForWebContents(
web_contents,
TestPrintViewManagerForDLP::RestrictionLevel::kWarnCancel);
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kUnknown);
content::ExecuteScriptAsync(web_contents->GetPrimaryMainFrame(),
"window.print();");
print_view_manager->WaitUntilPreviewIsShownOrCancelled();
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kDisallowed);
}
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DLPBlockedWithWindowDotPrint) {
ASSERT_TRUE(embedded_test_server()->Started());
GURL url(embedded_test_server()->GetURL("/printing/test1.html"));
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(web_contents);
TestPrintViewManagerForDLP* print_view_manager =
TestPrintViewManagerForDLP::CreateForWebContents(
web_contents, TestPrintViewManagerForDLP::RestrictionLevel::kBlock);
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kUnknown);
content::ExecuteScriptAsync(web_contents->GetPrimaryMainFrame(),
"window.print();");
print_view_manager->WaitUntilPreviewIsShownOrCancelled();
ASSERT_EQ(print_view_manager->GetPrintAllowance(),
TestPrintViewManagerForDLP::PrintAllowance::kDisallowed);
}
#endif
IN_PROC_BROWSER_TEST_F(IsolateOriginsPrintBrowserTest, OopifPrinting) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCachePrintBrowserTest, DisableCaching) { … }
IN_PROC_BROWSER_TEST_F(PrintExtensionBrowserTest, PrintOptionPage) { … }
IN_PROC_BROWSER_TEST_F(PrintExtensionBrowserTest,
UpdatePrintSettingsExtensionPrinter) { … }
IN_PROC_BROWSER_TEST_F(
PrintExtensionBrowserTest,
UpdatePrintSettingsExtensionPrinterMissingPrintableArea) { … }
IN_PROC_BROWSER_TEST_F(SitePerProcessPrintExtensionBrowserTest,
PrintOptionPage) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, DISABLED_PrintNup) { … }
IN_PROC_BROWSER_TEST_F(SitePerProcessPrintBrowserTest, DISABLED_PrintNup) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, MultipagePrint) { … }
IN_PROC_BROWSER_TEST_F(SitePerProcessPrintBrowserTest, MultipagePrint) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest,
DISABLED_PDFPluginNotKeyboardFocusable) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, WindowDotPrint) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, PdfWindowDotPrint) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest,
WindowDotPrintTriggersBeforeAfterEvents) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest,
WindowDotPrintWhilePrintPreviewIsInProgress) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest,
WindowDotPrintWhilePrintPreviewForNodeIsInProgress) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, NoResizeEvent) { … }
IN_PROC_BROWSER_TEST_F(PrintBrowserTest, SpecifiedPageSizeCrash) { … }
class PrintPrerenderBrowserTest
: public PrintBrowserTest,
public testing::WithParamInterface<std::string> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(PrintPrerenderBrowserTest, QuietBlockWithWindowPrint) { … }
IN_PROC_BROWSER_TEST_P(PrintPrerenderBrowserTest,
QuietBlockWithDocumentExecCommand) { … }
class PrintFencedFrameBrowserTest : public PrintBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PrintFencedFrameBrowserTest, ScriptedPrint) { … }
IN_PROC_BROWSER_TEST_F(PrintFencedFrameBrowserTest, DocumentExecCommand) { … }
#if BUILDFLAG(IS_WIN)
std::string GetDocumentDataTypeTestSuffix(
const testing::TestParamInfo<DocumentDataType>& info) {
switch (info.param) {
case DocumentDataType::kUnknown:
NOTREACHED();
case DocumentDataType::kPdf:
return "Pdf";
case DocumentDataType::kXps:
return "Xps";
}
}
class PrintCompositorDocumentDataTypeBrowserTest
: public PrintBrowserTest,
public testing::WithParamInterface<DocumentDataType> {
public:
PrintCompositorDocumentDataTypeBrowserTest() = default;
~PrintCompositorDocumentDataTypeBrowserTest() override = default;
void SetUp() override {
std::vector<base::test::FeatureRefAndParams> enabled_features;
std::vector<base::test::FeatureRef> disabled_features;
enabled_features.push_back(
{features::kEnableOopPrintDrivers,
{{features::kEnableOopPrintDriversJobPrint.name, "true"}}});
if (GetParam() == DocumentDataType::kXps) {
enabled_features.push_back({features::kUseXpsForPrinting, {}});
} else {
disabled_features.push_back(features::kUseXpsForPrinting);
}
scoped_feature_list_.InitWithFeaturesAndParameters(enabled_features,
disabled_features);
PrintBrowserTest::SetUp();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
INSTANTIATE_TEST_SUITE_P(All,
PrintCompositorDocumentDataTypeBrowserTest,
testing::Values(DocumentDataType::kPdf,
DocumentDataType::kXps),
GetDocumentDataTypeTestSuffix);
IN_PROC_BROWSER_TEST_P(PrintCompositorDocumentDataTypeBrowserTest,
WindowDotPrint) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
TestPrintPreviewObserver print_preview_observer(true);
content::ExecuteScriptAsync(web_contents->GetPrimaryMainFrame(),
"window.print();");
print_preview_observer.WaitUntilPreviewIsReady();
EXPECT_THAT(print_preview_observer.last_document_composite_data_type(),
testing::Optional(GetParam()));
}
class PrintCompositorLegacySandboxBrowserTest : public PrintBrowserTest {
void SetUp() override {
std::vector<base::test::FeatureRef> disabled_features;
disabled_features.push_back(
sandbox::policy::features::kPrintCompositorLPAC);
disabled_features.push_back(features::kUseXpsForPrinting);
scoped_feature_list_.InitWithFeatures({},
disabled_features);
PrintBrowserTest::SetUp();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
IN_PROC_BROWSER_TEST_F(PrintCompositorLegacySandboxBrowserTest,
WindowDotPrint) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
TestPrintPreviewObserver print_preview_observer(true);
content::ExecuteScriptAsync(web_contents->GetPrimaryMainFrame(),
"window.print();");
print_preview_observer.WaitUntilPreviewIsReady();
EXPECT_THAT(print_preview_observer.last_document_composite_data_type(),
testing::Optional(DocumentDataType::kPdf));
}
#endif
}