| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 public void testImage() { | 89 public void testImage() { |
| 90 // Test the absolute and different kinds of relative URLs for image sour
ces, | 90 // Test the absolute and different kinds of relative URLs for image sour
ces, |
| 91 // and also add an extra comma (,) as malformed srcset syntax for robust
ness. | 91 // and also add an extra comma (,) as malformed srcset syntax for robust
ness. |
| 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>" + |
| 98 "<source srcset=\"image200 200w, //example.org/image400 400w\">"
+ |
| 99 "<source srcset=\"image100 100w, //example.org/image300 300w\">"
+ |
| 100 "<img>" + |
| 101 "</picture></figure>" + |
| 97 "<img id=\"b\" style=\"align: left\" alt=\"b\" data-dummy=\"c\" data
-src=\"image2\">" + | 102 "<img id=\"b\" style=\"align: left\" alt=\"b\" data-dummy=\"c\" data
-src=\"image2\">" + |
| 98 "<table role=\"grid\"><tbody><tr><td>" + | 103 "<table role=\"grid\"><tbody><tr><td>" + |
| 99 "<img id=\"c\" style=\"a\" alt=\"b\" src=\"/image\" srcset=\"htt
ps://example.com/image2x 2x, /image4x 4x,\">" + | 104 "<img id=\"c\" style=\"a\" alt=\"b\" src=\"/image\" srcset=\"htt
ps://example.com/image2x 2x, /image4x 4x,\">" + |
| 100 "<img id=\"d\" style=\"a\" align=\"left\" src=\"/image2\">" + | 105 "<img id=\"d\" style=\"a\" align=\"left\" src=\"/image2\">" + |
| 101 "</td></tr></tbody></table>" + | 106 "</td></tr></tbody></table>" + |
| 102 "<p>" + CONTENT_TEXT + "</p>"; | 107 "<p>" + CONTENT_TEXT + "</p>"; |
| 103 | 108 |
| 104 final String expected = | 109 final String expected = |
| 105 "<h1>" + CONTENT_TEXT + "</h1>" + | 110 "<h1>" + CONTENT_TEXT + "</h1>" + |
| 106 "<img src=\"http://example.com/path/image\" " + | 111 "<img src=\"http://example.com/path/image\" " + |
| 107 "srcset=\"http://example.com/path/image200 200w, http://example
.org/image400 400w\">" + | 112 "srcset=\"http://example.com/path/image200 200w, http://example
.org/image400 400w\">" + |
| 113 "<figure><picture>" + |
| 114 "<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\">" + |
| 116 "<img>" + |
| 117 "</picture></figure>" + |
| 108 "<img alt=\"b\" src=\"http://example.com/path/image2\">" + | 118 "<img alt=\"b\" src=\"http://example.com/path/image2\">" + |
| 109 "<table role=\"grid\"><tbody><tr><td>" + | 119 "<table role=\"grid\"><tbody><tr><td>" + |
| 110 "<img alt=\"b\" src=\"http://example.com/image\" " + | 120 "<img alt=\"b\" src=\"http://example.com/image\" " + |
| 111 "srcset=\"https://example.com/image2x 2x, http://example.co
m/image4x 4x, \">" + | 121 "srcset=\"https://example.com/image2x 2x, http://example.co
m/image4x 4x, \">" + |
| 112 "<img src=\"http://example.com/image2\">" + | 122 "<img src=\"http://example.com/image2\">" + |
| 113 "</td></tr></tbody></table>" + | 123 "</td></tr></tbody></table>" + |
| 114 "<p>" + CONTENT_TEXT + "</p>"; | 124 "<p>" + CONTENT_TEXT + "</p>"; |
| 115 | 125 |
| 116 mHead.setInnerHTML("<base href=\"http://example.com/path/\">"); | 126 mHead.setInnerHTML("<base href=\"http://example.com/path/\">"); |
| 117 mBody.setInnerHTML(html); | 127 mBody.setInnerHTML(html); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 691 |
| 682 final String expected = | 692 final String expected = |
| 683 "<p>" + CONTENT_TEXT + "</p>" + | 693 "<p>" + CONTENT_TEXT + "</p>" + |
| 684 "<p>" + CONTENT_TEXT + "</p>" + | 694 "<p>" + CONTENT_TEXT + "</p>" + |
| 685 "<p>" + CONTENT_TEXT + "</p>" + | 695 "<p>" + CONTENT_TEXT + "</p>" + |
| 686 "<p>" + CONTENT_TEXT + "</p>"; | 696 "<p>" + CONTENT_TEXT + "</p>"; |
| 687 | 697 |
| 688 assertExtractor(expected, html); | 698 assertExtractor(expected, html); |
| 689 } | 699 } |
| 690 } | 700 } |
| OLD | NEW |