/** * Copyright 2017 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. */ import { browserTest as it, expect } from '../config/browserTest'; import { attachFrame } from '../config/utils'; it('should not be visible in context.pages', async ({ contextFactory }) => { const context = await contextFactory(); const page = await context.newPage(); expect(context.pages()).toContain(page); await page.close(); expect(context.pages()).not.toContain(page); }); it('page.context should return the correct instance', async function({ contextFactory }) { const context = await contextFactory(); const page = await context.newPage(); expect(page.context()).toBe(context); }); it('frame.focus should work multiple times', async ({ contextFactory }) => { const context = await contextFactory(); const page1 = await context.newPage(); const page2 = await context.newPage(); for (const page of [page1, page2]) { await page.setContent(``); await page.focus('#foo'); expect(await page.evaluate(() => !!window['gotFocus'])).toBe(true); } }); it('should click with disabled javascript', async ({ browser, server }) => { const context = await browser.newContext({ javaScriptEnabled: false }); const page = await context.newPage(); await page.goto(server.PREFIX + '/wrappedlink.html'); await Promise.all([ page.click('a'), page.waitForNavigation() ]); expect(page.url()).toBe(server.PREFIX + '/wrappedlink.html#clicked'); await context.close(); }); it('should not hang with touch-enabled viewports', async ({ browser, playwright }) => { // @see https://github.com/GoogleChrome/puppeteer/issues/161 const { viewport, hasTouch } = playwright.devices['iPhone 6']; const context = await browser.newContext({ viewport, hasTouch }); const page = await context.newPage(); await page.mouse.down(); await page.mouse.move(100, 10); await page.mouse.up(); await context.close(); }); it('should click the button with deviceScaleFactor set', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 400, height: 400 }, deviceScaleFactor: 5 }); const page = await context.newPage(); expect(await page.evaluate(() => window.devicePixelRatio)).toBe(5); await page.setContent('