Skip to content

Commit

Permalink
Merge branch 'main' into issues/ASSETS-33747
Browse files Browse the repository at this point in the history
  • Loading branch information
LSantha committed Apr 30, 2024
2 parents 00b3d92 + ec57de2 commit d0c06f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ private String getHtmlWithInjectedAttributes(String html) {
jsAttributes.append(getHtmlAttr(OPTION_ONLOAD, onload));
StringBuilder cssAttributes = new StringBuilder();
cssAttributes.append(getHtmlAttr(OPTION_MEDIA, media));
cssAttributes.append(getHtmlAttr(OPTION_ONLOAD, onload));
String updatedHtml = StringUtils.replace(html,"<script ", "<script " + jsAttributes.toString());
return StringUtils.replace(updatedHtml,"<link ", "<link " + cssAttributes.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ void setUp() {
cssIncludes.put(CAROUSEL_CATEGORY, "<link rel=\"stylesheet\" href=\"" + CAROUSEL_CLIENTLIB_PATH + ".css\" type=\"text/css\">");

cssIncludesWithAttributes = new HashMap<>();
cssIncludesWithAttributes.put(TEASER_CATEGORY, "<link media=\"print\" rel=\"stylesheet\" href=\"" + TEASER_CLIENTLIB_PATH + ".css\" type=\"text/css\">");
cssIncludesWithAttributes.put(ACCORDION_CATEGORY, "<link media=\"print\" rel=\"stylesheet\" href=\"" + ACCORDION_CLIENTLIB_PATH + ".css\" type=\"text/css\">");
cssIncludesWithAttributes.put(CAROUSEL_CATEGORY, "<link media=\"print\" rel=\"stylesheet\" href=\"" + CAROUSEL_CLIENTLIB_PATH + ".css\" type=\"text/css\">");
cssIncludesWithAttributes.put(TEASER_CATEGORY, "<link media=\"print\" onload=\"myFunction()\" rel=\"stylesheet\" href=\"" + TEASER_CLIENTLIB_PATH + ".css\" type=\"text/css\">");
cssIncludesWithAttributes.put(ACCORDION_CATEGORY, "<link media=\"print\" onload=\"myFunction()\" rel=\"stylesheet\" href=\"" + ACCORDION_CLIENTLIB_PATH + ".css\" type=\"text/css\">");
cssIncludesWithAttributes.put(CAROUSEL_CATEGORY, "<link media=\"print\" onload=\"myFunction()\" rel=\"stylesheet\" href=\"" + CAROUSEL_CLIENTLIB_PATH + ".css\" type=\"text/css\">");

jsInlines = new HashMap<>();
jsInlines.put(TEASER_CATEGORY, "console.log('teaser clientlib js');");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ClientlibsIncludeIT {
private String testPage = "/content/core-components/clientlibs-include-page";
private final static String REGEX_SCRIPT_ELEMENT = "<script async crossorigin=\"anonymous\" onload=\"console.log..\".*src=\".*/etc.clientlibs/core/wcm/tests/components/clientlibs-include/clientlibs/site.*.js\"></script>";
private final static String REGEX_LINK_ELEMENT = "<link media=\"print\" rel=\"stylesheet\" href=\".*/etc.clientlibs/core/wcm/tests/components/clientlibs-include/clientlibs/site.*.css\" type=\"text/css\">";
private final static String REGEX_LINK_ONLOAD_ELEMENT = "<link media=\"print\" onload=\"console.log\\(\\)\" rel=\"stylesheet\" href=\".*/etc.clientlibs/core/wcm/tests/components/clientlibs-include/clientlibs/site.*.css\" type=\"text/css\">";

@BeforeClass
public static void beforeClass() {
Expand All @@ -67,7 +68,7 @@ public void testCssInclude() throws ClientException {
public void testAllInclude() throws ClientException {
String content = adminAuthor.doGet(testPage + ".includeall.html", 200).getContent();
GraniteAssert.assertRegExFind("Incorrect script and/or script attributes", content, REGEX_SCRIPT_ELEMENT);
GraniteAssert.assertRegExFind("Incorrect link and/or link attributes", content, REGEX_LINK_ELEMENT);
GraniteAssert.assertRegExFind("Incorrect link and/or link attributes", content, REGEX_LINK_ONLOAD_ELEMENT);
}

}

0 comments on commit d0c06f5

Please sign in to comment.