| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Copyright 2018 Google Inc. All rights reserved. | 
					
						
							|  |  |  |  * Modifications copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2020-08-19 21:32:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-06 07:08:22 -07:00
										 |  |  | import { test as it, expect } from './pageTest'; | 
					
						
							| 
									
										
										
										
											2021-05-05 19:10:28 -07:00
										 |  |  | import { attachFrame } from '../config/utils'; | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-10 19:42:52 +01:00
										 |  |  | it('should navigate subframes @smoke', async ({ page, server }) => { | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  |   await page.goto(server.PREFIX + '/frames/one-frame.html'); | 
					
						
							|  |  |  |   expect(page.frames()[0].url()).toContain('/frames/one-frame.html'); | 
					
						
							|  |  |  |   expect(page.frames()[1].url()).toContain('/frames/frame.html'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const response = await page.frames()[1].goto(server.EMPTY_PAGE); | 
					
						
							|  |  |  |   expect(response.ok()).toBe(true); | 
					
						
							|  |  |  |   expect(response.frame()).toBe(page.frames()[1]); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-25 01:23:12 -08:00
										 |  |  | it('should reject when frame detaches', async ({ page, server, browserName }) => { | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  |   await page.goto(server.PREFIX + '/frames/one-frame.html'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-10 09:25:54 -08:00
										 |  |  |   server.setRoute('/one-style.css', () => {}); | 
					
						
							|  |  |  |   const navigationPromise = page.frames()[1].goto(server.PREFIX + '/one-style.html').catch(e => e); | 
					
						
							|  |  |  |   await server.waitForRequest('/one-style.css'); | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   await page.$eval('iframe', frame => frame.remove()); | 
					
						
							|  |  |  |   const error = await navigationPromise; | 
					
						
							| 
									
										
										
										
											2023-01-25 01:23:12 -08:00
										 |  |  |   if (browserName === 'chromium') | 
					
						
							| 
									
										
										
										
											2023-07-25 16:47:04 -07:00
										 |  |  |     expect(error.message.includes('net::ERR_ABORTED') || error.message.toLowerCase().includes('frame was detached')).toBe(true); | 
					
						
							| 
									
										
										
										
											2023-01-25 01:23:12 -08:00
										 |  |  |   else | 
					
						
							| 
									
										
										
										
											2023-07-25 16:47:04 -07:00
										 |  |  |     expect(error.message.toLowerCase()).toContain('frame was detached'); | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-31 11:24:04 -07:00
										 |  |  | it('should continue after client redirect', async ({ page, server, isAndroid, mode }) => { | 
					
						
							| 
									
										
										
										
											2022-08-03 10:51:45 +02:00
										 |  |  |   it.fixme(isAndroid); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  |   server.setRoute('/frames/script.js', () => {}); | 
					
						
							|  |  |  |   const url = server.PREFIX + '/frames/child-redirect.html'; | 
					
						
							|  |  |  |   const error = await page.goto(url, { timeout: 5000, waitUntil: 'networkidle' }).catch(e => e); | 
					
						
							|  |  |  |   expect(error.message).toContain('page.goto: Timeout 5000ms exceeded.'); | 
					
						
							|  |  |  |   expect(error.message).toContain(`navigating to "${url}", waiting until "networkidle"`); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 18:58:08 +02:00
										 |  |  | it('should return matching responses', async ({ page, server }) => { | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  |   await page.goto(server.EMPTY_PAGE); | 
					
						
							|  |  |  |   // Attach three frames.
 | 
					
						
							|  |  |  |   const frames = [ | 
					
						
							| 
									
										
										
										
											2020-09-18 15:52:14 -07:00
										 |  |  |     await attachFrame(page, 'frame1', server.EMPTY_PAGE), | 
					
						
							|  |  |  |     await attachFrame(page, 'frame2', server.EMPTY_PAGE), | 
					
						
							|  |  |  |     await attachFrame(page, 'frame3', server.EMPTY_PAGE), | 
					
						
							| 
									
										
										
										
											2020-08-04 16:32:10 -07:00
										 |  |  |   ]; | 
					
						
							|  |  |  |   const serverResponses = []; | 
					
						
							|  |  |  |   server.setRoute('/0.html', (req, res) => serverResponses.push(res)); | 
					
						
							|  |  |  |   server.setRoute('/1.html', (req, res) => serverResponses.push(res)); | 
					
						
							|  |  |  |   server.setRoute('/2.html', (req, res) => serverResponses.push(res)); | 
					
						
							|  |  |  |   const navigations = []; | 
					
						
							|  |  |  |   for (let i = 0; i < 3; ++i) { | 
					
						
							|  |  |  |     navigations.push(frames[i].goto(server.PREFIX + '/' + i + '.html')); | 
					
						
							|  |  |  |     await server.waitForRequest('/' + i + '.html'); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // Respond from server out-of-order.
 | 
					
						
							|  |  |  |   const serverResponseTexts = ['AAA', 'BBB', 'CCC']; | 
					
						
							|  |  |  |   for (const i of [1, 2, 0]) { | 
					
						
							|  |  |  |     serverResponses[i].end(serverResponseTexts[i]); | 
					
						
							|  |  |  |     const response = await navigations[i]; | 
					
						
							|  |  |  |     expect(response.frame()).toBe(frames[i]); | 
					
						
							|  |  |  |     expect(await response.text()).toBe(serverResponseTexts[i]); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }); |