| 1 | /** |
| 2 | * Copyright 2018 Google Inc. All rights reserved. |
| 3 | * Modifications copyright (c) Microsoft Corporation. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | import { test as it } from './pageTest'; |
| 19 | |
| 20 | it('clicking on links which do not commit navigation', async ({ page, server, httpsServer }) => { |
| 21 | await page.goto(server.EMPTY_PAGE); |
| 22 | await page.setContent(`<a href='${httpsServer.EMPTY_PAGE}'>foobar</a>`); |
| 23 | await page.click('a'); |
| 24 | }); |
| 25 | |
| 26 | it('calling window.stop async', async ({ page, server }) => { |
| 27 | server.setRoute('/empty.html', async (req, res) => {}); |
| 28 | await page.evaluate(url => { |
| 29 | window.location.href = url; |
| 30 | setTimeout(() => window.stop(), 100); |
| 31 | }, server.EMPTY_PAGE); |
| 32 | }); |
| 33 | |
| 34 | it('calling window.stop sync', async ({ page, server }) => { |
| 35 | await page.evaluate(url => { |
| 36 | window.location.href = url; |
| 37 | window.stop(); |
| 38 | }, server.EMPTY_PAGE); |
| 39 | }); |
| 40 | |
| 41 | it('assigning location to about:blank', async ({ page, server }) => { |
| 42 | await page.goto(server.EMPTY_PAGE); |
| 43 | await page.evaluate(`window.location.href = "about:blank";`); |
| 44 | }); |
| 45 | |
| 46 | it('assigning location to about:blank after non-about:blank', async ({ page, server }) => { |
| 47 | server.setRoute('/empty.html', async (req, res) => {}); |
| 48 | await page.evaluate(` |
| 49 | window.location.href = "${server.EMPTY_PAGE}"; |
| 50 | window.location.href = "about:blank";`); |
| 51 | }); |
| 52 | |
| 53 | it('calling window.open and window.close', async function({ page, server }) { |
| 54 | await page.goto(server.EMPTY_PAGE); |
| 55 | await page.evaluate(() => { |
| 56 | const popup = window.open(window.location.href); |
| 57 | popup.close(); |
| 58 | }); |
| 59 | }); |
| 60 | |
| 61 | it('opening a popup', async function({ page, server }) { |
| 62 | await page.goto(server.EMPTY_PAGE); |
| 63 | await Promise.all([ |
| 64 | page.waitForEvent('popup'), |
| 65 | page.evaluate(() => window.open(window.location.href) && 1), |
| 66 | ]); |
| 67 | }); |