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.android_webview.test; | 5 package org.chromium.android_webview.test; |
6 | 6 |
7 import android.os.Build; | 7 import android.os.Build; |
8 import android.support.test.filters.SmallTest; | 8 import android.support.test.filters.SmallTest; |
9 | 9 |
10 import org.chromium.android_webview.AwContents; | 10 import org.chromium.android_webview.AwContents; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 | 43 |
44 @Override | 44 @Override |
45 protected void setUp() throws Exception { | 45 protected void setUp() throws Exception { |
46 super.setUp(); | 46 super.setUp(); |
47 | 47 |
48 final AwTestContainerView testContainerView = | 48 final AwTestContainerView testContainerView = |
49 createAwTestContainerViewOnMainSync(mContentsClient); | 49 createAwTestContainerViewOnMainSync(mContentsClient); |
50 mAwContents = testContainerView.getAwContents(); | 50 mAwContents = testContainerView.getAwContents(); |
51 enableJavaScriptOnUiThread(mAwContents); | 51 enableJavaScriptOnUiThread(mAwContents); |
52 | 52 |
53 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), | 53 // Treat file:/// as secure context, which is required by EME APIs. |
54 getKeySystemTestPage(), "text/html", false); | 54 allowFileAccessFromFileURLs(mAwContents); |
Torne
2017/02/07 11:24:54
Several questions here:
1) I don't get why allowF
xhwang
2017/02/07 18:43:56
I think you are right. I had a misunderstanding of
| |
55 } | |
56 | 55 |
57 private String getKeySystemTestPage() { | 56 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), |
58 // requestMediaKeySystemAccess() provides 2 different configurations | 57 "file:///android_asset/key-system-test.html"); |
59 // as encrypted webm is only supported on Lollipop+. mp4 is proprietary, | |
60 // and may not be supported on all Android devices. | |
61 return "<html> <script>" | |
62 + "var result;" | |
63 + "function success(keySystemAccess) {" | |
64 + " result = 'supported';" | |
65 + "}" | |
66 + "function failure(error){" | |
67 + " result = error.name;" | |
68 + "}" | |
69 + "function isKeySystemSupported(keySystem) {" | |
70 + " navigator.requestMediaKeySystemAccess(" | |
71 + " keySystem, " | |
72 + " [{audioCapabilities:" | |
73 + " [{contentType: 'audio/webm; codec=\"vorbis\"'}]}, " | |
74 + " {videoCapabilities:" | |
75 + " [{contentType: 'video/mp4; codecs=\"avc1.4D000C\"'}] }])" | |
76 + " .then(success, failure);" | |
77 + "}" | |
78 + "function areProprietaryCodecsSupported() {" | |
79 + " var video = document.createElement('video');" | |
80 + " return video.canPlayType('video/mp4; codecs=\"avc1\"');" | |
81 + "}" | |
82 + "</script> </html>"; | |
83 } | 58 } |
84 | 59 |
85 private String isKeySystemSupported(String keySystem) throws Exception { | 60 private String isKeySystemSupported(String keySystem) throws Exception { |
86 executeJavaScriptAndWaitForResult( | 61 executeJavaScriptAndWaitForResult( |
87 mAwContents, mContentsClient, "isKeySystemSupported('" + keySyst em + "')"); | 62 mAwContents, mContentsClient, "isKeySystemSupported('" + keySyst em + "')"); |
88 | 63 |
89 pollInstrumentationThread(new Callable<Boolean>() { | 64 pollInstrumentationThread(new Callable<Boolean>() { |
90 @Override | 65 @Override |
91 public Boolean call() throws Exception { | 66 public Boolean call() throws Exception { |
92 return !getResultFromJS().equals("null"); | 67 return !getResultFromJS().equals("null"); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 assertEquals(getPlatformKeySystemExpectations(), | 125 assertEquals(getPlatformKeySystemExpectations(), |
151 isKeySystemSupported("x-com.oem.test-keysystem")); | 126 isKeySystemSupported("x-com.oem.test-keysystem")); |
152 } | 127 } |
153 | 128 |
154 @Feature({"AndroidWebView"}) | 129 @Feature({"AndroidWebView"}) |
155 @SmallTest | 130 @SmallTest |
156 public void testSupportPlatformKeySystemNoPrefix() throws Throwable { | 131 public void testSupportPlatformKeySystemNoPrefix() throws Throwable { |
157 assertEquals("\"NotSupportedError\"", isKeySystemSupported("com.oem.test -keysystem")); | 132 assertEquals("\"NotSupportedError\"", isKeySystemSupported("com.oem.test -keysystem")); |
158 } | 133 } |
159 } | 134 } |
OLD | NEW |