Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| 11 <script> | 11 <script> |
| 12 // Since promises catch any exception and convert it into a | |
| 13 // rejected Promise, there is no current way to have the W3C | |
| 14 // test framework report a failed test. For now, simply force | |
| 15 // a timeout to indicate failure. | |
| 16 // FIXME: Once W3C test framework handles Promises, fix this. | |
| 17 | |
| 12 // This function checks that calling |testCase.func| returns a | 18 // This function checks that calling |testCase.func| returns a |
| 13 // rejected Promise with the error.name equal to | 19 // rejected Promise with the error.name equal to |
| 14 // |testCase.exception|. | 20 // |testCase.exception|. |
| 15 function test_exception(testCase /*...*/) | 21 function test_exception(testCase /*...*/) |
| 16 { | 22 { |
| 17 var func = testCase.func; | 23 var func = testCase.func; |
| 18 var exception = testCase.exception; | 24 var exception = testCase.exception; |
| 19 var args = Array.prototype.slice.call(arguments, 1); | 25 var args = Array.prototype.slice.call(arguments, 1); |
| 20 | 26 |
| 21 // Currently blink throws for TypeErrors rather than returning | 27 // Currently blink throws for TypeErrors rather than returning |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 34 } | 40 } |
| 35 ); | 41 ); |
| 36 } catch (e) { | 42 } catch (e) { |
| 37 // Only allow 'TypeError' exceptions to be thrown. | 43 // Only allow 'TypeError' exceptions to be thrown. |
| 38 // Everything else should be a failed promise. | 44 // Everything else should be a failed promise. |
| 39 assert_equals('TypeError', exception, format_value(func)); | 45 assert_equals('TypeError', exception, format_value(func)); |
| 40 assert_equals(e.name, exception, format_value(func)); | 46 assert_equals(e.name, exception, format_value(func)); |
| 41 } | 47 } |
| 42 } | 48 } |
| 43 | 49 |
| 44 var kCreateMediaKeysExceptionsTestCases = [ | 50 var kRequestMediaKeySystemAccessExceptionsTestCases = [ |
| 45 // Too few parameters. | 51 // Too few parameters. |
| 46 { | 52 { |
| 47 exception: 'TypeError', | 53 exception: 'TypeError', |
| 48 func: function() { return MediaKeys.create(); } | 54 func: function() { return navigator.requestMediaKeySystemAcc ess(); } |
| 49 }, | 55 }, |
| 50 // Invalid parameters. | 56 // Invalid parameters. |
| 51 { | 57 { |
| 52 exception: 'InvalidAccessError', | 58 exception: 'InvalidAccessError', |
| 53 func: function() { return MediaKeys.create(''); } | 59 func: function() { return navigator.requestMediaKeySystemAcc ess(''); } |
| 54 }, | 60 }, |
| 55 // Invalid key systems. | 61 // Invalid key systems. Note that JavaScript converts all these |
| 62 // values into strings by calling toString(), so they fail due | |
| 63 // to the key system not being supported, not due to the type. | |
| 56 { | 64 { |
| 57 exception: 'NotSupportedError', | 65 exception: 'NotSupportedError', |
| 58 func: function() { return MediaKeys.create(null); } | 66 func: function() { return navigator.requestMediaKeySystemAcc ess(null); } |
| 59 }, | 67 }, |
| 60 { | 68 { |
| 61 exception: 'NotSupportedError', | 69 exception: 'NotSupportedError', |
| 62 func: function() { return MediaKeys.create(undefined); } | 70 func: function() { return navigator.requestMediaKeySystemAcc ess(undefined); } |
| 63 }, | 71 }, |
| 64 { | 72 { |
| 65 exception: 'NotSupportedError', | 73 exception: 'NotSupportedError', |
| 66 func: function() { return MediaKeys.create(1); } | 74 func: function() { return navigator.requestMediaKeySystemAcc ess(1); } |
| 67 }, | 75 }, |
| 68 { | 76 { |
| 69 exception: 'NotSupportedError', | 77 exception: 'NotSupportedError', |
| 70 func: function() { return MediaKeys.create(new Uint8Array(0) ); } | 78 func: function() { return navigator.requestMediaKeySystemAcc ess(new Uint8Array(0)); } |
| 71 }, | 79 }, |
| 72 { | 80 { |
| 73 exception: 'NotSupportedError', | 81 exception: 'NotSupportedError', |
| 74 func: function() { return MediaKeys.create('unsupported'); } | 82 func: function() { return navigator.requestMediaKeySystemAcc ess('unsupported'); } |
| 75 }, | 83 }, |
| 76 // Non-ASCII names. | 84 // Non-ASCII names. |
| 77 { | 85 { |
| 78 exception: 'NotSupportedError', | 86 exception: 'NotSupportedError', |
| 79 func: function() { return MediaKeys.create('org.w3\u263A.cle arkey'); } | 87 func: function() { return navigator.requestMediaKeySystemAcc ess('org.w3\u263A.clearkey'); } |
| 80 } | 88 } |
| 81 ]; | 89 ]; |
| 82 | 90 |
| 83 async_test(function(test) | 91 async_test(function(test) |
| 84 { | 92 { |
| 85 // Since promises catch any exception and convert it into a | 93 var createPromises = kRequestMediaKeySystemAccessExceptionsTestC ases.map(function(testCase) { |
| 86 // rejected Promise, there is no current way to have the W3C | |
| 87 // test framework report a failed test. For now, simply force | |
| 88 // a timeout to indicate failure. | |
| 89 // FIXME: Once W3C test framework handles Promises, fix this. | |
| 90 | |
| 91 var createPromises = kCreateMediaKeysExceptionsTestCases.map(fun ction(testCase) { | |
| 92 return test_exception(testCase); | 94 return test_exception(testCase); |
| 93 }); | 95 }); |
| 94 | 96 |
| 95 Promise.all(createPromises).then(function(result) { | 97 Promise.all(createPromises).then(function(result) { |
| 96 test.done(); | 98 test.done(); |
| 97 }).catch(function(error) { | 99 }).catch(function(error) { |
| 98 forceTestFailureFromPromise(test, error, 'create() tests fai led'); | 100 forceTestFailureFromPromise(test, error, 'requestMediaKeySys temAccess() tests failed'); |
| 99 }); | 101 }); |
| 100 }, 'Test MediaKeys create() exceptions.'); | 102 }, 'Test Navigator.requestMediaKeySystemAccess() exceptions.'); |
| 101 | 103 |
| 102 async_test(function(test) | 104 async_test(function(test) |
| 103 { | 105 { |
| 104 assert_equals(typeof window.MediaKeys, 'function'); | 106 assert_equals(typeof navigator.requestMediaKeySystemAccess, 'fun ction'); |
| 105 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 107 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 108 assert_not_equals(access, null); | |
| 109 assert_equals(typeof access, 'object'); | |
| 110 assert_equals(access.keySystem, 'org.w3.clearkey'); | |
| 111 assert_equals(typeof access.createMediaKeys, 'function'); | |
| 112 test.done(); | |
| 113 }).catch(function(error) { | |
| 114 forceTestFailureFromPromise(test, error, 'requestMediaKeySys temAccess() tests failed'); | |
| 115 }); | |
| 116 }, 'Test Navigator.requestMediaKeySystemAccess().'); | |
| 117 | |
| 118 async_test(function(test) | |
| 119 { | |
| 120 var access; | |
| 121 | |
| 122 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(result) { | |
| 123 access = result; | |
| 124 assert_equals(access.keySystem, 'org.w3.clearkey'); | |
| 125 return access.createMediaKeys(); | |
| 126 }).then(function(mediaKeys) { | |
| 106 assert_not_equals(mediaKeys, null); | 127 assert_not_equals(mediaKeys, null); |
| 128 assert_equals(typeof mediaKeys, 'object'); | |
| 129 assert_equals(typeof mediaKeys.createSession, 'function'); | |
| 130 assert_equals(typeof mediaKeys.setServerCertificate, 'functi on'); | |
| 107 | 131 |
| 108 // Test creation of a second MediaKeys. | 132 // Test creation of a second MediaKeys. |
|
ddorwin
2014/10/23 23:32:01
We should probably add tests to test the creation
jrummell
2014/10/24 22:43:22
Added to bug.
| |
| 109 // The extra parameter is ignored. | 133 // The extra parameter is ignored. |
| 110 return MediaKeys.create('org.w3.clearkey', 'extra'); | 134 return access.createMediaKeys('extra'); |
| 111 }).then(function(mediaKeys) { | 135 }).then(function(mediaKeys) { |
| 112 assert_not_equals(mediaKeys, null); | 136 assert_not_equals(mediaKeys, null); |
| 113 assert_equals(typeof mediaKeys, 'object'); | 137 assert_equals(typeof mediaKeys, 'object'); |
| 114 assert_equals(mediaKeys.keySystem, 'org.w3.clearkey'); | |
| 115 assert_equals(typeof mediaKeys.createSession, 'function'); | 138 assert_equals(typeof mediaKeys.createSession, 'function'); |
| 116 assert_equals(typeof mediaKeys.addEventListener, 'undefined' ); | 139 assert_equals(typeof mediaKeys.setServerCertificate, 'functi on'); |
| 117 test.done(); | 140 test.done(); |
| 118 }).catch(function(error) { | 141 }).catch(function(error) { |
| 119 forceTestFailureFromPromise(test, error, 'create() tests fai led'); | 142 forceTestFailureFromPromise(test, error, 'create() tests fai led'); |
| 120 }); | 143 }); |
| 121 }, 'Test MediaKeys create().'); | 144 }, 'Test MediaKeys create().'); |
| 122 | 145 |
| 123 var kCreateSessionExceptionsTestCases = [ | 146 var kCreateSessionExceptionsTestCases = [ |
| 124 // Tests in this set use a shortened parameter name due to | 147 // Tests in this set use a shortened parameter name due to |
| 125 // format_value() only returning the first 60 characters as the | 148 // format_value() only returning the first 60 characters as the |
| 126 // result. With a longer name the first 60 characters is not | 149 // result. With a longer name the first 60 characters is not |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 152 func: function(mk) { return mk.createSession(new Uint8Array( 0)); } | 175 func: function(mk) { return mk.createSession(new Uint8Array( 0)); } |
| 153 }, | 176 }, |
| 154 { | 177 { |
| 155 exception: 'TypeError', | 178 exception: 'TypeError', |
| 156 func: function(mk) { return mk.createSession('TEMPORARY'); } | 179 func: function(mk) { return mk.createSession('TEMPORARY'); } |
| 157 } | 180 } |
| 158 ]; | 181 ]; |
| 159 | 182 |
| 160 async_test(function(test) | 183 async_test(function(test) |
| 161 { | 184 { |
| 162 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 185 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 186 return access.createMediaKeys(); | |
| 187 }).then(function(mediaKeys) { | |
| 163 var sessionPromises = kCreateSessionExceptionsTestCases.map( function(testCase) { | 188 var sessionPromises = kCreateSessionExceptionsTestCases.map( function(testCase) { |
| 164 return test_exception(testCase, mediaKeys); | 189 return test_exception(testCase, mediaKeys); |
| 165 }); | 190 }); |
| 166 | 191 |
| 167 assert_not_equals(sessionPromises.length, 0); | 192 assert_not_equals(sessionPromises.length, 0); |
| 168 return Promise.all(sessionPromises); | 193 return Promise.all(sessionPromises); |
| 169 }).then(function(result) { | 194 }).then(function(result) { |
| 170 test.done(); | 195 test.done(); |
| 171 }).catch(function(error) { | 196 }).catch(function(error) { |
| 172 forceTestFailureFromPromise(test, error, 'createSession() te sts failed'); | 197 forceTestFailureFromPromise(test, error, 'createSession() te sts failed'); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 func: function(mk5, type) { return mk5.createSession().gener ateRequest(type, 1); } | 307 func: function(mk5, type) { return mk5.createSession().gener ateRequest(type, 1); } |
| 283 }, | 308 }, |
| 284 { | 309 { |
| 285 exception: 'InvalidAccessError', | 310 exception: 'InvalidAccessError', |
| 286 func: function(mk6, type) { return mk6.createSession().gener ateRequest(type, new Uint8Array(0)); } | 311 func: function(mk6, type) { return mk6.createSession().gener ateRequest(type, new Uint8Array(0)); } |
| 287 } | 312 } |
| 288 ]; | 313 ]; |
| 289 | 314 |
| 290 async_test(function(test) | 315 async_test(function(test) |
| 291 { | 316 { |
| 292 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 317 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 318 return access.createMediaKeys(); | |
| 319 }).then(function(mediaKeys) { | |
| 293 // FIXME: Remove "video/" from the calls to isTypeSupported( ) once it is updated. | 320 // FIXME: Remove "video/" from the calls to isTypeSupported( ) once it is updated. |
| 294 // http://crbug.com/405731. | 321 // http://crbug.com/405731. |
| 295 var initData = stringToUint8Array('init data'); | 322 var initData = stringToUint8Array('init data'); |
| 296 var sessionPromises = kGenerateRequestExceptionsTestCases.ma p(function(testCase) { | 323 var sessionPromises = kGenerateRequestExceptionsTestCases.ma p(function(testCase) { |
| 297 return test_exception(testCase, mediaKeys, '', initData) ; | 324 return test_exception(testCase, mediaKeys, '', initData) ; |
| 298 }); | 325 }); |
| 299 | 326 |
| 300 // Test that WebM sessions generate the expected error, if | 327 // Test that WebM sessions generate the expected error, if |
| 301 // supported. | 328 // supported. |
| 302 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { | 329 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 func: function(mk15) { return mk15.createSession('temporary' ).load('1234'); } | 421 func: function(mk15) { return mk15.createSession('temporary' ).load('1234'); } |
| 395 }, | 422 }, |
| 396 { | 423 { |
| 397 exception: 'NotSupportedError', | 424 exception: 'NotSupportedError', |
| 398 func: function(mk16) { return mk16.createSession('persistent ').load('1234'); } | 425 func: function(mk16) { return mk16.createSession('persistent ').load('1234'); } |
| 399 } | 426 } |
| 400 ]; | 427 ]; |
| 401 | 428 |
| 402 async_test(function(test) | 429 async_test(function(test) |
| 403 { | 430 { |
| 404 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 431 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 432 return access.createMediaKeys(); | |
| 433 }).then(function(mediaKeys) { | |
| 405 // FIXME: Remove "video/" from the calls to isTypeSupported( ) once it is updated. | 434 // FIXME: Remove "video/" from the calls to isTypeSupported( ) once it is updated. |
| 406 // http://crbug.com/405731. | 435 // http://crbug.com/405731. |
| 407 var initData = stringToUint8Array('init data'); | 436 var initData = stringToUint8Array('init data'); |
| 408 var sessionPromises = kLoadExceptionsTestCases.map(function( testCase) { | 437 var sessionPromises = kLoadExceptionsTestCases.map(function( testCase) { |
| 409 return test_exception(testCase, mediaKeys); | 438 return test_exception(testCase, mediaKeys); |
| 410 }); | 439 }); |
| 411 | 440 |
| 412 assert_not_equals(sessionPromises.length, 0); | 441 assert_not_equals(sessionPromises.length, 0); |
| 413 return Promise.all(sessionPromises); | 442 return Promise.all(sessionPromises); |
| 414 }).then(function(result) { | 443 }).then(function(result) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 assert_equals(mediaKeySession.sessionId, ''); | 508 assert_equals(mediaKeySession.sessionId, ''); |
| 480 assert_equals(typeof mediaKeySession.sessionId, 'string'); | 509 assert_equals(typeof mediaKeySession.sessionId, 'string'); |
| 481 assert_equals(typeof mediaKeySession.onopen, 'undefined'); | 510 assert_equals(typeof mediaKeySession.onopen, 'undefined'); |
| 482 assert_equals(typeof mediaKeySession.onmessage, 'undefined'); | 511 assert_equals(typeof mediaKeySession.onmessage, 'undefined'); |
| 483 assert_equals(typeof mediaKeySession.onclose, 'undefined'); | 512 assert_equals(typeof mediaKeySession.onclose, 'undefined'); |
| 484 assert_equals(typeof mediaKeySession.onerror, 'undefined'); | 513 assert_equals(typeof mediaKeySession.onerror, 'undefined'); |
| 485 } | 514 } |
| 486 | 515 |
| 487 async_test(function(test) | 516 async_test(function(test) |
| 488 { | 517 { |
| 489 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 518 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 519 return access.createMediaKeys(); | |
| 520 }).then(function(mediaKeys) { | |
| 490 kCreateSessionTestCases.map(function(testCase) { | 521 kCreateSessionTestCases.map(function(testCase) { |
| 491 test_createSession(testCase, mediaKeys); | 522 test_createSession(testCase, mediaKeys); |
| 492 }); | 523 }); |
| 493 test.done(); | 524 test.done(); |
| 494 }).catch(function(error) { | 525 }).catch(function(error) { |
| 495 forceTestFailureFromPromise(test, error, 'createSession() te sts failed'); | 526 forceTestFailureFromPromise(test, error, 'createSession() te sts failed'); |
| 496 }); | 527 }); |
| 497 }, 'Test MediaKeys createSession().'); | 528 }, 'Test MediaKeys createSession().'); |
| 498 | 529 |
| 499 // This function checks that calling generateRequest() works for | 530 // This function checks that calling generateRequest() works for |
| 500 // various sessions. |testCase.func| creates a MediaKeySession | 531 // various sessions. |testCase.func| creates a MediaKeySession |
| 501 // object, and then generateRequest() is called on that object. It | 532 // object, and then generateRequest() is called on that object. It |
| 502 // allows for an NotSupportedError to be generated and treated as a | 533 // allows for an NotSupportedError to be generated and treated as a |
| 503 // success, if allowed. See comment above kCreateSessionTestCases. | 534 // success, if allowed. See comment above kCreateSessionTestCases. |
| 504 function test_generateRequest(testCase, mediaKeys, type, initData) | 535 function test_generateRequest(testCase, mediaKeys, type, initData) |
| 505 { | 536 { |
| 506 var mediaKeySession; | 537 var mediaKeySession; |
| 507 try { | 538 try { |
| 508 mediaKeySession = testCase.func.call(null, mediaKeys); | 539 mediaKeySession = testCase.func.call(null, mediaKeys); |
| 509 } catch (e) { | 540 } catch (e) { |
| 510 assert_true(testCase.isNotSupportedAllowed); | 541 assert_true(testCase.isNotSupportedAllowed); |
| 511 return new Promise(new Promise(function() {})); | 542 return new Promise(new Promise(function() {})); |
| 512 } | 543 } |
| 513 return mediaKeySession.generateRequest(type, initData); | 544 return mediaKeySession.generateRequest(type, initData); |
| 514 } | 545 } |
| 515 | 546 |
| 516 async_test(function(test) | 547 async_test(function(test) |
| 517 { | 548 { |
| 518 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 549 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 550 return access.createMediaKeys(); | |
| 551 }).then(function(mediaKeys) { | |
| 519 var sessionPromises = []; | 552 var sessionPromises = []; |
| 520 | 553 |
| 521 // Test that WebM sessions generate the expected error, if | 554 // Test that WebM sessions generate the expected error, if |
| 522 // supported. | 555 // supported. |
| 523 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { | 556 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { |
| 524 var WebmSessionPromises = kCreateSessionTestCases.map(fu nction(testCase) { | 557 var WebmSessionPromises = kCreateSessionTestCases.map(fu nction(testCase) { |
| 525 return test_generateRequest(testCase, mediaKeys, 'we bm', getInitData('webm')); | 558 return test_generateRequest(testCase, mediaKeys, 'we bm', getInitData('webm')); |
| 526 }); | 559 }); |
| 527 sessionPromises = sessionPromises.concat(WebmSessionProm ises); | 560 sessionPromises = sessionPromises.concat(WebmSessionProm ises); |
| 528 } | 561 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 func: function(s) { return s.update(1); } | 606 func: function(s) { return s.update(1); } |
| 574 }, | 607 }, |
| 575 { | 608 { |
| 576 exception: 'InvalidAccessError', | 609 exception: 'InvalidAccessError', |
| 577 func: function(s) { return s.update(new Uint8Array(0)); } | 610 func: function(s) { return s.update(new Uint8Array(0)); } |
| 578 } | 611 } |
| 579 ]; | 612 ]; |
| 580 | 613 |
| 581 async_test(function(test) | 614 async_test(function(test) |
| 582 { | 615 { |
| 583 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 616 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 617 return access.createMediaKeys(); | |
| 618 }).then(function(mediaKeys) { | |
| 584 var promises = []; | 619 var promises = []; |
| 585 | 620 |
| 586 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { | 621 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { |
| 587 var WebmSessionPromises = kUpdateSessionExceptionsTestCa ses.map(function(testCase) { | 622 var WebmSessionPromises = kUpdateSessionExceptionsTestCa ses.map(function(testCase) { |
| 588 var mediaKeySession = mediaKeys.createSession(); | 623 var mediaKeySession = mediaKeys.createSession(); |
| 589 return mediaKeySession.generateRequest('webm', getIn itData('webm')).then(function(result) { | 624 return mediaKeySession.generateRequest('webm', getIn itData('webm')).then(function(result) { |
| 590 return test_exception(testCase, mediaKeySession) ; | 625 return test_exception(testCase, mediaKeySession) ; |
| 591 }); | 626 }); |
| 592 }); | 627 }); |
| 593 promises = promises.concat(WebmSessionPromises); | 628 promises = promises.concat(WebmSessionPromises); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 622 // Call update() with a different license and an extra | 657 // Call update() with a different license and an extra |
| 623 // parameter. The extra parameter is ignored. | 658 // parameter. The extra parameter is ignored. |
| 624 var validLicense = stringToUint8Array(createJWKSet(createJWK (stringToUint8Array('4567890'), stringToUint8Array('01234567890abcde')))); | 659 var validLicense = stringToUint8Array(createJWKSet(createJWK (stringToUint8Array('4567890'), stringToUint8Array('01234567890abcde')))); |
| 625 return mediaKeySession.update(validLicense, 'extra'); | 660 return mediaKeySession.update(validLicense, 'extra'); |
| 626 }); | 661 }); |
| 627 return promise; | 662 return promise; |
| 628 } | 663 } |
| 629 | 664 |
| 630 async_test(function(test) | 665 async_test(function(test) |
| 631 { | 666 { |
| 632 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 667 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 668 return access.createMediaKeys(); | |
| 669 }).then(function(mediaKeys) { | |
| 633 var promises = []; | 670 var promises = []; |
| 634 | 671 |
| 635 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm') ) { | 672 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm') ) { |
| 636 promises.push(create_update_test(mediaKeys, 'webm', getIni tData('webm'))); | 673 promises.push(create_update_test(mediaKeys, 'webm', getIni tData('webm'))); |
| 637 } | 674 } |
| 638 | 675 |
| 639 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4')) { | 676 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4')) { |
| 640 promises.push(create_update_test(mediaKeys, 'cenc', getIni tData('cenc'))); | 677 promises.push(create_update_test(mediaKeys, 'cenc', getIni tData('cenc'))); |
| 641 } | 678 } |
| 642 | 679 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 656 assert_unreached('close() should not succeed if session unin itialized'); | 693 assert_unreached('close() should not succeed if session unin itialized'); |
| 657 }).catch(function(error) { | 694 }).catch(function(error) { |
| 658 assert_equals(error.name, 'InvalidStateError'); | 695 assert_equals(error.name, 'InvalidStateError'); |
| 659 // Return something so the promise resolves. | 696 // Return something so the promise resolves. |
| 660 return Promise.resolve(); | 697 return Promise.resolve(); |
| 661 }); | 698 }); |
| 662 } | 699 } |
| 663 | 700 |
| 664 async_test(function(test) | 701 async_test(function(test) |
| 665 { | 702 { |
| 666 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 703 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 704 return access.createMediaKeys(); | |
| 705 }).then(function(mediaKeys) { | |
| 667 var promises = []; | 706 var promises = []; |
| 668 | 707 |
| 669 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { | 708 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { |
| 670 promises.push(create_close_exception_test(mediaKeys, 'we bm', getInitData('webm'))); | 709 promises.push(create_close_exception_test(mediaKeys, 'we bm', getInitData('webm'))); |
| 671 } | 710 } |
| 672 | 711 |
| 673 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { | 712 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { |
| 674 promises.push(create_close_exception_test(mediaKeys, 'ce nc', getInitData('cenc'))); | 713 promises.push(create_close_exception_test(mediaKeys, 'ce nc', getInitData('cenc'))); |
| 675 } | 714 } |
| 676 | 715 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 692 }).then(function(result) { | 731 }).then(function(result) { |
| 693 // Call close() again with an extra parameter. The extra | 732 // Call close() again with an extra parameter. The extra |
| 694 // parameter is ignored. | 733 // parameter is ignored. |
| 695 return mediaKeySession.close('extra'); | 734 return mediaKeySession.close('extra'); |
| 696 }); | 735 }); |
| 697 return promise; | 736 return promise; |
| 698 } | 737 } |
| 699 | 738 |
| 700 async_test(function(test) | 739 async_test(function(test) |
| 701 { | 740 { |
| 702 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 741 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 742 return access.createMediaKeys(); | |
| 743 }).then(function(mediaKeys) { | |
| 703 var promises = []; | 744 var promises = []; |
| 704 | 745 |
| 705 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { | 746 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { |
| 706 promises.push(create_close_test(mediaKeys, 'webm', getIn itData('webm'))); | 747 promises.push(create_close_test(mediaKeys, 'webm', getIn itData('webm'))); |
| 707 } | 748 } |
| 708 | 749 |
| 709 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { | 750 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { |
| 710 promises.push(create_close_test(mediaKeys, 'cenc', getIn itData('cenc'))); | 751 promises.push(create_close_test(mediaKeys, 'cenc', getIn itData('cenc'))); |
| 711 } | 752 } |
| 712 | 753 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 }).catch(function(error) { | 790 }).catch(function(error) { |
| 750 assert_equals(error.name, 'InvalidStateError'); | 791 assert_equals(error.name, 'InvalidStateError'); |
| 751 | 792 |
| 752 // Return something so the promise resolves. | 793 // Return something so the promise resolves. |
| 753 return Promise.resolve(); | 794 return Promise.resolve(); |
| 754 }); | 795 }); |
| 755 } | 796 } |
| 756 | 797 |
| 757 async_test(function(test) | 798 async_test(function(test) |
| 758 { | 799 { |
| 759 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 800 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 801 return access.createMediaKeys(); | |
| 802 }).then(function(mediaKeys) { | |
| 760 var promises = []; | 803 var promises = []; |
| 761 | 804 |
| 762 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { | 805 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { |
| 763 promises.push(create_remove_exception_test(mediaKeys, 'w ebm', getInitData('webm'))); | 806 promises.push(create_remove_exception_test(mediaKeys, 'w ebm', getInitData('webm'))); |
| 764 } | 807 } |
| 765 | 808 |
| 766 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { | 809 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { |
| 767 promises.push(create_remove_exception_test(mediaKeys, 'c enc', getInitData('cenc'))); | 810 promises.push(create_remove_exception_test(mediaKeys, 'c enc', getInitData('cenc'))); |
| 768 } | 811 } |
| 769 | 812 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 787 assert_equals(error.name, 'NotSupportedError'); | 830 assert_equals(error.name, 'NotSupportedError'); |
| 788 return Promise.resolve(); | 831 return Promise.resolve(); |
| 789 } | 832 } |
| 790 return mediaKeySession.generateRequest(type, initData).then(func tion(result) { | 833 return mediaKeySession.generateRequest(type, initData).then(func tion(result) { |
| 791 return mediaKeySession.remove(); | 834 return mediaKeySession.remove(); |
| 792 }); | 835 }); |
| 793 } | 836 } |
| 794 | 837 |
| 795 async_test(function(test) | 838 async_test(function(test) |
| 796 { | 839 { |
| 797 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 840 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 841 return access.createMediaKeys(); | |
| 842 }).then(function(mediaKeys) { | |
| 798 var promises = []; | 843 var promises = []; |
| 799 | 844 |
| 800 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { | 845 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/webm ')) { |
| 801 promises.push(create_remove_test(mediaKeys, 'webm', getI nitData('webm'))); | 846 promises.push(create_remove_test(mediaKeys, 'webm', getI nitData('webm'))); |
| 802 } | 847 } |
| 803 | 848 |
| 804 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { | 849 if (MediaKeys.isTypeSupported('org.w3.clearkey', 'video/mp4' )) { |
| 805 promises.push(create_remove_test(mediaKeys, 'cenc', getI nitData('cenc'))); | 850 promises.push(create_remove_test(mediaKeys, 'cenc', getI nitData('cenc'))); |
| 806 } | 851 } |
| 807 | 852 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 }, | 894 }, |
| 850 { | 895 { |
| 851 // Pass in ArrayBuffer | 896 // Pass in ArrayBuffer |
| 852 exception: 'NotSupportedError', | 897 exception: 'NotSupportedError', |
| 853 func: function(mk) { var cert = new Uint8Array(200); assert_ false(ArrayBuffer.isView(cert.buffer)); return mk.setServerCertificate(cert.buff er); } | 898 func: function(mk) { var cert = new Uint8Array(200); assert_ false(ArrayBuffer.isView(cert.buffer)); return mk.setServerCertificate(cert.buff er); } |
| 854 } | 899 } |
| 855 ]; | 900 ]; |
| 856 | 901 |
| 857 async_test(function(test) | 902 async_test(function(test) |
| 858 { | 903 { |
| 859 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 904 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu nction(access) { |
| 905 return access.createMediaKeys(); | |
| 906 }).then(function(mediaKeys) { | |
| 860 var promises = kSetServerCertificateExceptionsTestCases.map( function(testCase) { | 907 var promises = kSetServerCertificateExceptionsTestCases.map( function(testCase) { |
| 861 return test_exception(testCase, mediaKeys); | 908 return test_exception(testCase, mediaKeys); |
| 862 }); | 909 }); |
| 863 | 910 |
| 864 assert_not_equals(promises.length, 0); | 911 assert_not_equals(promises.length, 0); |
| 865 return Promise.all(promises); | 912 return Promise.all(promises); |
| 866 }).then(function(result) { | 913 }).then(function(result) { |
| 867 test.done(); | 914 test.done(); |
| 868 }).catch(function(error) { | 915 }).catch(function(error) { |
| 869 forceTestFailureFromPromise(test, error, 'setServerCertifica te() exception tests failed'); | 916 forceTestFailureFromPromise(test, error, 'setServerCertifica te() exception tests failed'); |
| 870 }); | 917 }); |
| 871 }, 'Test MediaKeys setServerCertificate() exceptions.'); | 918 }, 'Test MediaKeys setServerCertificate() exceptions.'); |
| 872 | 919 |
| 873 // FIXME: Add test for successful setServerCertificate(). Note that | 920 // FIXME: Add test for successful setServerCertificate(). Note that |
| 874 // ClearKey does not support it. | 921 // ClearKey does not support it. |
| 875 | 922 |
| 876 // FIXME: Add syntax checks for MediaKeys.IsTypeSupported(). | 923 // FIXME: Add syntax checks for MediaKeys.IsTypeSupported(). |
| 877 // FIXME: Add syntax checks for MediaKeyError and MediaKeySession ev ents. | 924 // FIXME: Add syntax checks for MediaKeyError and MediaKeySession ev ents. |
| 878 // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, med iakeys, onencrypted. | 925 // FIXME: Add HTMLMediaElement syntax checks, e.g. setMediaKeys, med iakeys, onencrypted. |
| 879 </script> | 926 </script> |
| 880 </body> | 927 </body> |
| 881 </html> | 928 </html> |
| OLD | NEW |