| 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 com.google.gwt.dom.client.Document; | 7 import com.google.gwt.dom.client.Document; |
| 8 import com.google.gwt.dom.client.Element; | 8 import com.google.gwt.dom.client.Element; |
| 9 | 9 |
| 10 public class ContentExtractorTest extends DomDistillerJsTestCase { | 10 public class ContentExtractorTest extends DomDistillerJsTestCase { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // Also test images in WebImage and WebTable. | 92 // Also test images in WebImage and WebTable. |
| 93 // TODO(wychen): add images in WebText when it is supported. | 93 // TODO(wychen): add images in WebText when it is supported. |
| 94 final String html = | 94 final String html = |
| 95 "<h1>" + CONTENT_TEXT + "</h1>" + | 95 "<h1>" + CONTENT_TEXT + "</h1>" + |
| 96 "<img id=\"a\" style=\"typo\" align=\"left\" src=\"image\" srcset=\"
image200 200w, //example.org/image400 400w\">" + | 96 "<img id=\"a\" style=\"typo\" align=\"left\" src=\"image\" srcset=\"
image200 200w, //example.org/image400 400w\">" + |
| 97 "<figure><picture>" + | 97 "<figure><picture>" + |
| 98 "<source srcset=\"image200 200w, //example.org/image400 400w\">"
+ | 98 "<source srcset=\"image200 200w, //example.org/image400 400w\">"
+ |
| 99 "<source srcset=\"image100 100w, //example.org/image300 300w\">"
+ | 99 "<source srcset=\"image100 100w, //example.org/image300 300w\">"
+ |
| 100 "<img>" + | 100 "<img>" + |
| 101 "</picture></figure>" + | 101 "</picture></figure>" + |
| 102 "<span class=\"lazy-image-placeholder\" data-src=\"/image\" " + |
| 103 "data-srcset=\"/image2x 2x\" data-width=\"20\" data-height=\"10\
"></span>" + |
| 102 "<img id=\"b\" style=\"align: left\" alt=\"b\" data-dummy=\"c\" data
-src=\"image2\">" + | 104 "<img id=\"b\" style=\"align: left\" alt=\"b\" data-dummy=\"c\" data
-src=\"image2\">" + |
| 103 "<table role=\"grid\"><tbody><tr><td>" + | 105 "<table role=\"grid\"><tbody><tr><td>" + |
| 104 "<img id=\"c\" style=\"a\" alt=\"b\" src=\"/image\" srcset=\"htt
ps://example.com/image2x 2x, /image4x 4x,\">" + | 106 "<img id=\"c\" style=\"a\" alt=\"b\" src=\"/image\" srcset=\"htt
ps://example.com/image2x 2x, /image4x 4x,\">" + |
| 105 "<img id=\"d\" style=\"a\" align=\"left\" src=\"/image2\">" + | 107 "<img id=\"d\" style=\"a\" align=\"left\" src=\"/image2\">" + |
| 106 "</td></tr></tbody></table>" + | 108 "</td></tr></tbody></table>" + |
| 107 "<p>" + CONTENT_TEXT + "</p>"; | 109 "<p>" + CONTENT_TEXT + "</p>"; |
| 108 | 110 |
| 109 final String expected = | 111 final String expected = |
| 110 "<h1>" + CONTENT_TEXT + "</h1>" + | 112 "<h1>" + CONTENT_TEXT + "</h1>" + |
| 111 "<img src=\"http://example.com/path/image\" " + | 113 "<img src=\"http://example.com/path/image\" " + |
| 112 "srcset=\"http://example.com/path/image200 200w, http://example
.org/image400 400w\">" + | 114 "srcset=\"http://example.com/path/image200 200w, http://example
.org/image400 400w\">" + |
| 113 "<figure><picture>" + | 115 "<figure><picture>" + |
| 114 "<source srcset=\"http://example.com/path/image200 200w, http://
example.org/image400 400w\">" + | 116 "<source srcset=\"http://example.com/path/image200 200w, http://
example.org/image400 400w\">" + |
| 115 "<source srcset=\"http://example.com/path/image100 100w, http://
example.org/image300 300w\">" + | 117 "<source srcset=\"http://example.com/path/image100 100w, http://
example.org/image300 300w\">" + |
| 116 "<img>" + | 118 "<img>" + |
| 117 "</picture></figure>" + | 119 "</picture></figure>" + |
| 120 "<img srcset=\"http://example.com/image2x 2x\" src=\"http://example.
com/image\" " + |
| 121 "width=\"20\" height=\"10\">" + |
| 118 "<img alt=\"b\" src=\"http://example.com/path/image2\">" + | 122 "<img alt=\"b\" src=\"http://example.com/path/image2\">" + |
| 119 "<table role=\"grid\"><tbody><tr><td>" + | 123 "<table role=\"grid\"><tbody><tr><td>" + |
| 120 "<img alt=\"b\" src=\"http://example.com/image\" " + | 124 "<img alt=\"b\" src=\"http://example.com/image\" " + |
| 121 "srcset=\"https://example.com/image2x 2x, http://example.co
m/image4x 4x, \">" + | 125 "srcset=\"https://example.com/image2x 2x, http://example.co
m/image4x 4x, \">" + |
| 122 "<img src=\"http://example.com/image2\">" + | 126 "<img src=\"http://example.com/image2\">" + |
| 123 "</td></tr></tbody></table>" + | 127 "</td></tr></tbody></table>" + |
| 124 "<p>" + CONTENT_TEXT + "</p>"; | 128 "<p>" + CONTENT_TEXT + "</p>"; |
| 125 | 129 |
| 126 mHead.setInnerHTML("<base href=\"http://example.com/path/\">"); | 130 mHead.setInnerHTML("<base href=\"http://example.com/path/\">"); |
| 127 mBody.setInnerHTML(html); | 131 mBody.setInnerHTML(html); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 695 |
| 692 final String expected = | 696 final String expected = |
| 693 "<p>" + CONTENT_TEXT + "</p>" + | 697 "<p>" + CONTENT_TEXT + "</p>" + |
| 694 "<p>" + CONTENT_TEXT + "</p>" + | 698 "<p>" + CONTENT_TEXT + "</p>" + |
| 695 "<p>" + CONTENT_TEXT + "</p>" + | 699 "<p>" + CONTENT_TEXT + "</p>" + |
| 696 "<p>" + CONTENT_TEXT + "</p>"; | 700 "<p>" + CONTENT_TEXT + "</p>"; |
| 697 | 701 |
| 698 assertExtractor(expected, html); | 702 assertExtractor(expected, html); |
| 699 } | 703 } |
| 700 } | 704 } |
| OLD | NEW |