@@ -792,7 +792,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
792
792
} ) ;
793
793
it ( 'should work for cross-process navigations' , async ( { page, server} ) => {
794
794
await page . goto ( server . EMPTY_PAGE ) ;
795
- const waitPromise = page . waitForNavigation ( { waitUntil : 'commit ' } ) ;
795
+ const waitPromise = page . waitForNavigation ( { waitUntil : 'domcontentloaded ' } ) ;
796
796
const url = server . CROSS_PROCESS_PREFIX + '/empty.html' ;
797
797
const gotoPromise = page . goto ( url ) ;
798
798
const response = await waitPromise ;
@@ -808,37 +808,42 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
808
808
const messages = [ ] ;
809
809
server . setRoute ( '/empty.html' , async ( req , res ) => {
810
810
messages . push ( 'route' ) ;
811
- res . end ( 'done' ) ;
811
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
812
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
812
813
} ) ;
813
814
814
815
await page . setContent ( `<a href="${ server . EMPTY_PAGE } ">empty.html</a>` ) ;
815
816
816
817
await Promise . all ( [
817
818
page . click ( 'a' ) . then ( ( ) => messages . push ( 'click' ) ) ,
818
- page . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) )
819
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
820
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
819
821
] ) ;
820
- expect ( messages . join ( '|' ) ) . toBe ( 'route|waitForNavigation |click' ) ;
822
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded |click|load ' ) ;
821
823
} ) ;
822
824
it ( 'clicking anchor should await cross-process navigation' , async ( { page, server} ) => {
823
825
const messages = [ ] ;
824
826
server . setRoute ( '/empty.html' , async ( req , res ) => {
825
827
messages . push ( 'route' ) ;
826
- res . end ( 'done' ) ;
828
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
829
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
827
830
} ) ;
828
831
829
832
await page . setContent ( `<a href="${ server . CROSS_PROCESS_PREFIX + '/empty.html' } ">empty.html</a>` ) ;
830
833
831
834
await Promise . all ( [
832
835
page . click ( 'a' ) . then ( ( ) => messages . push ( 'click' ) ) ,
833
- page . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) )
836
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
837
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
834
838
] ) ;
835
- expect ( messages . join ( '|' ) ) . toBe ( 'route|waitForNavigation |click' ) ;
839
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded |click|load ' ) ;
836
840
} ) ;
837
841
it ( 'should await form-get on click' , async ( { page, server} ) => {
838
842
const messages = [ ] ;
839
843
server . setRoute ( '/empty.html?foo=bar' , async ( req , res ) => {
840
844
messages . push ( 'route' ) ;
841
- res . end ( 'done' ) ;
845
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
846
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
842
847
} ) ;
843
848
844
849
await page . setContent ( `
@@ -849,15 +854,17 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
849
854
850
855
await Promise . all ( [
851
856
page . click ( 'input[type=submit]' ) . then ( ( ) => messages . push ( 'click' ) ) ,
852
- page . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) )
857
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
858
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
853
859
] ) ;
854
- expect ( messages . join ( '|' ) ) . toBe ( 'route|waitForNavigation |click' ) ;
860
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded |click|load ' ) ;
855
861
} ) ;
856
862
it ( 'should await form-post on click' , async ( { page, server} ) => {
857
863
const messages = [ ] ;
858
864
server . setRoute ( '/empty.html' , async ( req , res ) => {
859
865
messages . push ( 'route' ) ;
860
- res . end ( 'done' ) ;
866
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
867
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
861
868
} ) ;
862
869
863
870
await page . setContent ( `
@@ -868,23 +875,26 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
868
875
869
876
await Promise . all ( [
870
877
page . click ( 'input[type=submit]' ) . then ( ( ) => messages . push ( 'click' ) ) ,
871
- page . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) )
878
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
879
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
872
880
] ) ;
873
- expect ( messages . join ( '|' ) ) . toBe ( 'route|waitForNavigation |click' ) ;
881
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded |click|load ' ) ;
874
882
} ) ;
875
883
it ( 'assigning location should await navigation' , async ( { page, server} ) => {
876
884
const messages = [ ] ;
877
885
server . setRoute ( '/empty.html' , async ( req , res ) => {
878
886
messages . push ( 'route' ) ;
879
- res . end ( 'done' ) ;
887
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
888
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
880
889
} ) ;
881
890
await Promise . all ( [
882
891
page . evaluate ( `window.location.href = "${ server . EMPTY_PAGE } "` ) . then ( ( ) => messages . push ( 'evaluate' ) ) ,
883
- page . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) ) ,
892
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
893
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
884
894
] ) ;
885
- expect ( messages . join ( '|' ) ) . toBe ( 'route|waitForNavigation |evaluate' ) ;
895
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded |evaluate|load ' ) ;
886
896
} ) ;
887
- it . skip ( CHROMIUM ) ( 'assigning location twice should await navigation' , async ( { page, server} ) => {
897
+ it . fail ( CHROMIUM ) ( 'assigning location twice should await navigation' , async ( { page, server} ) => {
888
898
const messages = [ ] ;
889
899
server . setRoute ( '/empty.html?cancel' , async ( req , res ) => { res . end ( 'done' ) ; } ) ;
890
900
server . setRoute ( '/empty.html?override' , async ( req , res ) => { messages . push ( 'routeoverride' ) ; res . end ( 'done' ) ; } ) ;
@@ -899,17 +909,26 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
899
909
it ( 'evaluating reload should await navigation' , async ( { page, server} ) => {
900
910
const messages = [ ] ;
901
911
await page . goto ( server . EMPTY_PAGE ) ;
902
- server . setRoute ( '/empty.html' , async ( req , res ) => { messages . push ( 'route' ) ; res . end ( 'done' ) ; } ) ;
912
+ server . setRoute ( '/empty.html' , async ( req , res ) => {
913
+ messages . push ( 'route' ) ;
914
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
915
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
916
+ } ) ;
903
917
904
918
await Promise . all ( [
905
919
page . evaluate ( `window.location.reload()` ) . then ( ( ) => messages . push ( 'evaluate' ) ) ,
906
- page . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) ) ,
920
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
921
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
907
922
] ) ;
908
- expect ( messages . join ( '|' ) ) . toBe ( 'route|waitForNavigation |evaluate' ) ;
923
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded |evaluate|load ' ) ;
909
924
} ) ;
910
925
it ( 'should await navigating specified target' , async ( { page, server} ) => {
911
926
const messages = [ ] ;
912
- server . setRoute ( '/empty.html' , async ( req , res ) => { messages . push ( 'route' ) ; res . end ( 'done' ) ; } ) ;
927
+ server . setRoute ( '/empty.html' , async ( req , res ) => {
928
+ messages . push ( 'route' ) ;
929
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
930
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
931
+ } ) ;
913
932
914
933
await page . setContent ( `
915
934
<a href="${ server . EMPTY_PAGE } " target=target>empty.html</a>
@@ -918,19 +937,42 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
918
937
const frame = page . frame ( { name : 'target' } ) ;
919
938
await Promise . all ( [
920
939
page . click ( 'a' ) . then ( ( ) => messages . push ( 'click' ) ) ,
921
- frame . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) )
940
+ frame . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
941
+ frame . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
922
942
] ) ;
923
943
expect ( frame . url ( ) ) . toBe ( server . EMPTY_PAGE ) ;
924
- expect ( messages . join ( '|' ) ) . toBe ( 'route|waitForNavigation |click' ) ;
944
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded |click|load ' ) ;
925
945
} ) ;
926
- it ( 'nowait' , async ( { page, server} ) => {
946
+ it ( 'waitUntil: nowait' , async ( { page, server} ) => {
927
947
const messages = [ ] ;
948
+ server . setRoute ( '/empty.html' , async ( req , res ) => {
949
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
950
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
951
+ } ) ;
952
+
928
953
await page . setContent ( `<a href="${ server . EMPTY_PAGE } ">empty.html</a>` ) ;
929
954
await Promise . all ( [
930
955
page . click ( 'a' , { waitUntil : 'nowait' } ) . then ( ( ) => messages . push ( 'click' ) ) ,
931
- page . waitForNavigation ( { waitUntil : 'commit' } ) . then ( ( ) => messages . push ( 'waitForNavigation' ) )
956
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
957
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
958
+ ] ) ;
959
+ expect ( messages . join ( '|' ) ) . toBe ( 'click|domcontentloaded|load' ) ;
960
+ } ) ;
961
+ it ( 'waitUntil: load' , async ( { page, server} ) => {
962
+ const messages = [ ] ;
963
+ server . setRoute ( '/empty.html' , async ( req , res ) => {
964
+ messages . push ( 'route' ) ;
965
+ res . setHeader ( 'Content-Type' , 'text/html' ) ;
966
+ res . end ( `<link rel='stylesheet' href='./one-style.css'>` ) ;
967
+ } ) ;
968
+
969
+ await page . setContent ( `<a href="${ server . EMPTY_PAGE } ">empty.html</a>` ) ;
970
+ await Promise . all ( [
971
+ page . click ( 'a' , { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'click' ) ) ,
972
+ page . waitForNavigation ( { waitUntil : 'domcontentloaded' } ) . then ( ( ) => messages . push ( 'domcontentloaded' ) ) ,
973
+ page . waitForNavigation ( { waitUntil : 'load' } ) . then ( ( ) => messages . push ( 'load' ) ) ,
932
974
] ) ;
933
- expect ( messages . join ( '|' ) ) . toBe ( 'click|waitForNavigation ' ) ;
975
+ expect ( messages . join ( '|' ) ) . toBe ( 'route|domcontentloaded|load|click ' ) ;
934
976
} ) ;
935
977
} ) ;
936
978
@@ -975,7 +1017,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
975
1017
server . setRoute ( '/one-style.css' , ( req , res ) => response = res ) ;
976
1018
await Promise . all ( [
977
1019
server . waitForRequest ( '/one-style.css' ) ,
978
- page . goto ( server . PREFIX + '/one-style.html' , { waitUntil : 'commit ' } ) ,
1020
+ page . goto ( server . PREFIX + '/one-style.html' , { waitUntil : 'domcontentloaded ' } ) ,
979
1021
] ) ;
980
1022
const waitPromise = page . mainFrame ( ) . _waitForLoadState ( ) ;
981
1023
response . statusCode = 404 ;
@@ -984,7 +1026,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
984
1026
} ) ;
985
1027
it ( 'should respect timeout' , async ( { page, server} ) => {
986
1028
server . setRoute ( '/one-style.css' , ( req , res ) => response = res ) ;
987
- await page . goto ( server . PREFIX + '/one-style.html' , { waitUntil : 'commit ' } ) ;
1029
+ await page . goto ( server . PREFIX + '/one-style.html' , { waitUntil : 'domcontentloaded ' } ) ;
988
1030
const error = await page . mainFrame ( ) . _waitForLoadState ( { timeout : 1 } ) . catch ( e => e ) ;
989
1031
expect ( error . message ) . toBe ( 'Navigation timeout of 1 ms exceeded' ) ;
990
1032
} ) ;
@@ -995,7 +1037,7 @@ module.exports.describe = function({testRunner, expect, playwright, MAC, WIN, FF
995
1037
it ( 'should resolve immediately if load state matches' , async ( { page, server} ) => {
996
1038
await page . goto ( server . EMPTY_PAGE ) ;
997
1039
server . setRoute ( '/one-style.css' , ( req , res ) => response = res ) ;
998
- await page . goto ( server . PREFIX + '/one-style.html' , { waitUntil : 'commit ' } ) ;
1040
+ await page . goto ( server . PREFIX + '/one-style.html' , { waitUntil : 'domcontentloaded ' } ) ;
999
1041
await page . mainFrame ( ) . _waitForLoadState ( { waitUntil : 'domcontentloaded' } ) ;
1000
1042
} ) ;
1001
1043
it ( 'should work with pages that have loaded before being connected to' , async ( { page, context, server} ) => {
0 commit comments