Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1283)

Unified Diff: javatests/org/chromium/distiller/DomUtilTest.java

Issue 2401853004: Strip unwanted classNames from all nodes (Closed)
Patch Set: address comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « javatests/org/chromium/distiller/ContentExtractorTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: javatests/org/chromium/distiller/DomUtilTest.java
diff --git a/javatests/org/chromium/distiller/DomUtilTest.java b/javatests/org/chromium/distiller/DomUtilTest.java
index 295e2fe64092e4c5d9a660955807454fe9bdd3e0..bd73eecbac55c621adcec950bed1d78a85198759 100644
--- a/javatests/org/chromium/distiller/DomUtilTest.java
+++ b/javatests/org/chromium/distiller/DomUtilTest.java
@@ -392,6 +392,36 @@ public class DomUtilTest extends DomDistillerJsTestCase {
assertEquals(expected, mBody.getInnerHTML());
}
+ public void testStripUnwantedClassNames() {
+ String html =
+ "<br class=\"iscaptiontxt\">" +
+ "<br id=\"a\">" +
+ "<br class=\"\">" +
+ "<div class=\"tion cap\">" +
+ "<br class=\"hascaption\">" +
+ "<br class=\"not_me\">" +
+ "</div>";
+
+ final String expected =
+ "<br class=\"caption\">" +
+ "<br id=\"a\">" +
+ "<br>" +
+ "<div>" +
+ "<br class=\"caption\">" +
+ "<br>" +
+ "</div>";
+
+ mBody.setInnerHTML(html);
+ for (int i = 0; i < mBody.getChildCount(); i++) {
+ DomUtil.stripUnwantedClassNames(Element.as(mBody.getChild(i)));
+ }
+ assertEquals(expected, mBody.getInnerHTML());
+
+ mBody.setInnerHTML(html);
+ DomUtil.stripUnwantedClassNames(mBody);
+ assertEquals(expected, mBody.getInnerHTML());
+ }
+
public void testIsVisibleByOffsetParentDisplayNone() {
String html =
"<div style=\"display: none;\">" +
« no previous file with comments | « javatests/org/chromium/distiller/ContentExtractorTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698