OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>MediaStream Recoder Browser Test (w/ MediaSource)</title> | 4 <title>MediaStream Recoder Browser Test (w/ MediaSource)</title> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <div> Record Real-Time video content browser test.</div> | 7 <div> Record Real-Time video content browser test.</div> |
8 <video id="video" autoplay></video> | 8 <video id="video" autoplay></video> |
9 </body> | 9 </body> |
10 <script type="text/javascript" src="mediarecorder_test_utils.js"></script> | 10 <script type="text/javascript" src="mediarecorder_test_utils.js"></script> |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 .then(function(stream) { | 477 .then(function(stream) { |
478 return createMediaRecorder(stream, DEFAULT_RECORDER_MIME_TYPE); | 478 return createMediaRecorder(stream, DEFAULT_RECORDER_MIME_TYPE); |
479 }) | 479 }) |
480 .then(function(recorder) { | 480 .then(function(recorder) { |
481 assertThrows(function() {recorder.requestData()}, | 481 assertThrows(function() {recorder.requestData()}, |
482 'Calling requestdata() in inactive state should throw a DOM ' + | 482 'Calling requestdata() in inactive state should throw a DOM ' + |
483 'Exception'); | 483 'Exception'); |
484 }); | 484 }); |
485 } | 485 } |
486 | 486 |
| 487 // Tests that MediaRecorder fires an Error Event when the associated MediaStream |
| 488 // gets a Track added. |
| 489 function testAddingTrackToMediaStreamFiresErrorEvent() { |
| 490 var theStream; |
| 491 var theRecorder; |
| 492 var errorEventReceived = false; |
| 493 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) |
| 494 .then(function(stream) { |
| 495 theStream = stream; |
| 496 return createAndStartMediaRecorder(stream); |
| 497 }) |
| 498 .then(function(recorder) { |
| 499 theRecorder = recorder; |
| 500 theRecorder.onerror = function(event) { |
| 501 errorEventReceived = true; |
| 502 assertEquals('inactive', theRecorder.state); |
| 503 }; |
| 504 // Add a new track, copy of an existing one for simplicity. |
| 505 theStream.addTrack(theStream.getTracks()[1].clone()); |
| 506 }) |
| 507 .then(function() { |
| 508 return waitFor('Waiting for the Error Event', |
| 509 function() { |
| 510 return errorEventReceived; |
| 511 }); |
| 512 }) |
| 513 .catch(function(err) { |
| 514 return failTest(err.toString()); |
| 515 }) |
| 516 .then(function() { |
| 517 reportTestSuccess(); |
| 518 }); |
| 519 } |
| 520 |
| 521 // Tests that MediaRecorder fires an Error Event when the associated MediaStream |
| 522 // gets a Track removed. |
| 523 function testRemovingTrackFromMediaStreamFiresErrorEvent() { |
| 524 var theStream; |
| 525 var theRecorder; |
| 526 var errorEventReceived = false; |
| 527 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) |
| 528 .then(function(stream) { |
| 529 theStream = stream; |
| 530 return createAndStartMediaRecorder(stream); |
| 531 }) |
| 532 .then(function(recorder) { |
| 533 theRecorder = recorder; |
| 534 theRecorder.onerror = function(event) { |
| 535 errorEventReceived = true; |
| 536 assertEquals('inactive', theRecorder.state); |
| 537 }; |
| 538 theStream.removeTrack(theStream.getTracks()[1]); |
| 539 }) |
| 540 .then(function() { |
| 541 return waitFor('Waiting for the Error Event', |
| 542 function() { |
| 543 return errorEventReceived; |
| 544 }); |
| 545 }) |
| 546 .catch(function(err) { |
| 547 return failTest(err.toString()); |
| 548 }) |
| 549 .then(function() { |
| 550 reportTestSuccess(); |
| 551 }); |
| 552 } |
| 553 |
487 </script> | 554 </script> |
488 </body> | 555 </body> |
489 </html> | 556 </html> |
OLD | NEW |