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

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

Issue 946503002: Filter supported session types in createSession(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@export
Patch Set: Remove persistent-license syntax tests. Created 5 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 | Source/modules/encryptedmedia/MediaKeySystemAccess.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 assert_not_equals(sessionPromises.length, 0); 370 assert_not_equals(sessionPromises.length, 0);
371 return Promise.all(sessionPromises); 371 return Promise.all(sessionPromises);
372 }).then(function(result) { 372 }).then(function(result) {
373 test.done(); 373 test.done();
374 }).catch(function(error) { 374 }).catch(function(error) {
375 forceTestFailureFromPromise(test, error, 'generateRequest() tests failed'); 375 forceTestFailureFromPromise(test, error, 'generateRequest() tests failed');
376 }); 376 });
377 }, 'Test MediaKeys generateRequest() exceptions.'); 377 }, 'Test MediaKeys generateRequest() exceptions.');
378 378
379 // FIXME: Add tests for 'persistent-release-message' once supported.
380 var kLoadExceptionsTestCases = [ 379 var kLoadExceptionsTestCases = [
381 // Too few parameters. 380 // Too few parameters.
382 { 381 {
383 exception: 'TypeError', 382 exception: 'TypeError',
384 func: function(mk1) { return mk1.createSession('temporary'). load(); } 383 func: function(mk1) { return mk1.createSession('temporary'). load(); }
385 }, 384 },
386 {
387 exception: 'TypeError',
388 func: function(mk2) { return mk2.createSession('persistent-l icense').load(); }
389 },
390 // 'temporary' sessions are never allowed, so always return 385 // 'temporary' sessions are never allowed, so always return
391 // 'InvalidAccessError'. 386 // 'InvalidAccessError'.
392 { 387 {
393 exception: 'InvalidAccessError', 388 exception: 'InvalidAccessError',
394 func: function(mk3) { return mk3.createSession('temporary'). load(''); } 389 func: function(mk3) { return mk3.createSession('temporary'). load(''); }
395 }, 390 },
396 { 391 {
397 exception: 'InvalidAccessError', 392 exception: 'InvalidAccessError',
398 func: function(mk4) { return mk4.createSession('temporary'). load(1); } 393 func: function(mk4) { return mk4.createSession('temporary'). load(1); }
399 }, 394 },
400 { 395 {
401 exception: 'InvalidAccessError', 396 exception: 'InvalidAccessError',
402 func: function(mk5) { return mk5.createSession('temporary'). load('!@#$%^&*()'); } 397 func: function(mk5) { return mk5.createSession('temporary'). load('!@#$%^&*()'); }
403 }, 398 },
404 { 399 {
405 exception: 'InvalidAccessError', 400 exception: 'InvalidAccessError',
406 func: function(mk6) { return mk6.createSession('temporary'). load('1234'); } 401 func: function(mk6) { return mk6.createSession('temporary'). load('1234'); }
407 },
408 // Invalid parameters.
409 // For 'persistent' sessions, JS calls .toString() on the
410 // parameter if it is not already a string before passing it
411 // to code. So tests like mk8 or mk9 pass in "null" or
412 // "undefined" as the sessionId.
413 {
414 exception: 'InvalidAccessError',
415 func: function(mk7) { return mk7.createSession('persistent-l icense').load(''); }
416 },
417 {
418 exception: 'NotSupportedError',
419 func: function(mk8) { return mk8.createSession('persistent-l icense').load(null); }
420 },
421 {
422 exception: 'NotSupportedError',
423 func: function(mk9) { return mk9.createSession('persistent-l icense').load(undefined); }
424 },
425 {
426 exception: 'NotSupportedError',
427 func: function(mk10) { return mk10.createSession('persistent -license').load(1); }
428 },
429 {
430 exception: 'InvalidAccessError',
431 func: function(mk11) { return mk11.createSession('persistent -license').load(new Uint8Array(0)); }
432 },
433 // Invalid session id.
434 {
435 exception: 'InvalidAccessError',
436 func: function(mk12) { return mk12.createSession('persistent -license').load('!@#$%^&*()'); }
437 },
438 // Valid session id (but not supported by Clear Key).
439 {
440 exception: 'NotSupportedError',
441 func: function(mk13) { return mk13.createSession('persistent -license').load('1234'); }
442 } 402 }
443 ]; 403 ];
444 404
445 async_test(function(test) 405 async_test(function(test)
446 { 406 {
447 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { 407 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) {
448 return access.createMediaKeys(); 408 return access.createMediaKeys();
449 }).then(function(mediaKeys) { 409 }).then(function(mediaKeys) {
450 var initData = stringToUint8Array('init data'); 410 var initData = stringToUint8Array('init data');
451 var sessionPromises = kLoadExceptionsTestCases.map(function( testCase) { 411 var sessionPromises = kLoadExceptionsTestCases.map(function( testCase) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 forceTestFailureFromPromise(test, error, 'close() tests fail ed'); 737 forceTestFailureFromPromise(test, error, 'close() tests fail ed');
778 }); 738 });
779 }, 'Test MediaKeySession close().'); 739 }, 'Test MediaKeySession close().');
780 740
781 function create_remove_exception_test(mediaKeys, type, initData) 741 function create_remove_exception_test(mediaKeys, type, initData)
782 { 742 {
783 // remove() on an uninitialized session should fail. 743 // remove() on an uninitialized session should fail.
784 var mediaKeySession = mediaKeys.createSession('temporary'); 744 var mediaKeySession = mediaKeys.createSession('temporary');
785 return mediaKeySession.remove().then(function(result) { 745 return mediaKeySession.remove().then(function(result) {
786 assert_unreached('remove() should not succeed if session uni nitialized'); 746 assert_unreached('remove() should not succeed if session uni nitialized');
787 }).catch(function(error) { 747 }, function(error) {
788 assert_equals(error.name, 'InvalidStateError'); 748 assert_equals(error.name, 'InvalidStateError');
789 749
790 // remove() on a temporary session should fail. 750 // remove() on a temporary session should fail.
791 return mediaKeySession.generateRequest(type, initData); 751 return mediaKeySession.generateRequest(type, initData);
792 }).then(function(result) { 752 }).then(function(result) {
793 return mediaKeySession.remove(); 753 return mediaKeySession.remove();
794 }).then(function(result) { 754 }).then(function(result) {
795 assert_unreached('remove() should not succeed for temporary sessions'); 755 assert_unreached('remove() should not succeed for temporary sessions');
796 }).catch(function(error) { 756 }, function(error) {
797 assert_equals(error.name, 'InvalidAccessError'); 757 assert_equals(error.name, 'InvalidAccessError');
ddorwin 2015/02/20 22:26:57 We should at least have tests that we get NotSuppo
798
799 // remove() on a closed persistent-license session should al so fail.
800 mediaKeySession = mediaKeys.createSession('persistent-licens e');
801 return mediaKeySession.generateRequest(type, initData);
802 }).then(function(result) {
803 return mediaKeySession.close();
804 }).then(function(result) {
805 return mediaKeySession.remove();
806 }).then(function(result) {
807 assert_unreached('remove() should not succeed for closed per sistent-license sessions');
808 }).catch(function(error) {
809 assert_equals(error.name, 'InvalidStateError');
810
811 // Add test for persistent-release-message once supported.
812
813 // Return something so the promise resolves.
814 return Promise.resolve();
815 }); 758 });
816 } 759 }
817 760
818 async_test(function(test) 761 async_test(function(test)
819 { 762 {
820 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) { 763 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).t hen(function(access) {
821 return access.createMediaKeys(); 764 return access.createMediaKeys();
822 }).then(function(mediaKeys) { 765 }).then(function(mediaKeys) {
823 var promises = []; 766 var promises = [];
824 767
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 882
940 // FIXME: Add test for successful setServerCertificate(). Note that 883 // FIXME: Add test for successful setServerCertificate(). Note that
941 // Clear Key does not support it. 884 // Clear Key does not support it.
942 885
943 // FIXME: Add syntax checks for MediaKeys.IsTypeSupported(). 886 // FIXME: Add syntax checks for MediaKeys.IsTypeSupported().
944 // FIXME: Add syntax checks for MediaKeyError and MediaKeySession ev ents. 887 // FIXME: Add syntax checks for MediaKeyError and MediaKeySession ev ents.
945 // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, med iakeys, onencrypted. 888 // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, med iakeys, onencrypted.
946 </script> 889 </script>
947 </body> 890 </body>
948 </html> 891 </html>
OLDNEW
« no previous file with comments | « no previous file | Source/modules/encryptedmedia/MediaKeySystemAccess.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698