Skip to content

[pull] main from microsoft:main #101

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

Merged
merged 2 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/playwright-core/browsers.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"name": "webkit",
"revision": "2196",
"revision": "2197",
"installByDefault": true,
"revisionOverrides": {
"debian11-x64": "2105",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const disabledFeatures = (assistantMode?: boolean) => [
'DestroyProfileOnBrowserClose',
// See https://github.com/microsoft/playwright/pull/13854
'DialMediaRouteProvider',
// Chromium is disabling manifest version 2. Allow testing it as long as Chromium can actually run it.
// Disabled in https://chromium-review.googlesource.com/c/chromium/src/+/6265903.
'ExtensionManifestV2Disabled',
'GlobalMediaControls',
// See https://github.com/microsoft/playwright/pull/27605
'HttpsUpgrades',
Expand All @@ -41,8 +38,6 @@ const disabledFeatures = (assistantMode?: boolean) => [
'ThirdPartyStoragePartitioning',
// See https://github.com/microsoft/playwright/issues/16126
'Translate',
// https://chromium-review.googlesource.com/c/chromium/src/+/6711453
'ExtensionManifestV2Unsupported',
assistantMode ? 'AutomationControlled' : '',
].filter(Boolean);

Expand Down
3 changes: 0 additions & 3 deletions tests/assets/extension-mv2-simple/content-script.js

This file was deleted.

2 changes: 0 additions & 2 deletions tests/assets/extension-mv2-simple/index.js

This file was deleted.

14 changes: 0 additions & 14 deletions tests/assets/extension-mv2-simple/manifest.json

This file was deleted.

98 changes: 3 additions & 95 deletions tests/library/chromium/extensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,102 +39,10 @@ const it = base.extend<{

it.skip(({ isHeadlessShell }) => isHeadlessShell, 'Headless Shell has no support for extensions');

it.describe('MV2', () => {
it.skip(({ channel }) => channel?.startsWith('chrome'), '--load-extension is not supported in Chrome anymore. https://groups.google.com/a/chromium.org/g/chromium-extensions/c/1-g8EFx2BBY/m/S0ET5wPjCAAJ');

it('should return background pages', async ({ browserType, asset }) => {
const extensionPath = asset('extension-mv2-simple');
const extensionOptions = {
args: [
`--disable-extensions-except=${extensionPath}`,
`--load-extension=${extensionPath}`,
],
};
const context = await browserType.launchPersistentContext('', extensionOptions);
const backgroundPages = context.backgroundPages();
const backgroundPage = backgroundPages.length
? backgroundPages[0]
: await context.waitForEvent('backgroundpage');
expect(backgroundPage).toBeTruthy();
expect(context.backgroundPages()).toContain(backgroundPage);
expect(context.pages()).not.toContain(backgroundPage);
await context.close();
expect(context.pages().length).toBe(0);
expect(context.backgroundPages().length).toBe(0);
});

it('should return background pages when recording video', async ({ browserType, asset }, testInfo) => {
const extensionPath = asset('extension-mv2-simple');
const extensionOptions = {
args: [
`--disable-extensions-except=${extensionPath}`,
`--load-extension=${extensionPath}`,
],
recordVideo: {
dir: testInfo.outputPath(''),
},
};
const context = await browserType.launchPersistentContext('', extensionOptions);
const backgroundPages = context.backgroundPages();
const backgroundPage = backgroundPages.length
? backgroundPages[0]
: await context.waitForEvent('backgroundpage');
expect(backgroundPage).toBeTruthy();
expect(context.backgroundPages()).toContain(backgroundPage);
expect(context.pages()).not.toContain(backgroundPage);
await context.close();
});

it('should support request/response events when using backgroundPage()', async ({ browserType, asset, server }) => {
server.setRoute('/empty.html', (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html', 'x-response-foobar': 'BarFoo' });
res.end(`<span>hello world!</span>`);
});
const extensionPath = asset('extension-mv2-simple');
const extensionOptions = {
args: [
`--disable-extensions-except=${extensionPath}`,
`--load-extension=${extensionPath}`,
],
};
const context = await browserType.launchPersistentContext('', extensionOptions);
const backgroundPages = context.backgroundPages();
const backgroundPage = backgroundPages.length
? backgroundPages[0]
: await context.waitForEvent('backgroundpage');
await backgroundPage.waitForURL(/chrome-extension\:\/\/.*/);
const [request, response, contextRequest, contextResponse] = await Promise.all([
backgroundPage.waitForEvent('request'),
backgroundPage.waitForEvent('response'),
context.waitForEvent('request'),
context.waitForEvent('response'),
backgroundPage.evaluate(url => fetch(url, {
method: 'POST',
body: 'foobar',
headers: { 'X-FOOBAR': 'KEKBAR' }
}), server.EMPTY_PAGE),
]);
expect(request).toBe(contextRequest);
expect(response).toBe(contextResponse);
expect(request.url()).toBe(server.EMPTY_PAGE);
expect(request.method()).toBe('POST');
expect(await request.allHeaders()).toEqual(expect.objectContaining({ 'x-foobar': 'KEKBAR' }));
expect(request.postData()).toBe('foobar');

expect(response.status()).toBe(200);
expect(response.url()).toBe(server.EMPTY_PAGE);
expect(response.request()).toBe(request);
expect(await response.text()).toBe('<span>hello world!</span>');
expect(await response.allHeaders()).toEqual(expect.objectContaining({ 'x-response-foobar': 'BarFoo' }));

await context.close();
});
});

it.describe('MV3', () => {
it.skip(({ channel }) => channel?.startsWith('chrome'), '--load-extension is not supported in Chrome anymore. https://groups.google.com/a/chromium.org/g/chromium-extensions/c/1-g8EFx2BBY/m/S0ET5wPjCAAJ');

it('should return background pages', async ({ launchPersistentContext, asset }) => {
it('should give access to the service worker', async ({ launchPersistentContext, asset }) => {
const extensionPath = asset('extension-mv3-simple');
const context = await launchPersistentContext(extensionPath);
const serviceWorkers = context.serviceWorkers();
Expand All @@ -146,7 +54,7 @@ it.describe('MV3', () => {
expect(context.backgroundPages().length).toBe(0);
});

it('should return background pages when recording video', async ({ launchPersistentContext, asset }, testInfo) => {
it('should give access to the service worker when recording video', async ({ launchPersistentContext, asset }, testInfo) => {
const extensionPath = asset('extension-mv3-simple');
const context = await launchPersistentContext(extensionPath, {
recordVideo: {
Expand All @@ -161,7 +69,7 @@ it.describe('MV3', () => {
await context.close();
});

it('should support request/response events when using backgroundPage()', async ({ launchPersistentContext, asset, server }) => {
it('should support request/response events in the service worker', async ({ launchPersistentContext, asset, server }) => {
it.fixme(true, 'Waiting for https://issues.chromium.org/u/1/issues/407795731 getting fixed.');
process.env.PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS = '1';
server.setRoute('/empty.html', (req, res) => {
Expand Down
Loading