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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 assertEquals(11, contentNodes.size()); | 242 assertEquals(11, contentNodes.size()); |
243 } | 243 } |
244 | 244 |
245 public void testMakeAllLinksAbsolute() { | 245 public void testMakeAllLinksAbsolute() { |
246 final String html = | 246 final String html = |
247 "<a href=\"link\"></a>" + | 247 "<a href=\"link\"></a>" + |
248 "<img src=\"image\" srcset=\"image200 200w, image400 400w\">" + | 248 "<img src=\"image\" srcset=\"image200 200w, image400 400w\">" + |
249 "<img src=\"image2\">" + | 249 "<img src=\"image2\">" + |
250 "<video src=\"video\" poster=\"poster\">" + | 250 "<video src=\"video\" poster=\"poster\">" + |
251 "<source src=\"source\">" + | 251 "<source src=\"source\">" + |
252 "<track src=\"track\"></track>" + | 252 "<track src=\"track\">" + |
253 "</video>"; | 253 "</video>"; |
254 | 254 |
255 final String expected = | 255 final String expected = |
256 "<a href=\"http://example.com/link\"></a>" + | 256 "<a href=\"http://example.com/link\"></a>" + |
257 "<img src=\"http://example.com/image\" " + | 257 "<img src=\"http://example.com/image\" " + |
258 "srcset=\"http://example.com/image200 200w, http://example.com/ima
ge400 400w\">" + | 258 "srcset=\"http://example.com/image200 200w, http://example.com/ima
ge400 400w\">" + |
259 "<img src=\"http://example.com/image2\">" + | 259 "<img src=\"http://example.com/image2\">" + |
260 "<video src=\"http://example.com/video\" poster=\"http://example.com
/poster\">" + | 260 "<video src=\"http://example.com/video\" poster=\"http://example.com
/poster\">" + |
261 "<source src=\"http://example.com/source\">" + | 261 "<source src=\"http://example.com/source\">" + |
262 "<track src=\"http://example.com/track\"></track>" + | 262 "<track src=\"http://example.com/track\">" + |
263 "</video>"; | 263 "</video>"; |
264 | 264 |
265 mHead.setInnerHTML("<base href=\"http://example.com/\">"); | 265 mHead.setInnerHTML("<base href=\"http://example.com/\">"); |
266 mBody.setInnerHTML(html); | 266 mBody.setInnerHTML(html); |
267 | 267 |
268 mBody.setInnerHTML(html); | 268 mBody.setInnerHTML(html); |
269 for (int i = 0; i < mBody.getChildCount(); i++) { | 269 for (int i = 0; i < mBody.getChildCount(); i++) { |
270 DomUtil.makeAllLinksAbsolute(mBody.getChild(i)); | 270 DomUtil.makeAllLinksAbsolute(mBody.getChild(i)); |
271 } | 271 } |
272 assertEquals(expected, mBody.getInnerHTML()); | 272 assertEquals(expected, mBody.getInnerHTML()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 element = element.getNextSiblingElement(); | 395 element = element.getNextSiblingElement(); |
396 assertEquals(300*200, DomUtil.getArea(element)); | 396 assertEquals(300*200, DomUtil.getArea(element)); |
397 | 397 |
398 element = element.getNextSiblingElement(); | 398 element = element.getNextSiblingElement(); |
399 assertEquals(400*100, DomUtil.getArea(element)); | 399 assertEquals(400*100, DomUtil.getArea(element)); |
400 | 400 |
401 element = element.getFirstChildElement(); | 401 element = element.getFirstChildElement(); |
402 assertEquals(400*100, DomUtil.getArea(element)); | 402 assertEquals(400*100, DomUtil.getArea(element)); |
403 } | 403 } |
404 } | 404 } |
OLD | NEW |