Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Fall back to WebBrowser controls when running as admin #250

Merged
merged 1 commit into from
May 15, 2020

Conversation

Andreas-Hjortland
Copy link
Contributor

Fixes #13

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

The current behavior is that if you run an application which contains a WebViewCompatible control as administrator the WebViewCompatible controller will not show up (will just be a blank view). See #13 for more details

What is the new behavior?

With this change, the application will fall back to using WebBrowser (legacy) controls when running the application elevated as administrator so that it the views will still work.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
    • I ran the test suite on x86 and x64 both in .net Framweork and in .net core 3.0, but I don't have any windows ARM devices to run the test suite on. Note that you need to run the test as administrator for it to pass (otherwise it will be inconclusive), and that will make all the other WebView tests fail
  • Pull Request has been submitted to the documentation repository instructions. Link:
    • I have not changed any public APIs, so I am not sure it is neccessary to update the documentation
  • Sample in sample app has been added / updated (for bug fixes / features)
    • Icon has been created (if new sample) following the [Thumbnail Style Guide and templates (https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)
    • As mentioned, this does not have any public changes so I am not sure if we need to add a sample
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

Just to reiterate for the new tests to pass, we need to run the test suite as administrator, and that will unfortunately make the other tests fail since WebView does not work when running as administrator.

The Edge WebView does not at the time of this writing (28. march 2020)
support running in an application with elevated permissions. This commit
adds a test to `WebViewControlHost.IsSupported` which checks if the
application is running as an administrator so that `WebViewCompatible`
will fall back to using the legacy WebBrowser controls.

The tests will unfortunately only work when running the test suite as
administrator, and that will make all the other tests fail.  The test
will therefore be marked as inconclusive instead of failling when the
test suite is running as a non elevated user so that we won't always
have at least one breaking test when we run the test suite.
@ghost
Copy link

ghost commented Mar 28, 2020

Thanks Andreas-Hjortland for opening a Pull Request! The reviewers will test the PR and highlight if there is any merge conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost assigned Kyaa-dost Mar 28, 2020
@dnfclas
Copy link

dnfclas commented Mar 28, 2020

CLA assistant check
All CLA requirements met.

@Andreas-Hjortland
Copy link
Contributor Author

Andreas-Hjortland commented Mar 28, 2020

It would be better if we could support Edge WebView when running as an administrator, but I think this could be a good compromise if that is not possible, or a stopgap solution until we do support running Edge WebView as administrator

@michael-hawker michael-hawker added the WebView 🖥️ WPF and WinForms WebView label Apr 21, 2020
Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this stop-gap measure @Andreas-Hjortland! Sorry for the delay in reviewing this, but I just checked it out with WebViewCompatible on .NET Framework and Core and it worked like a charm and switched to IE 11 mode when running as Admin!

This'll be in the 6.1 release of the toolkit coming in a couple of weeks!

If you have a chance mind updating the documentation file here with this new behavior note? Thanks!

@Andreas-Hjortland
Copy link
Contributor Author

Done, you can check it out at MicrosoftDocs/WindowsCommunityToolkitDocs#336

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
WebView 🖥️ WPF and WinForms WebView
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebView can't run as administrator
4 participants