-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Feature] Support running extensions with Firefox #7297
Comments
@Pooort Well, this was a best-effort hack that didn't age well. So overall, that's not a bug: it was never officially supported. We probably can support it properly, but that's an engineering effort. The more upvotes this issue gets, the higher we'll prioritize it! |
@aslushnikov I appreciate your effort. It would be nice to have extensions support. Voting up. |
agreed. this would be fantastic. |
This is definitely a much needed feature. It would be great if there is easy support for extension across all browsers since its one of the USP of Playwright. |
It would be nice to have extensions support. Voting up. |
Hi, It will be great to have firefox extension support. Voting up. @aslushnikov are there any plans to make it works? |
I would also like to see this feature integrated. |
Being able to test a website with multiple browsers and commonly used extensions all with the same code will be a real game changer. |
I found another workaround to install add-ons to Firefox. Firefox allows installing addons via RDP (Remote Debugging Protocol). The following shows how to install addons by the RDP client implemented in import { firefox } from 'playwright';
// 'remote' is not defined by "exports" in package.json
import { connect } from './node_modules/web-ext/lib/firefox/remote.js';
const RDP_PORT = 12345;
(async () => {
const browser = await firefox.launch({
headless: false,
args: [ '-start-debugger-server', String(RDP_PORT) ],
firefoxUserPrefs: {
'devtools.debugger.remote-enabled': true,
'devtools.debugger.prompt-connection': false,
}
});
const client = await connect(RDP_PORT);
const resp = await client.installTemporaryAddon("path/to/addon/directory");
console.log("Installed addon with ID", resp.addon.id);
const page = await browser.newPage();
await page.goto('https://mozilla.org');
// ...
})(); Although this example imports an internal module, I believe it's better to use another client, such as Foxdriver (or implement a client yourself). |
@ueokande Here's a full native Node.js implementation of this - no need to use import { Buffer } from 'buffer';
import net from 'net';
export const loadFirefoxAddon = (port: number, host: string, addonPath: string) => {
return new Promise<boolean>((resolve) => {
const socket = net.connect({
port,
host,
});
let success = false;
socket.once('error', () => {});
socket.once('close', () => {
resolve(success);
});
const send = (data: Record<string, string>) => {
const raw = Buffer.from(JSON.stringify(data));
socket.write(`${raw.length}`);
socket.write(':');
socket.write(raw);
};
send({
to: 'root',
type: 'getRoot',
});
const onMessage = (message: any) => {
if (message.addonsActor) {
send({
to: message.addonsActor,
type: 'installTemporaryAddon',
addonPath,
});
}
if (message.addon) {
success = true;
socket.end();
}
if (message.error) {
socket.end();
}
};
const buffers: Buffer[] = [];
let remainingBytes = 0;
socket.on('data', (data) => {
while (true) {
if (remainingBytes === 0) {
const index = data.indexOf(':');
buffers.push(data);
if (index === -1) {
return;
}
const buffer = Buffer.concat(buffers);
const bufferIndex = buffer.indexOf(':');
buffers.length = 0;
remainingBytes = Number(buffer.subarray(0, bufferIndex).toString());
if (!Number.isFinite(remainingBytes)) {
throw new Error('Invalid state');
}
data = buffer.subarray(bufferIndex + 1);
}
if (data.length < remainingBytes) {
remainingBytes -= data.length;
buffers.push(data);
break;
} else {
buffers.push(data.subarray(0, remainingBytes));
const buffer = Buffer.concat(buffers);
buffers.length = 0;
const json = JSON.parse(buffer.toString());
queueMicrotask(() => {
onMessage(json);
});
const remainder = data.subarray(remainingBytes);
remainingBytes = 0;
if (remainder.length === 0) {
break;
} else {
data = remainder;
}
}
}
});
});
}; |
Hello All , I have tried the below code in java to launch extension , its working but its getting launged in nightly . Is this still a limitation or something wrong with the code . Can some one help me here pls ? Playwright playwright = Playwright.create() List Args= new ArrayList<>(); Args.add("--dusable-extension-except="+extpath); BrowserType.LaunchPersistentContextOptions lp= new BrowserType.LaunchPersistentContextOptions(); The above cose is working with extensionbut its loading in Nightly .. is it a limitation or something wrong with code ? |
add pls. |
add pls (python) |
Hi! I have published npm package which enables you to load an extensions on playwright. |
@ueokande I used your package to install the addon. The addon installed successfully but it is asking for permissions and I am not able to give permissions to it. is there any way to do this ? |
Much needed! (java) |
+1 |
…tion We are migrating Chrome extension users over onto the manifest v3 (MV3) build, in time for the June deadline[1]. Once that's finished, only Firefox users will remain on the MV2 build. Let's rename the build, release, and test scripts and related documentation to reflect that change. Note: We unfortunately can't remove the chrome-mv2 build target entirely, since Playwright does not yet support testing Firefox extensions[2]. To test the MV2 code via the integration tests, using the chrome-mv2 build is the best we can do for now. 1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/ 2 - microsoft/playwright#7297
…tion We are migrating Chrome extension users over onto the manifest v3 (MV3) build, in time for the June deadline[1]. Once that's finished, only Firefox users will remain on the MV2 build. Let's rename the build, release, and test scripts and related documentation to reflect that change. Note: We unfortunately can't remove the chrome-mv2 build target entirely, since Playwright does not yet support testing Firefox extensions[2]. To test the MV2 code via the integration tests, using the chrome-mv2 build is the best we can do for now. 1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/ 2 - microsoft/playwright#7297
…tion We are migrating Chrome extension users over onto the manifest v3 (MV3) build, in time for the June deadline[1]. Once that's finished, only Firefox users will remain on the MV2 build. Let's rename the build, release, and test scripts and related documentation to reflect that change. Note: We unfortunately can't remove the chrome-mv2 build target entirely, since Playwright does not yet support testing Firefox extensions[2]. To test the MV2 code via the integration tests, using the chrome-mv2 build is the best we can do for now. 1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/ 2 - microsoft/playwright#7297
…tion We are migrating Chrome extension users over onto the manifest v3 (MV3) build, in time for the June deadline[1]. Once that's finished, only Firefox users will remain on the MV2 build. Let's rename the build, release, and test scripts and related documentation to reflect that change. Note: We unfortunately can't remove the chrome-mv2 build target entirely, since Playwright does not yet support testing Firefox extensions[2]. To test the MV2 code via the integration tests, using the chrome-mv2 build is the best we can do for now. 1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/ 2 - microsoft/playwright#7297
…tion We are migrating Chrome extension users over onto the manifest v3 (MV3) build, in time for the June deadline[1]. Once that's finished, only Firefox users will remain on the MV2 build. Let's rename the build, release, and test scripts and related documentation to reflect that change. Note: We unfortunately can't remove the chrome-mv2 build target entirely, since Playwright does not yet support testing Firefox extensions[2]. To test the MV2 code via the integration tests, using the chrome-mv2 build is the best we can do for now. 1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/ 2 - microsoft/playwright#7297
…tion We are migrating Chrome extension users over onto the manifest v3 (MV3) build, in time for the June deadline[1]. Once that's finished, only Firefox users will remain on the MV2 build. Let's rename the build, release, and test scripts and related documentation to reflect that change. Note: We unfortunately can't remove the chrome-mv2 build target entirely, since Playwright does not yet support testing Firefox extensions[2]. To test the MV2 code via the integration tests, using the chrome-mv2 build is the best we can do for now. 1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/ 2 - microsoft/playwright#7297
+1 (python) |
…tion (#2524) We are migrating Chrome extension users over onto the manifest v3 (MV3) build, in time for the June deadline[1]. Once that's finished, only Firefox users will remain on the MV2 build. Let's rename the build, release, and test scripts and related documentation to reflect that change. Note: We unfortunately can't remove the chrome-mv2 build target entirely, since Playwright does not yet support testing Firefox extensions[2]. To test the MV2 code via the integration tests, using the chrome-mv2 build is the best we can do for now. 1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/ 2 - microsoft/playwright#7297
Much needed feature!! |
would be awesome |
+1 (python) |
This one should be great! (python) |
would be great to have this |
much needed - thanks! |
Another upvote for this. It would also be great if Firefox add-ons for android could be tested although I appreciate this is beyond the scope of this ticket. |
+1 |
Yes, please. |
+1 |
+1 |
1 similar comment
+1 |
We need this! Thanks |
would be great to have 🚀 |
Bump, please! |
upvoting, would be very helpful! |
Context:
Can't connect to the Firefox browser using this code: #2644 (comment)
The code freezes on the:
const browser = await firefox.connect({ wsEndpoint });
I see the browser with extension started, but Playwright can't connect to Firefox.
The text was updated successfully, but these errors were encountered: