File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
main/java/com/microsoft/playwright/impl
test/java/com/microsoft/playwright Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -946,9 +946,6 @@ public byte[] pdf(PdfOptions options) {
946946 }
947947
948948 private byte [] pdfImpl (PdfOptions options ) {
949- if (!browserContext .browser ().isChromium ()) {
950- throw new PlaywrightException ("Page.pdf only supported in headless Chromium" );
951- }
952949 if (options == null ) {
953950 options = new PdfOptions ();
954951 }
Original file line number Diff line number Diff line change @@ -52,6 +52,18 @@ void shouldSupportFractionalScaleValue(@TempDir Path tempDir) throws IOException
5252 @ DisabledIf (value ="com.microsoft.playwright.TestBase#isChromium" , disabledReason ="skip" )
5353 void shouldThrowInNonChromium () {
5454 PlaywrightException e = assertThrows (PlaywrightException .class , () -> page .pdf ());
55- assertTrue (e .getMessage ().contains ("Page.pdf only supported in headless Chromium" ));
55+ assertTrue (e .getMessage ().contains ("PDF generation is only supported for Headless Chromium" ), e .getMessage ());
56+ }
57+
58+
59+ @ Test
60+ @ DisabledIf (value ="com.microsoft.playwright.TestBase#isChromium" , disabledReason ="skip" )
61+ void correctExceptionWithPersistentContext (@ TempDir Path tempDir ) {
62+ Path profile = tempDir .resolve ("profile" );
63+ try (BrowserContext context = browserType .launchPersistentContext (profile )) {
64+ Page page = context .newPage ();
65+ PlaywrightException e = assertThrows (PlaywrightException .class , () -> page .pdf ());
66+ assertTrue (e .getMessage ().contains ("PDF generation is only supported for Headless Chromium" ), e .getMessage ());
67+ }
5668 }
5769}
You can’t perform that action at this time.
0 commit comments