Skip to content

Commit

Permalink
fix object-classid processing if the js engine is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 21, 2020
1 parent fbc628c commit dfa6ffc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void onAllChildrenAddedToPage(final boolean postponed) {
}

final String clsId = getClassIdAttribute();
if (ATTRIBUTE_NOT_DEFINED != clsId) {
if (ATTRIBUTE_NOT_DEFINED != clsId && getPage().getWebClient().isJavaScriptEngineEnabled()) {
((HTMLObjectElement) getScriptableObject()).setClassid(clsId);
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/com/gargoylesoftware/htmlunit/WebClient8Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,28 @@ public void link() throws Exception {
webClient.getPage(URL_FIRST);
}
}

/**
* @throws Exception if something goes wrong
*/
@Test
public void object() throws Exception {
final String html = "<html>\n"
+ "<head>\n"
+ " <title>foo</title>\n"
+ "</head>\n"
+ "<body>\n"
+ "<object type='application/pdf' classid='cls12345'></object>\n"
+ "</body></html>";

try (WebClient webClient = new WebClient(getBrowserVersion(), false, null, -1)) {
final MockWebConnection webConnection = getMockWebConnection();
webConnection.setResponse(URL_FIRST, html);
webConnection.setResponse(new URL(URL_FIRST, "simple.css"), "");

webClient.setWebConnection(webConnection);

webClient.getPage(URL_FIRST);
}
}
}

0 comments on commit dfa6ffc

Please sign in to comment.