test: drop webview2 bot (#38490)

This commit is contained in:
Simon Knott 2025-12-09 09:08:34 +01:00 committed by GitHub
parent 1065dd72af
commit 2529632db6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 4 additions and 400 deletions

View File

@ -55,36 +55,6 @@ jobs:
- run: npm run stest heap -- --project=chromium
if: ${{ !cancelled() }}
test_webview2:
name: WebView2
environment: ${{ github.event_name == 'push' && 'allow-uploading-flakiness-results' || null }}
runs-on: windows-2022
permissions:
id-token: write # This is required for OIDC login (azure/login) to succeed
contents: read # This is required for actions/checkout to succeed
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- run: dotnet build
working-directory: tests/webview2/webview2-app/
- name: Update to Evergreen WebView2 Runtime
shell: pwsh
run: |
# See here: https://developer.microsoft.com/en-us/microsoft-edge/webview2/
Invoke-WebRequest -Uri 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' -OutFile 'setup.exe'
Start-Process -FilePath setup.exe -Verb RunAs -Wait
- uses: ./.github/actions/run-test
with:
node-version: 20
browsers-to-install: chromium
command: npm run webview2test
bot-name: "webview2-chromium-windows"
flakiness-client-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_CLIENT_ID }}
flakiness-tenant-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_TENANT_ID }}
flakiness-subscription-id: ${{ secrets.AZURE_FLAKINESS_DASHBOARD_SUBSCRIPTION_ID }}
test_clock_frozen_time_linux:
name: time library - ${{ matrix.clock }}
environment: ${{ github.event_name == 'push' && 'allow-uploading-flakiness-results' || null }}

View File

@ -21,7 +21,6 @@
"wtest": "playwright test --config=tests/library/playwright.config.ts --project=webkit-*",
"atest": "playwright test --config=tests/android/playwright.config.ts",
"etest": "playwright test --config=tests/electron/playwright.config.ts",
"webview2test": "playwright test --config=tests/webview2/playwright.config.ts",
"itest": "playwright test --config=tests/installation/playwright.config.ts",
"stest": "playwright test --config=tests/stress/playwright.config.ts",
"biditest": "playwright test --config=tests/bidi/playwright.config.ts",

View File

