@@ -92,3 +92,67 @@ it('page.reload should work with data url', async ({page, server}) => {
92
92
expect ( await page . reload ( ) ) . toBe ( null ) ;
93
93
expect ( await page . content ( ) ) . toContain ( 'hello' ) ;
94
94
} ) ;
95
+
96
+ it ( 'page.reload during renderer-initiated navigation' , async ( { page, server} ) => {
97
+ await page . goto ( server . PREFIX + '/one-style.html' ) ;
98
+ await page . setContent ( `<form method='POST' action='/post'>Form is here<input type='submit'></form>` ) ;
99
+ server . setRoute ( '/post' , ( req , res ) => { } ) ;
100
+
101
+ let callback ;
102
+ const reloadFailedPromise = new Promise ( f => callback = f ) ;
103
+ page . once ( 'request' , async ( ) => {
104
+ await page . reload ( ) . catch ( e => { } ) ;
105
+ callback ( ) ;
106
+ } ) ;
107
+ const clickPromise = page . click ( 'input[type=submit]' ) . catch ( e => { } ) ;
108
+ await reloadFailedPromise ;
109
+ await clickPromise ;
110
+
111
+ // Form submit should be canceled, and reload should eventually arrive
112
+ // to the original one-style.html.
113
+ await page . waitForSelector ( 'text=hello' ) ;
114
+ } ) ;
115
+
116
+ it ( 'page.goBack during renderer-initiated navigation' , async ( { page, server} ) => {
117
+ await page . goto ( server . PREFIX + '/one-style.html' ) ;
118
+ await page . goto ( server . EMPTY_PAGE ) ;
119
+ await page . setContent ( `<form method='POST' action='/post'>Form is here<input type='submit'></form>` ) ;
120
+ server . setRoute ( '/post' , ( req , res ) => { } ) ;
121
+
122
+ let callback ;
123
+ const reloadFailedPromise = new Promise ( f => callback = f ) ;
124
+ page . once ( 'request' , async ( ) => {
125
+ await page . goBack ( ) . catch ( e => { } ) ;
126
+ callback ( ) ;
127
+ } ) ;
128
+ const clickPromise = page . click ( 'input[type=submit]' ) . catch ( e => { } ) ;
129
+ await reloadFailedPromise ;
130
+ await clickPromise ;
131
+
132
+ // Form submit should be canceled, and goBack should eventually arrive
133
+ // to the original one-style.html.
134
+ await page . waitForSelector ( 'text=hello' ) ;
135
+ } ) ;
136
+
137
+ it ( 'page.goForward during renderer-initiated navigation' , async ( { page, server} ) => {
138
+ await page . goto ( server . EMPTY_PAGE ) ;
139
+ await page . goto ( server . PREFIX + '/one-style.html' ) ;
140
+ await page . goBack ( ) ;
141
+
142
+ await page . setContent ( `<form method='POST' action='/post'>Form is here<input type='submit'></form>` ) ;
143
+ server . setRoute ( '/post' , ( req , res ) => { } ) ;
144
+
145
+ let callback ;
146
+ const reloadFailedPromise = new Promise ( f => callback = f ) ;
147
+ page . once ( 'request' , async ( ) => {
148
+ await page . goForward ( ) . catch ( e => { } ) ;
149
+ callback ( ) ;
150
+ } ) ;
151
+ const clickPromise = page . click ( 'input[type=submit]' ) . catch ( e => { } ) ;
152
+ await reloadFailedPromise ;
153
+ await clickPromise ;
154
+
155
+ // Form submit should be canceled, and goForward should eventually arrive
156
+ // to the original one-style.html.
157
+ await page . waitForSelector ( 'text=hello' ) ;
158
+ } ) ;
0 commit comments