OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
| 7 import android.support.test.filters.SmallTest; |
7 import android.test.InstrumentationTestCase; | 8 import android.test.InstrumentationTestCase; |
8 import android.test.suitebuilder.annotation.SmallTest; | |
9 | 9 |
10 import org.chromium.base.test.util.UrlUtils; | 10 import org.chromium.base.test.util.UrlUtils; |
11 | 11 |
12 import java.net.URI; | 12 import java.net.URI; |
13 import java.net.URLDecoder; | 13 import java.net.URLDecoder; |
14 | 14 |
15 public class EncodeHtmlDataUriTest extends InstrumentationTestCase { | 15 public class EncodeHtmlDataUriTest extends InstrumentationTestCase { |
16 private static final String DATA_URI_PREFIX = "data:text/html;utf-8,"; | 16 private static final String DATA_URI_PREFIX = "data:text/html;utf-8,"; |
17 | 17 |
18 private String getData(String dataUri) { | 18 private String getData(String dataUri) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 throws java.net.URISyntaxException, java.io.UnsupportedEncodingExcep
tion { | 55 throws java.net.URISyntaxException, java.io.UnsupportedEncodingExcep
tion { |
56 String testString = "<html><body onload=\"alert('Hello \\\"world\\\"');\
"></body></html>"; | 56 String testString = "<html><body onload=\"alert('Hello \\\"world\\\"');\
"></body></html>"; |
57 String encodedUri = UrlUtils.encodeHtmlDataUri(testString); | 57 String encodedUri = UrlUtils.encodeHtmlDataUri(testString); |
58 String decodedUri = decode(encodedUri); | 58 String decodedUri = decode(encodedUri); |
59 // Verify that the encoded URI is valid. | 59 // Verify that the encoded URI is valid. |
60 new URI(encodedUri); | 60 new URI(encodedUri); |
61 // Verify that something sensible was encoded. | 61 // Verify that something sensible was encoded. |
62 assertEquals("Simple HTML is not properly encoded", decodedUri, testStri
ng); | 62 assertEquals("Simple HTML is not properly encoded", decodedUri, testStri
ng); |
63 } | 63 } |
64 } | 64 } |
OLD | NEW |