Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.test.InstrumentationTestCase; | 7 import android.test.InstrumentationTestCase; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 9 | 9 |
| 10 import org.chromium.base.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 97 |
| 98 uri = URI.create("chrome://settings:443"); | 98 uri = URI.create("chrome://settings:443"); |
| 99 assertEquals("chrome://settings:443", UrlUtilities.getOriginForDisplay(u ri, true)); | 99 assertEquals("chrome://settings:443", UrlUtilities.getOriginForDisplay(u ri, true)); |
| 100 assertEquals("settings:443", UrlUtilities.getOriginForDisplay(uri, false )); | 100 assertEquals("settings:443", UrlUtilities.getOriginForDisplay(uri, false )); |
| 101 | 101 |
| 102 uri = URI.create("about:blank"); | 102 uri = URI.create("about:blank"); |
| 103 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, true)) ; | 103 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, true)) ; |
| 104 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, false) ); | 104 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, false) ); |
| 105 } | 105 } |
| 106 | 106 |
| 107 @SmallTest | |
| 108 public void testValidateIntentUrl() { | |
| 109 String[] expectedTrue = { | |
| 110 "intent://10010#Intent;scheme=tel;action=com.google.android.apps." | |
| 111 + "authenticator.AUTHENTICATE;end", | |
| 112 "intent://scan/#Intent;package=com.google.zxing.client.android;" | |
| 113 + "scheme=zxing;end;", | |
| 114 "intent://wump-hey.example.com/#Intent;package=com.example.wump;" | |
| 115 + "scheme=yow;component=com.example.PUMPKIN;end;", | |
| 116 "intent://wump_hey.example.com/#Intent;package=com.example.wump;" | |
|
Yaron
2015/04/24 20:38:17
Please add a test with extras
| |
| 117 + "scheme=eeek;action=frighten_children;end;" | |
| 118 }; | |
| 119 | |
| 120 for (int i = 0; i < expectedTrue.length; ++i) { | |
| 121 assertTrue(UrlUtilities.validateIntentUrl(expectedTrue[i])); | |
| 122 } | |
| 123 | |
| 124 String[] expectedFalse = { | |
| 125 // Junk after end. | |
| 126 "intent://10010#Intent;scheme=tel;action=com.google.android.apps." | |
| 127 + "authenticator.AUTHENTICATE;end','*');" | |
| 128 + "alert(document.cookie);//", | |
| 129 // component appears twice. | |
| 130 "intent://wump-hey.example.com/#Intent;package=com.example.wump;" | |
| 131 + "scheme=yow;component=com.example.PUMPKIN;" | |
| 132 + "component=com.example.AVOCADO;end;", | |
| 133 // scheme contains illegal character. | |
| 134 "intent://wump-hey.example.com/#Intent;package=com.example.wump;" | |
| 135 + "scheme=hello+goodbye;component=com.example.PUMPKIN;end;", | |
| 136 // category contains illegal character. | |
| 137 "intent://wump-hey.example.com/#Intent;package=com.example.wump;" | |
| 138 + "category=42%_by_volume;end" | |
| 139 }; | |
| 140 | |
| 141 for (int i = 0; i < expectedFalse.length; ++i) { | |
| 142 assertFalse(UrlUtilities.validateIntentUrl(expectedFalse[i])); | |
| 143 } | |
| 144 } | |
| 145 | |
| 107 } | 146 } |
| OLD | NEW |