Skip to content

Commit 4a8438e

Browse files
authored
feat: drop special support for chromium extensions mv2 (microsoft#36788)
1 parent b56d472 commit 4a8438e

File tree

5 files changed

+3
-119
lines changed

5 files changed

+3
-119
lines changed

packages/playwright-core/src/server/chromium/chromiumSwitches.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ const disabledFeatures = (assistantMode?: boolean) => [
2525
'DestroyProfileOnBrowserClose',
2626
// See https://github.com/microsoft/playwright/pull/13854
2727
'DialMediaRouteProvider',
28-
// Chromium is disabling manifest version 2. Allow testing it as long as Chromium can actually run it.
29-
// Disabled in https://chromium-review.googlesource.com/c/chromium/src/+/6265903.
30-
'ExtensionManifestV2Disabled',
3128
'GlobalMediaControls',
3229
// See https://github.com/microsoft/playwright/pull/27605
3330
'HttpsUpgrades',
@@ -41,8 +38,6 @@ const disabledFeatures = (assistantMode?: boolean) => [
4138
'ThirdPartyStoragePartitioning',
4239
// See https://github.com/microsoft/playwright/issues/16126
4340
'Translate',
44-
// https://chromium-review.googlesource.com/c/chromium/src/+/6711453
45-
'ExtensionManifestV2Unsupported',
4641
assistantMode ? 'AutomationControlled' : '',
4742
].filter(Boolean);
4843

tests/assets/extension-mv2-simple/content-script.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/assets/extension-mv2-simple/index.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/assets/extension-mv2-simple/manifest.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/library/chromium/extensions.spec.ts

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -39,102 +39,10 @@ const it = base.extend<{
3939

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

42-
it.describe('MV2', () => {
43-
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');
44-
45-
it('should return background pages', async ({ browserType, asset }) => {
46-
const extensionPath = asset('extension-mv2-simple');
47-
const extensionOptions = {
48-
args: [
49-
`--disable-extensions-except=${extensionPath}`,
50-
`--load-extension=${extensionPath}`,
51-
],
52-
};
53-
const context = await browserType.launchPersistentContext('', extensionOptions);
54-
const backgroundPages = context.backgroundPages();
55-
const backgroundPage = backgroundPages.length
56-
? backgroundPages[0]
57-
: await context.waitForEvent('backgroundpage');
58-
expect(backgroundPage).toBeTruthy();
59-
expect(context.backgroundPages()).toContain(backgroundPage);
60-
expect(context.pages()).not.toContain(backgroundPage);
61-
await context.close();
62-
expect(context.pages().length).toBe(0);
63-
expect(context.backgroundPages().length).toBe(0);
64-
});
65-
66-
it('should return background pages when recording video', async ({ browserType, asset }, testInfo) => {
67-
const extensionPath = asset('extension-mv2-simple');
68-
const extensionOptions = {
69-
args: [
70-
`--disable-extensions-except=${extensionPath}`,
71-
`--load-extension=${extensionPath}`,
72-
],
73-
recordVideo: {
74-
dir: testInfo.outputPath(''),
75-
},
76-
};
77-
const context = await browserType.launchPersistentContext('', extensionOptions);
78-
const backgroundPages = context.backgroundPages();
79-
const backgroundPage = backgroundPages.length
80-
? backgroundPages[0]
81-
: await context.waitForEvent('backgroundpage');
82-
expect(backgroundPage).toBeTruthy();
83-
expect(context.backgroundPages()).toContain(backgroundPage);
84-
expect(context.pages()).not.toContain(backgroundPage);
85-
await context.close();
86-
});
87-
88-
it('should support request/response events when using backgroundPage()', async ({ browserType, asset, server }) => {
89-
server.setRoute('/empty.html', (req, res) => {
90-
res.writeHead(200, { 'Content-Type': 'text/html', 'x-response-foobar': 'BarFoo' });
91-
res.end(`<span>hello world!</span>`);
92-
});
93-
const extensionPath = asset('extension-mv2-simple');
94-
const extensionOptions = {
95-
args: [
96-
`--disable-extensions-except=${extensionPath}`,
97-
`--load-extension=${extensionPath}`,
98-
],
99-
};
100-
const context = await browserType.launchPersistentContext('', extensionOptions);
101-
const backgroundPages = context.backgroundPages();
102-
const backgroundPage = backgroundPages.length
103-
? backgroundPages[0]
104-
: await context.waitForEvent('backgroundpage');
105-
await backgroundPage.waitForURL(/chrome-extension\:\/\/.*/);
106-
const [request, response, contextRequest, contextResponse] = await Promise.all([
107-
backgroundPage.waitForEvent('request'),
108-
backgroundPage.waitForEvent('response'),
109-
context.waitForEvent('request'),
110-
context.waitForEvent('response'),
111-
backgroundPage.evaluate(url => fetch(url, {
112-
method: 'POST',
113-
body: 'foobar',
114-
headers: { 'X-FOOBAR': 'KEKBAR' }
115-
}), server.EMPTY_PAGE),
116-
]);
117-
expect(request).toBe(contextRequest);
118-
expect(response).toBe(contextResponse);
119-
expect(request.url()).toBe(server.EMPTY_PAGE);
120-
expect(request.method()).toBe('POST');
121-
expect(await request.allHeaders()).toEqual(expect.objectContaining({ 'x-foobar': 'KEKBAR' }));
122-
expect(request.postData()).toBe('foobar');
123-
124-
expect(response.status()).toBe(200);
125-
expect(response.url()).toBe(server.EMPTY_PAGE);
126-
expect(response.request()).toBe(request);
127-
expect(await response.text()).toBe('<span>hello world!</span>');
128-
expect(await response.allHeaders()).toEqual(expect.objectContaining({ 'x-response-foobar': 'BarFoo' }));
129-
130-
await context.close();
131-
});
132-
});
133-
13442
it.describe('MV3', () => {
13543
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');
13644

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

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

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

0 commit comments

Comments
 (0)