Skip to content

Commit c50cfef

Browse files
ars18wrwiText-CI
authored andcommitted
Add some tests which show that base href set in an html is not supported
DEVSIX-6389 Autoported commit. Original commit hash: [9fb8459db]
1 parent 88a43dd commit c50cfef

File tree

7 files changed

+49
-1
lines changed

7 files changed

+49
-1
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/resolver/resource/HtmlResourceResolverTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,28 @@ public virtual void ConvertToPdfWithBaseUriFromUriTest() {
385385
().SetBaseUri(baseUri));
386386
}
387387

388+
[NUnit.Framework.Test]
389+
[LogMessage(Html2PdfLogMessageConstant.NO_WORKER_FOUND_FOR_TAG)]
390+
[LogMessage(Html2PdfLogMessageConstant.UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI)]
391+
[LogMessage(Html2PdfLogMessageConstant.WORKER_UNABLE_TO_PROCESS_OTHER_WORKER)]
392+
public virtual void BaseHrefViaHtmlResourceReferenceTest() {
393+
// TODO DEVSIX-6410 base href on html level is not supported
394+
String outPdf = DESTINATION_FOLDER + "baseHrefViaHtmlResourceReferenceTest.pdf";
395+
String cmpPdf = SOURCE_FOLDER + "cmp_baseHrefViaHtmlResourceReferenceTest.pdf";
396+
ConvertHtmlFileToPdf(SOURCE_FOLDER + "baseHrefViaHtmlResourceReferenceTest.html", outPdf, cmpPdf, new ConverterProperties
397+
());
398+
}
399+
400+
[NUnit.Framework.Test]
401+
[LogMessage(Html2PdfLogMessageConstant.NO_WORKER_FOUND_FOR_TAG)]
402+
public virtual void BaseHrefViaHtmlStylesheetReferenceTest() {
403+
// TODO DEVSIX-6410 base href on html level is not supported
404+
String outPdf = DESTINATION_FOLDER + "baseHrefViaHtmlStylesheetReferenceTest.pdf";
405+
String cmpPdf = SOURCE_FOLDER + "cmp_baseHrefViaHtmlStylesheetReferenceTest.pdf";
406+
ConvertHtmlFileToPdf(SOURCE_FOLDER + "baseHrefViaHtmlStylesheetReferenceTest.html", outPdf, cmpPdf, new ConverterProperties
407+
());
408+
}
409+
388410
private void ConvertHtmlStreamToPdf(String htmlPath, String outPdf, String cmpPdf, String baseUri) {
389411
System.Console.Out.WriteLine("html: " + UrlUtil.GetNormalizedFileUriString(htmlPath) + "\n");
390412
using (FileStream fileInputStream = new FileStream(htmlPath, FileMode.Open, FileAccess.Read)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<html>
2+
<head>
3+
<base href="img/">
4+
</head>
5+
<body>
6+
<p>The following image is inside a subfolder, specified in the html's base tag. It should be shown.</p>
7+
<img src="itis.jpg">
8+
<p>On the contrary, the following image is inside the root folder. It should not be shown.</p>
9+
<img src="bulb.gif">
10+
</body>
11+
</html>
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<html>
2+
<head>
3+
<base href="style/">
4+
<link href="styles.css" rel="stylesheet" type="text/css">
5+
</head>
6+
<body>
7+
<p>This paragraph should have a blue color and a font-size of 10 px, which are specified in the attached stylesheet.</p>
8+
</body>
9+
</html>
10+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
p {
2+
color: blue;
3+
font-size: 10px;
4+
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b0cee85ab798d3a5738ebb4f1bb703ae64f76dcc
1+
9fb8459dbf58745ab5e92789474cbef1893afa93

0 commit comments

Comments
 (0)