Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: webkit pipeline behaves different locally vs ci when set permissions #34307

Open
ZeroCool-85 opened this issue Jan 11, 2025 · 1 comment

Comments

@ZeroCool-85
Copy link

ZeroCool-85 commented Jan 11, 2025

Version

1.48.2

Steps to reproduce

Local: MacOS

CI Runner: Docker Linux

  1. Run a test with webkit
  2. Open a new page on the same website.
  3. Try to read clipboard

config:

import { defineConfig, devices } from '@playwright/test';
import 'dotenv/config';
import path from 'path';

/**
 * Read environment variables from file.
 * https://github.com/motdotla/dotenv
 */
require('dotenv').config({ path: path.resolve(__dirname, 'e2e', '.env') });

/**
 * See https://playwright.dev/docs/test-configuration.
 */
export default defineConfig({
  testDir: './e2e/tests',
  /* Run tests in files in parallel */
  fullyParallel: true,
  /* Fail the build on CI if you accidentally left test.only in the source code. */
  forbidOnly: !!process.env.CI,
  /* Retry on CI only */
  retries: process.env.CI ? 2 : 0,
  /* Opt out of parallel tests on CI. */
  workers: process.env.CI ? 1 : undefined,
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  reporter: 'html',
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  use: {
    /* Base URL to use in actions like `await page.goto('/')`. */
    // baseURL: 'http://127.0.0.1:3000',

    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    trace: 'on-first-retry',
    locale: 'en-us',
  },

  /* Configure projects for major browsers */
  projects: [
    { name: 'setup', testMatch: /.*\.setup\.ts/ },
    {
      name: 'chromium',
      testMatch: /.*\.spec\.ts/,
      use: {
        ...devices['Desktop Chrome'],
        storageState: '.auth/user.json',
        contextOptions: {
          permissions: ['clipboard-read', 'clipboard-write'],
        },
      },
      dependencies: ['setup'],
    },
    {
      name: 'firefox',
      testMatch: /.*\.spec\.ts/,
      use: {
        ...devices['Desktop Firefox'],
        storageState: '.auth/user.json',
      },
      dependencies: ['setup'],
    },
    {
      name: 'webkit',
      testMatch: /.*\.spec\.ts/,
      use: {
        ...devices['Desktop Safari'],
        storageState: '.auth/user.json',
        contextOptions: {
          permissions: ['clipboard-read'],
        },
      },
      dependencies: ['setup'],
    },
    {
      name: 'smoke-chromium',
      testMatch: /.*\.smoke\.ts/,
      use: {
        ...devices['Desktop Chrome'],
        storageState: '.auth/user.json',
      },
      dependencies: ['setup'],
    },
    {
      name: 'smoke-firefox',
      testMatch: /.*\.smoke\.ts/,
      use: {
        ...devices['Desktop Firefox'],
        storageState: '.auth/user.json',
      },
      dependencies: ['setup'],
    },
    {
      name: 'smoke-webkit',
      testMatch: /.*\.smoke\.ts/,
      use: {
        ...devices['Desktop Safari'],
        storageState: '.auth/user.json',
      },
      dependencies: ['setup'],
    },
});

code:

const page2 = await context.newPage();
await page2.goto(LINK_ON_THE_SAME_PAGE);
const clipboardContent = await page2.evaluate(() => navigator.clipboard.readText());

running local:

npx playwright install --with-deps
npx playwright test --project=webkit

running ci:

npx playwright install --with-deps
npx playwright test --project=webkit

Expected behavior

The tests behave the same for local and ci.

Actual behavior

Local: works as expected

CI: Throws error: Error: page.evaluate: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Additional context

No response

Environment

Local System:
    OS: macOS 14.6.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 13.47 MB / 16.00 GB
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
    pnpm: 9.12.0 - ~/.nvm/versions/node/v18.18.2/bin/pnpm
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.48.2 => 1.48.2 


CI Runner: Linux
@yury-s
Copy link
Member

yury-s commented Jan 13, 2025

WebPasteboardProxy::allPasteboardItemInfo is not implemented in headless WebKit on Linux, so navigator.clipboard.readText() fails there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants