| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.distiller; | 5 package org.chromium.distiller; |
| 6 | 6 |
| 7 import org.chromium.distiller.webdocument.WebTable; | 7 import org.chromium.distiller.webdocument.WebTable; |
| 8 | 8 |
| 9 import com.google.gwt.core.client.JsArray; | 9 import com.google.gwt.core.client.JsArray; |
| 10 import com.google.gwt.dom.client.Document; | 10 import com.google.gwt.dom.client.Document; |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 for (int i = 0; i < mBody.getChildCount(); i++) { | 385 for (int i = 0; i < mBody.getChildCount(); i++) { |
| 386 DomUtil.stripImageElements(mBody.getChild(i)); | 386 DomUtil.stripImageElements(mBody.getChild(i)); |
| 387 } | 387 } |
| 388 assertEquals(expected, mBody.getInnerHTML()); | 388 assertEquals(expected, mBody.getInnerHTML()); |
| 389 | 389 |
| 390 mBody.setInnerHTML(html); | 390 mBody.setInnerHTML(html); |
| 391 DomUtil.stripImageElements(mBody); | 391 DomUtil.stripImageElements(mBody); |
| 392 assertEquals(expected, mBody.getInnerHTML()); | 392 assertEquals(expected, mBody.getInnerHTML()); |
| 393 } | 393 } |
| 394 | 394 |
| 395 public void testStripUnwantedClassNames() { |
| 396 String html = |
| 397 "<br class=\"iscaptiontxt\">" + |
| 398 "<br id=\"a\">" + |
| 399 "<br class=\"\">" + |
| 400 "<div class=\"tion cap\">" + |
| 401 "<br class=\"hascaption\">" + |
| 402 "<br class=\"not_me\">" + |
| 403 "</div>"; |
| 404 |
| 405 final String expected = |
| 406 "<br class=\"caption\">" + |
| 407 "<br id=\"a\">" + |
| 408 "<br>" + |
| 409 "<div>" + |
| 410 "<br class=\"caption\">" + |
| 411 "<br>" + |
| 412 "</div>"; |
| 413 |
| 414 mBody.setInnerHTML(html); |
| 415 for (int i = 0; i < mBody.getChildCount(); i++) { |
| 416 DomUtil.stripUnwantedClassNames(Element.as(mBody.getChild(i))); |
| 417 } |
| 418 assertEquals(expected, mBody.getInnerHTML()); |
| 419 |
| 420 mBody.setInnerHTML(html); |
| 421 DomUtil.stripUnwantedClassNames(mBody); |
| 422 assertEquals(expected, mBody.getInnerHTML()); |
| 423 } |
| 424 |
| 395 public void testIsVisibleByOffsetParentDisplayNone() { | 425 public void testIsVisibleByOffsetParentDisplayNone() { |
| 396 String html = | 426 String html = |
| 397 "<div style=\"display: none;\">" + | 427 "<div style=\"display: none;\">" + |
| 398 "<div></div>" + | 428 "<div></div>" + |
| 399 "</div>"; | 429 "</div>"; |
| 400 mBody.setInnerHTML(html); | 430 mBody.setInnerHTML(html); |
| 401 Element child = mBody.getFirstChildElement().getFirstChildElement(); | 431 Element child = mBody.getFirstChildElement().getFirstChildElement(); |
| 402 assertFalse(DomUtil.isVisibleByOffset(child)); | 432 assertFalse(DomUtil.isVisibleByOffset(child)); |
| 403 } | 433 } |
| 404 | 434 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 element = element.getNextSiblingElement(); | 655 element = element.getNextSiblingElement(); |
| 626 assertEquals(300*200, DomUtil.getArea(element)); | 656 assertEquals(300*200, DomUtil.getArea(element)); |
| 627 | 657 |
| 628 element = element.getNextSiblingElement(); | 658 element = element.getNextSiblingElement(); |
| 629 assertEquals(400*100, DomUtil.getArea(element)); | 659 assertEquals(400*100, DomUtil.getArea(element)); |
| 630 | 660 |
| 631 element = element.getFirstChildElement(); | 661 element = element.getFirstChildElement(); |
| 632 assertEquals(400*100, DomUtil.getArea(element)); | 662 assertEquals(400*100, DomUtil.getArea(element)); |
| 633 } | 663 } |
| 634 } | 664 } |
| OLD | NEW |