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

webdriver support #281

Merged
merged 48 commits into from
Jun 9, 2021
Merged

webdriver support #281

merged 48 commits into from
Jun 9, 2021

Conversation

chippers
Copy link
Member

@chippers chippers commented May 20, 2021

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Documentation
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes. Issue #___
  • No

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:
I marked this as a draft cause the interfaces are not final. If a release is not planned soon, then this can be merged and the Application interface can be worked on before the next release. LMK if the non-final interface is okay to merge for now and I'll mark it for review.

Overall this was less lines of code than I thought, but putting it together correctly in the right order was important. I guess since we are heavily leveraging existing webdriver servers (WebKitWebDriver and msedgedriver) it was mostly about enabling proper support for them.

Some notes on the changes:

  • webkit2gtk starts webdriver support on v2_18 so I bumped it up to that.
  • unix::ApplicationExt allows setting the automation flag for Application because there is only allowed to be 1 automation context at a time. The other platforms have similar limitations I imagine (just from how webdriver works typically), but webkit2gtk semi-enforces this through the api.
    • Note: By default the context is an automation context. This just means it allows automation and not that it requires it.
  • wry::Application is back for the above reason. It should be thought of/acts like a "browser" where there might be multiple windows and/or tabs but it refers to the same context. Like how incognito mode is a single context that shares multiple windows/tabs. It doesn't really do anything other than represent some context specific data.

I'm thinking that wry::Application can be made into a builder, and start adding items that are getting passed to InnerWebView::new() to it that make sense. So far, I've only moved over data_directory.

Also, because we now have wry specific stuff in application (Application and mod unix), it gets mixed in with the tao re-exports. Maybe we should move the tao re-export to the crate root and maybe also add root re-exports for items expected to be used by most wry applications (EventLoop, WindowBuilder, Application, WebviewBuilder, ect...)

only linux + windows for now

Linux only so far. Until further notice, this entire branch is going to only
work on Linux until I can decide on a good interface to expose WebDriver stuff.

`Application` makes it so that multiple windows can share a single WebContext
and UserContentManager (data directory). This is required for WebDriver because
only a single `WebContext` is allowed to be marked to allow automation. It
seems that macOS and Windows have similar limitations to some extent.

Only the multi_window example has been updated so far.
again, linux only for now.

updated detect_js_ecma example also
is there a better proper fix? probably - but we will be redoing this interface
soon I imagine.
@chippers
Copy link
Member Author

@wusyong tagging you in a comment since I don't want to mark this as Review until we know how we want to expose Application (I'm thinking a builder).

@wusyong
Copy link
Member

wusyong commented May 22, 2021

I prefer to move all the setup of Application type into WebViewBuilder.
I looked up the ApplicationInner for Linux and Windows. And it should be possible to pass those fields into WebViewInner with WebViewBuilder I believe.

@chippers
Copy link
Member Author

I prefer to move all the setup of Application type into WebViewBuilder.
I looked up the ApplicationInner for Linux and Windows. And it should be possible to pass those fields into WebViewInner with WebViewBuilder I believe.

I'll look into this approach

@chippers chippers self-assigned this Jun 7, 2021
@chippers chippers marked this pull request as ready for review June 7, 2021 06:37
@chippers chippers requested a review from a team as a code owner June 7, 2021 06:37
@chippers chippers requested review from a team June 7, 2021 06:37
src/webview/web_context.rs Outdated Show resolved Hide resolved
src/webview/web_context.rs Show resolved Hide resolved
@chippers
Copy link
Member Author

chippers commented Jun 8, 2021

right now the unix::WebContextImpl struct is behind a private crate module, since it's only used internally for now. Realistically this information isn't problematic to expose publicly, should the web_context module be pub (and therefore the unix module and unix::WebContextExt also)?

@chippers chippers requested a review from wusyong June 8, 2021 17:53
wusyong
wusyong previously approved these changes Jun 9, 2021
@wusyong wusyong merged commit 761b2b5 into dev Jun 9, 2021
@wusyong wusyong deleted the feat/webdriver branch June 9, 2021 04:33
@github-actions github-actions bot mentioned this pull request Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants