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

Current limitations blocking Playwright's WebDriver BiDi adoption #32577

Open
8 of 42 tasks
yury-s opened this issue Sep 12, 2024 · 9 comments
Open
8 of 42 tasks

Current limitations blocking Playwright's WebDriver BiDi adoption #32577

yury-s opened this issue Sep 12, 2024 · 9 comments

Comments

@yury-s
Copy link
Member

yury-s commented Sep 12, 2024

We've spent a couple weeks adding support for Bidi to Playwright and running Playwright tests with the new protocol. The good news is there has been a large progress in Bidi support in Firefox and Chromium, many Playwright tests are now passing. However, there is still a long list of issues that are blocking Playwright from adopting Bidi as the browser automation protocol. At this point the number of bugs we identified is too large to file individual reports for each of them, instead we'll use this issue to describe some of the major problems that we've discovered.

🎉 Current stats are the following:

  • Chromium: 2368 / 3877 passed (3.2m)
  • Firefox: 1469 / 3877 passed (4.1m)

Spec

These are just some of the issue that we discovered while looking at the first cut. There are many other issues that are currently blocked by the ones above.

Implementation

  • Firefox: browsingContext.setViewport fails intermittently with {"type":"error","id":14,"error":"unknown error","message":"AbortError: Actor 'MessageHandlerFrame' destroyed before query 'MessageHandlerFrameParent:sendCommand' was resolved","stacktrace":""}. See this bug report.
  • Firefox: page.setContent doesn't work because of 'Error: page.setContent: SecurityError: The operation is insecure.' in utility context. Bug report
  • Firefox pointerDown/pointerUp/pointerDown/pointerUp in separate input.performActions commands don't generate dblclick event, see 'should dblclick the div' in page-mouse.spec.ts
  • Firefox: script.realmDestroyed comes after browsingContext.contextDestroyed
  • Firefox: script.evaluate exception have no details/message
  • Firefox: browsingContext.contextDestroyed comes before input.performActions response, see 'should not throw UnhandledPromiseRejection when page closes'. I.e. some events can come after browsingContext was destroyed.
  • Firefox: navigation id stays the same for different navigations, see 'should return from goto if new navigation is started'
  • Intermittent Error: Protocol error (script.evaluate): unknown error
    Message: AbortError: Actor 'MessageHandlerFrame' destroyed before query 'MessageHandlerFrameParent:sendCommand' was resolved - apparently fails if a command is sent before about:blank navigation finishes.
  • Firefox: lazy loading iframes are not reported (can be disabled in settings I think)
  • Firefox: setViewport does not affect window.screen.width/height, matchMedia, see 'should emulate device width'
  • Firefox: CSP tests are failing
  • Firefox: "url" not supported yet in network.continueRequest
  • Firefox: no requestfailed event when it's cancelled by the page, see 'should not throw if request was cancelled by the page' in
  • Firefox: 'should amend utf8 post data' - doesn't work with non-latin post data
  • Firefox: 'redirected requests should report overridden headers' - does not allow to override headers on redirects
  • Firefox: browsingContext.create sometimes hangs in parallel tests
  • Firefox: browsingContext.downloadWillBegin is not fired
  • Firefox: "Blocked request with id 15 not found" when sending network.continueWithAuth, authentication not working
  • Firefox: about:blank page is required for firefox to not close even in headless! (--silent didn't work)
  • Firefox: crash reporter dialog, can probably be fixed with settings.
  • Firefox: need canonical settings for testing browser
  • Chromium: Method 'network.setCacheBehavior' is not implemented.
@whimboo
Copy link

whimboo commented Sep 16, 2024

To mention it here as well... Thanks a lot for all the details @yury-s! This is pretty helpful. As stated on the BiDi issue already I've created a Google document that contains all the above details, for collaborative editing. If you could find the time to at least roughly prioritize those features that would be great. You have a better idea what's most important, but I'll also dig into and see what could be the main issues with Firefox specifically to get more tests passing. Thanks!

@yury-s
Copy link
Member Author

yury-s commented Sep 16, 2024

@whimboo I've assigned priorities to some items in the document. Since these are the first major issues we encountered during testing, and many are blockers for further progress, most are marked as P1 or P0. For clarity, I've added definition for the priority values used. Those are priorities from Playwright's perspective. For Browser implementation issues, I highlighted those that result in massive failures (and should be prioritized higher). Beyond that I'd defer prioritization of individual feature bugs to the browser maintainers.

@whimboo
Copy link

whimboo commented Oct 15, 2024

@yury-s some of the listed entries for Firefox are fixed in the meantime. We probably should get the list above updated (items checked) or fully rely on the Google document. It's hard to sync items on both sides - and here I don't have permissions to edit your comment for that purpose.

@yury-s
Copy link
Member Author

yury-s commented Oct 15, 2024

@whimboo thanks for bringing this up, I went ahead and marked resolved items, they should know be in sync with the Google doc.

@whimboo
Copy link

whimboo commented Dec 6, 2024

@yury-s I tried to run some default tests by using the CDP protocol and I noticed that there is quite a difference in the number of tests between Chromium and Firefox. While for Chromium 11961 tests are run for Firefox these are only 3950. Could you please explain the difference? Also is it enough to only care about those 3950 tests which also get run for the bidi-test command?

@yury-s
Copy link
Member Author

yury-s commented Dec 7, 2024

@yury-s I tried to run some default tests by using the CDP protocol and I noticed that there is quite a difference in the number of tests between Chromium and Firefox.

What command did you use to run the tests?

I see same number (4066) when running npm run biditest -- --project='bidi-firefox-nightly-*' and npm run biditest -- --project='bidi-chromium-*'. Note that these commands only execute core tests for playwright library under tests/library and tests/page. There is a lot of other tests for test runner, component testing, installation etc. Those are less relevant to the browser debugging protocol as the features they test are built on top of playwright "library" which provides core interface for browser automation. We don't run them as part of the bidi suite at the moment and your command probably ran some of those or included another configuration for the entire suite.

@whimboo
Copy link

whimboo commented Dec 9, 2024

Thank you Yury! This information was helpful. It's good to know that this subset of tests will be enough to run.

One thing I noticed which leads to differences in behavior especially for tests is that when I run BiDi tests the conditions for browserName == 'firefox' do not match because for these tests the browser name is actually _bidiFirefox. I assume that for tests that as well fail with firefox we can just ignore for bidi and mark it as such in the tests?

@yury-s
Copy link
Member Author

yury-s commented Dec 10, 2024

One thing I noticed which leads to differences in behavior especially for tests is that when I run BiDi tests the conditions for browserName == 'firefox' do not match because for these tests the browser name is actually _bidiFirefox.

Yes, that's correct, we currently use different browser name to simplify implementation. AFAICT there are 139 tests that have special condition for browserName === 'firefox' (either mark as failed or custom expectation or skipped).

I assume that for tests that as well fail with firefox we can just ignore for bidi and mark it as such in the tests?

For some of them yes as they make no sense in Firefox, e.g.

it('should not crash on storage.getDirectory()', async ({ page, server, browserName, isMac }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/18235' });
it.skip(browserName === 'firefox', 'navigator.storage.getDirectory is not a function');
await page.goto(server.EMPTY_PAGE);
const error = await page.evaluate(async () => {
const dir = await navigator.storage.getDirectory();
return dir.name;
}).catch(e => e);
if (browserName === 'webkit') {
if (isMac)
expect(error.message).toContain('UnknownError: The operation failed for an unknown transient reason');
else
expect(error.message).toContain('TypeError: undefined is not an object');
} else {
expect(error).toBeFalsy();
}
});
. But for others Bidi can probably do a better job than Playwright's current implementation, e.g.
test('console event should work in immediately closed popup', async ({ page, browserName }) => {
test.fixme(browserName === 'firefox', 'console message is not reported at all');
const [, message, popup] = await Promise.all([
page.evaluate(async () => {
const win = window.open()!;
(win as any).console.log('hello');
win.close();
}),
page.context().waitForEvent('console'),
page.waitForEvent('popup'),
]);
expect(message.text()).toBe('hello');
expect(message.page()).toBe(popup);
});
can work in Firefox as it does in other browsers.

@whimboo
Copy link

whimboo commented Dec 12, 2024

Yes, that makes sense. But the question would be if the browserName should really be prefixed with _bidi if a second flag like protocol could be used? I could update the expectations and provide a PR if that is known.

Also I can see that when running the bidi tests locally all the tests in library/chromium/ (and others) are run as well. I assume that those are really Chromium specific and most likely should be excluded from running when using WebDriver BiDi. If yes, I can as well update the testIgnore section for the bidi configuration.

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

3 participants