@@ -612,7 +612,7 @@ test('Attach mediaStream directly', function(t) {
612
612
// Run test.
613
613
seleniumHelpers . loadTestPage ( driver )
614
614
. then ( function ( ) {
615
- t . plan ( 6 ) ;
615
+ t . plan ( 4 ) ;
616
616
t . pass ( 'Page loaded' ) ;
617
617
return driver . executeAsyncScript ( testDefinition ) ;
618
618
} )
@@ -635,20 +635,14 @@ test('Attach mediaStream directly', function(t) {
635
635
return driver . wait ( webdriver . until . elementLocated (
636
636
webdriver . By . id ( 'video' ) ) , 3000 ) ;
637
637
} )
638
- . then ( function ( videoElement ) {
639
- t . pass ( 'Stream attached directly succesfully to a video element' ) ;
640
- videoElement . getAttribute ( 'videoWidth' )
641
- . then ( function ( width ) {
642
- videoElement . getAttribute ( 'videoHeight' )
643
- . then ( function ( height ) {
644
- // Chrome sets the stream dimensions to 2x2 if something is wrong
645
- // with the stream/frames from the camera.
646
- t . ok ( width > 2 , 'Video width is: ' + width ) ;
647
- t . ok ( height > 2 , 'Video height is: ' + height ) ;
648
- } ) ;
649
- } ) ;
638
+ . then ( function ( ) {
639
+ return driver . wait ( function ( ) {
640
+ return driver . executeScript (
641
+ 'return document.getElementById("video").readyState === 4' ) ;
642
+ } , 3000 ) ;
650
643
} )
651
644
. then ( function ( ) {
645
+ t . pass ( 'Stream attached directly succesfully to a video element' ) ;
652
646
t . end ( ) ;
653
647
} )
654
648
. then ( null , function ( err ) {
@@ -700,7 +694,7 @@ test('Re-attaching mediaStream directly', function(t) {
700
694
// Run test.
701
695
seleniumHelpers . loadTestPage ( driver )
702
696
. then ( function ( ) {
703
- t . plan ( 9 ) ;
697
+ t . plan ( 5 ) ;
704
698
t . pass ( 'Page loaded' ) ;
705
699
return driver . executeAsyncScript ( testDefinition ) ;
706
700
} )
@@ -726,36 +720,26 @@ test('Re-attaching mediaStream directly', function(t) {
726
720
webdriver . By . id ( 'video' ) ) , 3000 ) ;
727
721
} )
728
722
. then ( function ( videoElement ) {
723
+ return driver . wait ( function ( ) {
724
+ return driver . executeScript (
725
+ 'return document.querySelector("video").readyState === 4' ) ;
726
+ } , 3000 ) ;
727
+ } )
728
+ . then ( function ( ) {
729
729
t . pass ( 'Stream attached directly succesfully to a video element' ) ;
730
- videoElement . getAttribute ( 'videoWidth' )
731
- . then ( function ( width ) {
732
- videoElement . getAttribute ( 'videoHeight' )
733
- . then ( function ( height ) {
734
- // Chrome sets the stream dimensions to 2x2 if something is wrong
735
- // with the stream/frames from the camera.
736
- t . ok ( width > 2 , 'Video width is: ' + width ) ;
737
- t . ok ( height > 2 , 'Video height is: ' + height ) ;
738
- } ) ;
739
- } ) ;
740
730
// Wait until loadedmetadata event has fired and appended video element.
741
731
// 5 second timeout in case the event does not fire for some reason.
742
732
return driver . wait ( webdriver . until . elementLocated (
743
733
webdriver . By . id ( 'video2' ) ) , 3000 ) ;
744
734
} )
745
- . then ( function ( videoElement2 ) {
746
- t . pass ( 'Stream re-attached directly succesfully to a video element' ) ;
747
- videoElement2 . getAttribute ( 'videoWidth' )
748
- . then ( function ( width ) {
749
- videoElement2 . getAttribute ( 'videoHeight' )
750
- . then ( function ( height ) {
751
- // Chrome sets the stream dimensions to 2x2 if something is wrong
752
- // with the stream/frames from the camera.
753
- t . ok ( width > 2 , 'Video 2 width is: ' + width ) ;
754
- t . ok ( height > 2 , 'Video 2 height is: ' + height ) ;
755
- } ) ;
756
- } ) ;
735
+ . then ( function ( ) {
736
+ return driver . wait ( function ( ) {
737
+ return driver . executeScript (
738
+ 'return document.getElementById("video2").readyState === 4' ) ;
739
+ } , 3000 ) ;
757
740
} )
758
741
. then ( function ( ) {
742
+ t . pass ( 'Stream re-attached directly succesfully to a video element' ) ;
759
743
t . end ( ) ;
760
744
} )
761
745
. then ( null , function ( err ) {
0 commit comments