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

Side by Side Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-syntax.html

Issue 2056053003: Change MediaKeys.setServerCertificate() to return Promise<boolean> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve false Created 4 years, 6 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test EME syntax</title> 4 <title>Test EME syntax</title>
5 <script src="encrypted-media-utils.js"></script> 5 <script src="encrypted-media-utils.js"></script>
6 <script src="../../resources/testharness.js"></script> 6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script> 7 <script src="../../resources/testharnessreport.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <div id="log"></div> 10 <div id="log"></div>
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 func: function(mk) { return mk.setServerCertificate(undefine d); } 929 func: function(mk) { return mk.setServerCertificate(undefine d); }
930 }, 930 },
931 { 931 {
932 exception: 'TypeError', 932 exception: 'TypeError',
933 func: function(mk) { return mk.setServerCertificate(1); } 933 func: function(mk) { return mk.setServerCertificate(1); }
934 }, 934 },
935 // Empty array. 935 // Empty array.
936 { 936 {
937 exception: 'InvalidAccessError', 937 exception: 'InvalidAccessError',
938 func: function(mk) { return mk.setServerCertificate(new Uint 8Array(0)); } 938 func: function(mk) { return mk.setServerCertificate(new Uint 8Array(0)); }
939 },
940 // Valid calls, but not supported by Clear Key.
941 {
942 exception: 'NotSupportedError',
943 func: function(mk) { var cert = new Uint8Array(200); assert_ true(ArrayBuffer.isView(cert)); return mk.setServerCertificate(cert); }
944 },
945 {
946 // Pass in ArrayBuffer
947 exception: 'NotSupportedError',
948 func: function(mk) { var cert = new Uint8Array(200); assert_ false(ArrayBuffer.isView(cert.buffer)); return mk.setServerCertificate(cert.buff er); }
949 } 939 }
950 ]; 940 ];
951 941
952 async_test(function(test) 942 async_test(function(test)
953 { 943 {
954 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { 944 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) {
955 return access.createMediaKeys(); 945 return access.createMediaKeys();
956 }).then(function(mediaKeys) { 946 }).then(function(mediaKeys) {
957 var promises = kSetServerCertificateExceptionsTestCases.map( function(testCase) { 947 var promises = kSetServerCertificateExceptionsTestCases.map( function(testCase) {
958 return test_exception(testCase, mediaKeys); 948 return test_exception(testCase, mediaKeys);
959 }); 949 });
960 950
961 assert_not_equals(promises.length, 0); 951 assert_not_equals(promises.length, 0);
962 return Promise.all(promises); 952 return Promise.all(promises);
963 }).then(function(result) { 953 }).then(function(result) {
964 test.done(); 954 test.done();
965 }).catch(function(error) { 955 }).catch(function(error) {
966 forceTestFailureFromPromise(test, error, 'setServerCertifica te() exception tests failed'); 956 forceTestFailureFromPromise(test, error, 'setServerCertifica te() exception tests failed');
967 }); 957 });
968 }, 'Test MediaKeys setServerCertificate() exceptions.'); 958 }, 'Test MediaKeys setServerCertificate() exceptions.');
969 959
970 // FIXME: Add test for successful setServerCertificate(). Note that 960 // All calls to |func| in this group are expected to resolve.
971 // Clear Key does not support it. 961 var kSetServerCertificateTestCases = [
962 {
963 // Pass in ArrayBufferView
964 func: function(mk) {
965 var cert = new Uint8Array(200);
966 assert_true(ArrayBuffer.isView(cert));
967 return mk.setServerCertificate(cert);
968 }
969 },
970 {
971 // Pass in ArrayBuffer
972 func: function(mk) {
973 var cert = new Uint8Array(200);
974 assert_false(ArrayBuffer.isView(cert.buffer));
ddorwin 2016/06/13 17:28:09 What does isView() of the buffer tell us? Aren't w
jrummell 2016/06/13 18:54:13 isView() tells us that cert.buffer is not an Array
975 return mk.setServerCertificate(cert.buffer);
976 }
977 }
978 ];
979
980 function test_setServerCertificate(testCase, mediaKeys)
981 {
982 // As Clear Key does not support setServerCertificate(),
983 // successful calls should return false.
984 return testCase.func.call(null, mediaKeys).then(function(result) {
985 assert_false(result);
986 });
987 }
988
989 async_test(function(test)
990 {
991 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) {
ddorwin 2016/06/13 17:28:09 FYI, an empty configuration is no longer allowed b
jrummell 2016/06/13 18:54:13 Acknowledged. I'll do a subsequent CL to handle th
992 return access.createMediaKeys();
993 }).then(function(mediaKeys) {
994 var promises = kSetServerCertificateTestCases.map(function(t estCase) {
995 return test_setServerCertificate(testCase, mediaKeys);
996 });
997
998 assert_not_equals(promises.length, 0);
999 return Promise.all(promises);
1000 }).then(function(result) {
1001 test.done();
ddorwin 2016/06/13 17:28:09 We don't check the result. What is the result for
jrummell 2016/06/13 18:54:13 It returns an array of the results from each promi
1002 }).catch(function(error) {
1003 forceTestFailureFromPromise(test, error, 'setServerCertifica te() test failed');
1004 });
1005 }, 'Test MediaKeys setServerCertificate().');
1006
972 1007
973 // FIXME: Add syntax checks for MediaKeys.IsTypeSupported(). 1008 // FIXME: Add syntax checks for MediaKeys.IsTypeSupported().
974 // FIXME: Add syntax checks for MediaKeyError and MediaKeySession ev ents. 1009 // FIXME: Add syntax checks for MediaKeyError and MediaKeySession ev ents.
975 // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, med iakeys, onencrypted. 1010 // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, med iakeys, onencrypted.
976 </script> 1011 </script>
977 </body> 1012 </body>
978 </html> 1013 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698