@ -60,7 +60,6 @@ export const androidTest = baseTest.extend<PageTestFixtures & AndroidTestFixture
isAndroid: [true, { scope: 'worker' }],
isElectron: [false, { scope: 'worker' }],
electronMajorVersion: [0, { scope: 'worker' }],
isWebView2: [false, { scope: 'worker' }],
isHeadlessShell: [false, { scope: 'worker' }],
androidDevice: async ({ androidDeviceWorker }, use) => {

View File

@ -98,7 +98,6 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
isAndroid: [false, { scope: 'worker' }],
isElectron: [false, { scope: 'worker' }],
electronMajorVersion: [0, { scope: 'worker' }],
isWebView2: [false, { scope: 'worker' }],
isHeadlessShell: [async ({ browserName, channel, headless }, use) => {
await use(browserName === 'chromium' && (channel === 'chromium-headless-shell' || channel === 'chromium-tip-of-tree-headless-shell' || (!channel && headless)));

View File

@ -38,7 +38,6 @@ export const electronTest = baseTest.extend<TraceViewerFixtures>(traceViewerFixt
electronMajorVersion: [({}, use) => use(parseInt(require('electron/package.json').version.split('.')[0], 10)), { scope: 'worker' }],
isAndroid: [false, { scope: 'worker' }],
isElectron: [true, { scope: 'worker' }],
isWebView2: [false, { scope: 'worker' }],
isHeadlessShell: [false, { scope: 'worker' }],
createUserDataDir: async ({ mode }, run) => {

View File

@ -75,9 +75,8 @@ test('should cancel navigation when page crashes', async ({ server, page, crash
expect(error.message).toContain('page.goto: Page crashed');
});
test('should be able to close context when page crashes', async ({ isAndroid, isWebView2, page, crash }) => {
test('should be able to close context when page crashes', async ({ isAndroid, page, crash }) => {
test.skip(isAndroid);
test.skip(isWebView2, 'Page.close() is not supported in WebView2');
await page.setContent(`<div>This page should crash</div>`);
crash();

View File

@ -21,9 +21,8 @@ import { attachFrame } from '../config/utils';
import fs from 'fs';
import formidable from 'formidable';
test('should upload multiple large files', async ({ page, server, isAndroid, isWebView2, mode }, testInfo) => {
test('should upload multiple large files', async ({ page, server, isAndroid, mode }, testInfo) => {
test.skip(isAndroid);
test.skip(isWebView2);
test.skip(mode.startsWith('service'));
test.slow();

View File

@ -143,9 +143,8 @@ test('should upload a file after popup', async ({ page, server, asset }) => {
expect(await page.evaluate(e => e.files[0].name, input)).toBe('file-to-upload.txt');
});
test('should upload large file', async ({ page, server, isAndroid, isWebView2, mode }, testInfo) => {
test('should upload large file', async ({ page, server, isAndroid, mode }, testInfo) => {
test.skip(isAndroid);
test.skip(isWebView2);
test.skip(mode.startsWith('service'));
test.slow();
@ -201,9 +200,8 @@ test('should throw an error if the file does not exist', async ({ page, server,
expect(error.message).toContain('i actually do not exist.txt');
});
test('should upload large file with relative path', async ({ page, server, isAndroid, isWebView2, mode }, testInfo) => {
test('should upload large file with relative path', async ({ page, server, isAndroid, mode }, testInfo) => {
test.skip(isAndroid);
test.skip(isWebView2);
test.skip(mode.startsWith('service'));
test.slow();

View File

@ -20,7 +20,6 @@ import type { TestModeTestFixtures, TestModeWorkerFixtures, TestModeWorkerOption
import { androidTest } from '../android/androidTest';
import { browserTest } from '../config/browserTest';
import { electronTest } from '../electron/electronTest';
import { webView2Test } from '../webview2/webView2Test';
import type { PageTestFixtures, PageWorkerFixtures } from './pageTestApi';
import type { ServerFixtures, ServerWorkerOptions } from '../config/serverFixtures';
import { expect as baseExpect } from '@playwright/test';
@ -32,8 +31,6 @@ if (process.env.PWPAGE_IMPL === 'android')
impl = androidTest;
if (process.env.PWPAGE_IMPL === 'electron')
impl = electronTest;
if (process.env.PWPAGE_IMPL === 'webview2')
impl = webView2Test;
export const test = impl;

View File

@ -35,6 +35,5 @@ export type PageWorkerFixtures = {
electronMajorVersion: number;
isAndroid: boolean;
isElectron: boolean;
isWebView2: boolean;
isHeadlessShell: boolean;
};

View File

@ -1,47 +0,0 @@
/**
* 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 path from 'path';
import childProcess from 'child_process';
import playwright from 'playwright';
export default async () => {
const cdpPort = 9876;
const spawnedProcess = childProcess.spawn(path.join(__dirname, 'webview2-app/bin/Debug/net8.0-windows/webview2.exe'), {
shell: true,
env: {
...process.env,
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: `--remote-debugging-port=${cdpPort}`,
}
});
await new Promise<void>((resolve, reject) => {
spawnedProcess.on('error', error => {
reject(error);
});
spawnedProcess.stdout.on('data', (data: Buffer): void => {
if (data.toString().includes('WebView2 initialized'))
resolve();
});
});
const browser = await playwright.chromium.connectOverCDP(`http://127.0.0.1:${cdpPort}`);
console.log(`Using version ${browser.version()} WebView2 runtime`);
const page = browser.contexts()[0].pages()[0];
await page.waitForURL('about:blank');
await page.goto('data:text/html,');
const chromeVersion = await page.evaluate(() => navigator.userAgent.match(/Chrome\/(.*?) /)[1]);
process.env.PWTEST_WEBVIEW2_CHROMIUM_VERSION = chromeVersion;
await browser.close();
childProcess.spawnSync(`taskkill /pid ${spawnedProcess.pid} /T /F`, { shell: true });
};

View File

@ -1,70 +0,0 @@
/**
* 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 { config as loadEnv } from 'dotenv';
loadEnv({ path: path.join(__dirname, '..', '..', '.env') });
process.env.PWTEST_UNDER_TEST = '1';
import type { Config, PlaywrightTestOptions, PlaywrightWorkerOptions } from '@playwright/test';
import * as path from 'path';
process.env.PWPAGE_IMPL = 'webview2';
const outputDir = path.join(__dirname, '..', '..', 'test-results');
const testDir = path.join(__dirname, '..');
const config: Config<PlaywrightWorkerOptions & PlaywrightTestOptions> = {
testDir,
outputDir,
expect: {
timeout: 10000,
},
timeout: 30000,
globalTimeout: 5400000,
workers: process.env.CI ? 1 : undefined,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 3 : 0,
reporter: process.env.CI ? [
['dot'],
['json', { outputFile: path.join(outputDir, 'report.json') }],
['blob'],
] : 'line',
tag: process.env.PW_TAG,
projects: [],
globalSetup: './globalSetup.ts',
};
const metadata = {
platform: process.platform,
headless: 'headed',
browserName: 'webview2',
channel: undefined,
mode: 'default',
video: false,
};
config.projects.push({
name: 'webview2',
// Share screenshots with chromium.
snapshotPathTemplate: '{testDir}/{testFileDir}/{testFileName}-snapshots/{arg}-chromium{ext}',
use: {
browserName: 'chromium',
headless: false,
},
testDir: path.join(testDir, 'page'),
metadata,
});
export default config;

View File

@ -1,57 +0,0 @@
/**
* 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 { baseTest } from '../config/baseTest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import type { PageTestFixtures, PageWorkerFixtures } from '../page/pageTestApi';
import type { TraceViewerFixtures } from '../config/traceViewerFixtures';
import { traceViewerFixtures } from '../config/traceViewerFixtures';
export { expect } from '@playwright/test';
import { TestChildProcess } from '../config/commonFixtures';
import { chromiumSwitches } from '../../packages/playwright-core/lib/server/chromium/chromiumSwitches';
export const webView2Test = baseTest.extend<TraceViewerFixtures>(traceViewerFixtures).extend<PageTestFixtures, PageWorkerFixtures>({
browserVersion: [process.env.PWTEST_WEBVIEW2_CHROMIUM_VERSION, { scope: 'worker' }],
browserMajorVersion: [({ browserVersion }, use) => use(Number(browserVersion.split('.')[0])), { scope: 'worker' }],
isAndroid: [false, { scope: 'worker' }],
isElectron: [false, { scope: 'worker' }],
electronMajorVersion: [0, { scope: 'worker' }],
isWebView2: [true, { scope: 'worker' }],
isHeadlessShell: [false, { scope: 'worker' }],
browser: [async ({ playwright }, use, testInfo) => {
const cdpPort = 10000 + testInfo.workerIndex;
const spawnedProcess = new TestChildProcess({
command: [path.join(__dirname, 'webview2-app/bin/Debug/net8.0-windows/webview2.exe')],
shell: true,
env: {
...process.env,
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: `--remote-debugging-port=${cdpPort} ${chromiumSwitches().join(' ')}`,
WEBVIEW2_USER_DATA_FOLDER: path.join(fs.realpathSync.native(os.tmpdir()), `playwright-webview2-tests/user-data-dir-${testInfo.workerIndex}`),
}
});
await new Promise<void>(resolve => spawnedProcess.process.stdout.on('data', data => {
if (data.toString().includes('WebView2 initialized'))
resolve();
}));
const browser = await playwright.chromium.connectOverCDP(`http://127.0.0.1:${cdpPort}`);
await use(browser);
await browser.close();
await spawnedProcess.kill('SIGINT');
}, { scope: 'worker' }],
});

View File

@ -1,3 +0,0 @@
obj/
bin/
.vs/

View File

@ -1,64 +0,0 @@
namespace webview2;
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.webView = new Microsoft.Web.WebView2.WinForms.WebView2();
((System.ComponentModel.ISupportInitialize)(this.webView)).BeginInit();
this.SuspendLayout();
//
// webView
//
this.webView.AllowExternalDrop = true;
this.webView.CreationProperties = null;
this.webView.DefaultBackgroundColor = System.Drawing.Color.White;
this.webView.Dock = System.Windows.Forms.DockStyle.Fill;
this.webView.Location = new System.Drawing.Point(0, 0);
this.webView.Name = "webView";
this.webView.Size = new System.Drawing.Size(1280, 720);
this.webView.Source = new System.Uri("about:blank", System.UriKind.Absolute);
this.webView.TabIndex = 0;
this.webView.ZoomFactor = 1D;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1280, 720);
this.Controls.Add(this.webView);
this.Name = "Form1";
this.Text = "Playwright WebView2";
((System.ComponentModel.ISupportInitialize)(this.webView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Microsoft.Web.WebView2.WinForms.WebView2 webView;
}

View File

@ -1,14 +0,0 @@
namespace webview2;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.webView.CoreWebView2InitializationCompleted += (_, e) =>
{
if (e.IsSuccess)
Console.WriteLine("WebView2 initialized");
};
}
}

View File

@ -1,60 +0,0 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,16 +0,0 @@
namespace webview2;
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}

View File

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3240.44" />
</ItemGroup>
</Project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>