| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.content.Context; | 7 import android.content.Context; |
| 8 import android.net.Uri; | 8 import android.net.Uri; |
| 9 import android.os.Environment; | 9 import android.os.Environment; |
| 10 import android.test.suitebuilder.annotation.MediumTest; | 10 import android.test.suitebuilder.annotation.MediumTest; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 private String getTitleOnUiThread() { | 72 private String getTitleOnUiThread() { |
| 73 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<String>
() { | 73 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<String>
() { |
| 74 @Override | 74 @Override |
| 75 public String call() throws Exception { | 75 public String call() throws Exception { |
| 76 return getActivity().getActivityTab().getTitle(); | 76 return getActivity().getActivityTab().getTitle(); |
| 77 } | 77 } |
| 78 }); | 78 }); |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Test that a content URL is allowed within a data URL. | 82 * Test that a content URL is not allowed within a data URL. |
| 83 */ | 83 */ |
| 84 @MediumTest | 84 @MediumTest |
| 85 @Feature({"Navigation"}) | 85 @Feature({"Navigation"}) |
| 86 public void testContentUrlFromData() throws InterruptedException { | 86 public void testContentUrlFromData() throws InterruptedException { |
| 87 final String target = "content_from_data"; | 87 final String target = "content_from_data"; |
| 88 resetResourceRequestCountInContentProvider(target); | 88 resetResourceRequestCountInContentProvider(target); |
| 89 loadUrl(UrlUtils.encodeHtmlDataUri( | 89 loadUrl(UrlUtils.encodeHtmlDataUri( |
| 90 "<img src=\"" + createContentUrl(target) + "\">")); | 90 "<img src=\"" + createContentUrl(target) + "\">")); |
| 91 ensureResourceRequestCountInContentProviderNotLessThan(target, 1); | 91 ensureResourceRequestCountInContentProvider(target, 0); |
| 92 } | 92 } |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Test that a content URL is allowed within a local file. | 95 * Test that a content URL is not allowed within a local file. |
| 96 */ | 96 */ |
| 97 @MediumTest | 97 @MediumTest |
| 98 @Feature({"Navigation"}) | 98 @Feature({"Navigation"}) |
| 99 public void testContentUrlFromFile() throws InterruptedException, IOExceptio
n { | 99 public void testContentUrlFromFile() throws InterruptedException, IOExceptio
n { |
| 100 final String target = "content_from_file"; | 100 final String target = "content_from_file"; |
| 101 final File file = new File(Environment.getExternalStorageDirectory(), ta
rget + ".html"); | 101 final File file = new File(Environment.getExternalStorageDirectory(), ta
rget + ".html"); |
| 102 try { | 102 try { |
| 103 TestFileUtil.createNewHtmlFile( | 103 TestFileUtil.createNewHtmlFile( |
| 104 file, target, "<img src=\"" + createContentUrl(target) + "\"
>"); | 104 file, target, "<img src=\"" + createContentUrl(target) + "\"
>"); |
| 105 resetResourceRequestCountInContentProvider(target); | 105 resetResourceRequestCountInContentProvider(target); |
| 106 loadUrl("file:///" + file.getAbsolutePath()); | 106 loadUrl("file:///" + file.getAbsolutePath()); |
| 107 ensureResourceRequestCountInContentProviderNotLessThan(target, 1); | 107 ensureResourceRequestCountInContentProvider(target, 0); |
| 108 } finally { | 108 } finally { |
| 109 TestFileUtil.deleteFile(file); | 109 TestFileUtil.deleteFile(file); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Test that the browser can be navigated to a file URL. | 114 * Test that the browser can be navigated to a file URL. |
| 115 */ | 115 */ |
| 116 @MediumTest | 116 @MediumTest |
| 117 @Feature({"Navigation"}) | 117 @Feature({"Navigation"}) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 private String createContentUrl(final String target) { | 160 private String createContentUrl(final String target) { |
| 161 return TestContentProvider.createContentUrl(target); | 161 return TestContentProvider.createContentUrl(target); |
| 162 } | 162 } |
| 163 | 163 |
| 164 @Override | 164 @Override |
| 165 public void startMainActivity() throws InterruptedException { | 165 public void startMainActivity() throws InterruptedException { |
| 166 startMainActivityFromLauncher(); | 166 startMainActivityFromLauncher(); |
| 167 } | 167 } |
| 168 } | 168 } |
| OLD | NEW |