Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/KeySystemTest.java

Issue 2678433003: media: Require SecureContext for EME APIs (Closed)
Patch Set: rebase only Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | android_webview/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
54 getKeySystemTestPage(), "text/html", false); 54 "file:///android_asset/key-system-test.html");
55 }
56
57 private String getKeySystemTestPage() {
58 // requestMediaKeySystemAccess() provides 2 different configurations
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 } 55 }
84 56
85 private String isKeySystemSupported(String keySystem) throws Exception { 57 private String isKeySystemSupported(String keySystem) throws Exception {
86 executeJavaScriptAndWaitForResult( 58 executeJavaScriptAndWaitForResult(
87 mAwContents, mContentsClient, "isKeySystemSupported('" + keySyst em + "')"); 59 mAwContents, mContentsClient, "isKeySystemSupported('" + keySyst em + "')");
88 60
89 pollInstrumentationThread(new Callable<Boolean>() { 61 pollInstrumentationThread(new Callable<Boolean>() {
90 @Override 62 @Override
91 public Boolean call() throws Exception { 63 public Boolean call() throws Exception {
92 return !getResultFromJS().equals("null"); 64 return !getResultFromJS().equals("null");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 assertEquals(getPlatformKeySystemExpectations(), 122 assertEquals(getPlatformKeySystemExpectations(),
151 isKeySystemSupported("x-com.oem.test-keysystem")); 123 isKeySystemSupported("x-com.oem.test-keysystem"));
152 } 124 }
153 125
154 @Feature({"AndroidWebView"}) 126 @Feature({"AndroidWebView"})
155 @SmallTest 127 @SmallTest
156 public void testSupportPlatformKeySystemNoPrefix() throws Throwable { 128 public void testSupportPlatformKeySystemNoPrefix() throws Throwable {
157 assertEquals("\"NotSupportedError\"", isKeySystemSupported("com.oem.test -keysystem")); 129 assertEquals("\"NotSupportedError\"", isKeySystemSupported("com.oem.test -keysystem"));
158 } 130 }
159 } 131 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698