Skip to content

Commit

Permalink
Update projects to use latest WebView2 SDK 1.0.1829-prerelease (#188)
Browse files Browse the repository at this point in the history
* Updates for Win32, WPF and WinForms sample apps from 115.0.1829.0

* Updated package version for Win32, WPF and WinForms sample apps to 1.0.1829-prerelease

---------

Co-authored-by: WebView2 Github Bot <webview2github@microsoft.com>
  • Loading branch information
peiche-jessica and WebView2GithubBot authored May 8, 2023
1 parent eac0583 commit 197b4ac
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ScenarioExtensionsManagement : public ComponentBase
// assets/extensions. This extension is treated as the default extension for the
// `InstallDefaultExtensions` and `OffloadDefaultExtensionsIfExtraExtensionsInstalled`
// scenarios.
const std::wstring m_extensionId = L"bhjomlfgkfmjffpoikcekmhcblpgefmc";
const std::wstring m_extensionId = L"emncjacmognpbmnnjciakjihgcahddgc";

// `m_maxInstalledExtensions` is considered to be the maximum number of extensions we can
// have installed, before we have the case of "too many extensions". If we have too many
Expand Down
81 changes: 77 additions & 4 deletions SampleApps/WebView2APISample/SettingsComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,14 +845,14 @@ bool SettingsComponent::HandleWindowMessage(
{
CHECK_FAILURE(m_settings4->put_IsPasswordAutosaveEnabled(FALSE));
MessageBox(
nullptr, L"Password autosave will be disabled after the next navigation.",
nullptr, L"Password autosave will be disabled immediately.",
L"Settings change", MB_OK);
}
else
{
CHECK_FAILURE(m_settings4->put_IsPasswordAutosaveEnabled(TRUE));
MessageBox(
nullptr, L"Password autosave will be enabled after the next navigation.",
nullptr, L"Password autosave will be enabled immediately.",
L"Settings change", MB_OK);
}
//! [PasswordAutosaveEnabled]
Expand All @@ -869,14 +869,14 @@ bool SettingsComponent::HandleWindowMessage(
{
CHECK_FAILURE(m_settings4->put_IsGeneralAutofillEnabled(FALSE));
MessageBox(
nullptr, L"General autofill will be disabled after the next navigation.",
nullptr, L"General autofill will be disabled immediately.",
L"Settings change", MB_OK);
}
else
{
CHECK_FAILURE(m_settings4->put_IsGeneralAutofillEnabled(TRUE));
MessageBox(
nullptr, L"General autofill will be enabled after the next navigation.",
nullptr, L"General autofill will be enabled immediately.",
L"Settings change", MB_OK);
}
//! [GeneralAutofillEnabled]
Expand Down Expand Up @@ -1046,6 +1046,78 @@ bool SettingsComponent::HandleWindowMessage(
//! [ToggleSmartScreen]
return true;
}
case ID_SETTINGS_PROFILE_PASSWORD_AUTOSAVE_ENABLED:
{
//! [ToggleProfilePasswordAutosaveEnabled]
// Get the profile object.
auto webView2_13 = m_webView.try_query<ICoreWebView2_13>();
CHECK_FEATURE_RETURN(webView2_13);
wil::com_ptr<ICoreWebView2Profile> webView2Profile;
CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile));
CHECK_FEATURE_RETURN(webView2Profile);
auto webView2Profile6 = webView2Profile.try_query<ICoreWebView2Profile6>();
CHECK_FEATURE_RETURN(webView2Profile6);

BOOL enabled;
CHECK_FAILURE(webView2Profile6->get_IsPasswordAutosaveEnabled(&enabled));
// Set password-autosave property to the opposite value to current value.
if (enabled)
{
CHECK_FAILURE(webView2Profile6->put_IsPasswordAutosaveEnabled(FALSE));
MessageBox(
nullptr,
L"Password autosave will be disabled immediately in all "
L"WebView2 with the same profile.",
L"Profile settings change", MB_OK);
}
else
{
CHECK_FAILURE(webView2Profile6->put_IsPasswordAutosaveEnabled(TRUE));
MessageBox(
nullptr,
L"Password autosave will be enabled immediately in all "
L"WebView2 with the same profile.",
L"Profile settings change", MB_OK);
}
//! [ToggleProfilePasswordAutosaveEnabled]
return true;
}
case ID_SETTINGS_PROFILE_GENERAL_AUTOFILL_ENABLED:
{
//! [ToggleProfileGeneralAutofillEnabled]
// Get the profile object.
auto webView2_13 = m_webView.try_query<ICoreWebView2_13>();
CHECK_FEATURE_RETURN(webView2_13);
wil::com_ptr<ICoreWebView2Profile> webView2Profile;
CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile));
CHECK_FEATURE_RETURN(webView2Profile);
auto webView2Profile6 = webView2Profile.try_query<ICoreWebView2Profile6>();
CHECK_FEATURE_RETURN(webView2Profile6);

BOOL enabled;
CHECK_FAILURE(webView2Profile6->get_IsGeneralAutofillEnabled(&enabled));
// Set general-autofill property to the opposite value to current value.
if (enabled)
{
CHECK_FAILURE(webView2Profile6->put_IsGeneralAutofillEnabled(FALSE));
MessageBox(
nullptr,
L"General autofill will be disabled immediately in all WebView2 with the "
L"same profile.",
L"Profile settings change", MB_OK);
}
else
{
CHECK_FAILURE(webView2Profile6->put_IsGeneralAutofillEnabled(TRUE));
MessageBox(
nullptr,
L"General autofill will be enabled immediately in all WebView2 with the "
L"same profile.",
L"Profile settings change", MB_OK);
}
//! [ToggleProfileGeneralAutofillEnabled]
return true;
}
case ID_TOGGLE_LAUNCHING_EXTERNAL_URI_SCHEME_ENABLED:
{
//! [ToggleLaunchingExternalUriScheme]
Expand Down Expand Up @@ -1143,6 +1215,7 @@ bool SettingsComponent::HandleWindowMessage(
// a deferral is commented out here.
// wil::com_ptr<ICoreWebView2Deferral> deferral;
// CHECK_FAILURE(args->GetDeferral(&deferral));

// m_appWindow->RunAsync(
// [deferral, showDialog]()
// {
Expand Down
2 changes: 2 additions & 0 deletions SampleApps/WebView2APISample/WebView2APISample.rc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ BEGIN
MENUITEM "Toggle JavaScript", IDM_TOGGLE_JAVASCRIPT
MENUITEM "Toggle Password Autosave", ID_SETTINGS_PASSWORD_AUTOSAVE_ENABLED
MENUITEM "Toggle Pinch Zoom Enabled", ID_SETTINGS_PINCH_ZOOM_ENABLED
MENUITEM "Toggle Profile General Autofill", ID_SETTINGS_PROFILE_GENERAL_AUTOFILL_ENABLED
MENUITEM "Toggle Profile Password Autosave", ID_SETTINGS_PROFILE_PASSWORD_AUTOSAVE_ENABLED
MENUITEM "Toggle Profile Smart Screen", ID_SETTINGS_SMART_SCREEN_ENABLED
MENUITEM "Toggle Replace Images", ID_SETTINGS_REPLACEALLIMAGES
POPUP "Server Certificate Error"
Expand Down
4 changes: 2 additions & 2 deletions SampleApps/WebView2APISample/WebView2APISample.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1777-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1777-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1829-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1829-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1777-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1777-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1829-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1829-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function onHeaderClick() {
console.log("onHeaderClick+");
const header = document.getElementById('header');
document.getElementById('HeaderSpace').innerHTML = header.innerHTML;
document.getElementById('HeaderSpace').textContent = header.textContent;
console.log("onHeaderClick-");
}

Expand Down
82 changes: 82 additions & 0 deletions SampleApps/WebView2APISample/documentation/Testing-Instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ These are instructions for manually testing all the features of the WebView2 API
* [Toggle builtin error page enabled](#Toggle-builtin-error-page-enabled)
* [Toggle general autofill enabled](#Toggle-general-autofill-enabled)
* [Toggle password autosave enabled](#Toggle-password-autosave-enabled)
* [Toggle profile general autofill enabled](#Toggle-profile-general-autofill-enabled)
* [Toggle profile password autosave enabled](#Toggle-profile-password-autosave-enabled)
* [Toggle browser accelerator keys enabled](#Toggle-browser-accelerator-keys-enabled)
* [Toggle Swipe Navigation enabled](#Toggle-Swipe-Navigation-enabled)
* [Toggle SmartScreen enabled](#Toggle-SmartScreen-enabled)
Expand Down Expand Up @@ -694,6 +696,86 @@ Test that enables/disables password autosave
28. Repeat step 9.
29. Expected: There is not an additional drop down box that has been added.

### Toggle profile general autofill enabled

Test that enables/disables profile general autofill
_General autofill is enabled by default._

1. Launch the sample app.
2. Go to `Window -> Create New Window With Option`.
3. Type in profile name and uncheck InPrivate, then click `OK`.
4. Expected: A new app window opened with profile name in its title bar, we call this window as window1.
5. In sample app, repeat step 2.
6. Type in the same profile name as typed in step 3 and uncheck InPrivate, then click OK.
7. Expected: A new app window opened with profile name in its title bar, we call this window as window2.
8. In sample app, repeat step 2.
9. Type in the same profile name as typed in step 3 but check InPrivate, then click OK.
10. Expected: A new window opened with the same profile name in its title bar and the app icon should be different that can indicate it's in private mode, we call this window as window3.
11. In all windows(1-3) navigate to <https://rsolomakhin.github.io/autofill/> (Use this third party site to verify).
12. In window1 enter in any test information into the Profile Autofill section and click `Submit`.
13. In window1 navigate to <https://rsolomakhin.github.io/autofill/>.
14. In all windows(1-3) click on the Name field.
15. Expected: A drop down box with the saved profile information is shown.
16. In all windows(1-3) click on the box.
17. Expected: The profile information is autofilled.
18. In window1 go to `Settings -> Toggle Profile General Autofill`.
19. Expected: Message box that says `General autofill will be disabled immediately in all WebView2 with the same profile.`.
20. Click `OK` inside the popup dialog.
21. In all windows(1-3) click on the Name field.
22. Expected: No drop down box appears.
23. Repeat step 12-14.
24. Expected: No drop down box appears.
25. In window1 go to `Settings -> Toggle Profile General Autofill`.
26. Expected: Message box that says `General autofill will be enabled immediately in all WebView2 with the same profile.`.
27. Click `OK` inside the popup dialog.
28. In all windows(1-3) click on the Name field.
15. Expected: A drop down box with the original saved profile information from step 12 is shown.
16. In all windows(1-3) click on the box.
17. Expected: The profile information is autofilled.

### Toggle profile password autosave enabled

Test that enables/disables password autosave
_Password autosave is disabled by default._

1. Launch the sample app.
2. Go to `Settings -> Toggle Profile General Autofill`.
3. Expected: Message Box that says `General autofill will be disabled immediately in all WebView2 with the same profile.`.
4. Go to `Window -> Create New Window With Option`.
5. Type in profile name and uncheck InPrivate, then click `OK`.
6. Expected: A new app window opened with profile name in its title bar, we call this window as window1.
7. In sample app, repeat step 2.
8. Type in the same profile name as typed in step 3 and uncheck InPrivate, then click OK.
9. Expected: A new app window opened with profile name in its title bar, we call this window as window2.
10. In sample app, repeat step 2.
11. Type in the same profile name as typed in step 3 but check InPrivate, then click OK.
12. Expected: A new window opened with the same profile name in its title bar and the app icon should be different that can indicate it's in private mode, we call this window as window3.
13. In all windows(1-3) navigate to <https://rsolomakhin.github.io/autofill/> (Use this third party site to verify).
14. In window1 enter in any test information into the Username/Password section and click `Submit`.
15. Expected: The window1 navigates to <https://example.com/> and no save password prompt is shown.
16. In window1, navigate to <https://rsolomakhin.github.io/autofill/>.
17. In all windows(1-3) click on the username field.
18. Expected: No drop down box appears. (note: if password information has previously been saved when the password autosave has been enabled, a drop down box will appear.)
19. In window1, go to `Settings -> Toogle Profile Password Autosave`.
20. Expected: Message Box that says `Password autosave will be enabled after the next navigation in all WebView2 with the same profile.`.
21. Click `OK` inside the popup dialog.
22. In window1 enter in any test information into the Username/Password section and click `Submit`.
23. Expected: The app navigates to <https://example.com> and a save password prompt will popup.
24. Click `Save`.
25. In all windows(1-3) navigate to <https://rsolomakhin.github.io/autofill/>.
26. Expected: In window1 see the username and password information is auto-populated.
27. In all windows(1-3) click on the username field.
28. Expected: A drop down box with the saved password information is shown.
29. In window1 go to `Settings -> Toggle Profile Password Autosave`.
30. Expected: Message Box that says `Password autosave will be disabled after the next navigation in all WebView2 with the same profile.`.
31. Click `OK` inside the popup dialog.
32. In window1 delete the information from the username and password fields and enter in new test information and click submit.
33. Expected: No save password prompt is shown.
34. In window1 navigate to <https://rsolomakhin.github.io/autofill/>.
35. Expected: Only the information entered from step 22 is auto-populated.
36. In all windows(1-3) click on the username field.
37. Expected: There is not an additional drop down box that has been added.

### Toggle browser accelerator keys enabled

Test that enabled/disables browser accelerator keys
Expand Down
2 changes: 1 addition & 1 deletion SampleApps/WebView2APISample/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.1777-prerelease" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.1829-prerelease" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.191107.2" targetFramework="native" />
</packages>
3 changes: 3 additions & 0 deletions SampleApps/WebView2APISample/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@
#define ID_TOGGLE_ALLOW_EXTERNAL_DROP 32792
#define ID_SETTINGS_TOGGLE_POST_STATUS_BAR_ACTIVITY 32793
#define ID_SETTINGS_TOGGLE_POST_FAVICON_CHANGED 32794
#define ID_SETTINGS_PROFILE_GENERAL_AUTOFILL_ENABLED 32795
#define ID_SETTINGS_PROFILE_PASSWORD_AUTOSAVE_ENABLED 32796
#define ID_TOGGLE_CUSTOM_SERVER_CERTIFICATE_SUPPORT 32797
#define ID_CLEAR_SERVER_CERTIFICATE_ERROR_ACTIONS 32798
#define ID_SETTINGS_SMART_SCREEN_ENABLED 32799
Expand All @@ -206,6 +208,7 @@
#define IDC_CHECK_USE_OS_REGION 32803
#define ID_CUSTOM_DATA_PARTITION 32804
#define IDC_STATIC -1

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1777-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1829-prerelease" />
</ItemGroup>
<ItemGroup>
<Folder Include="assets\" />
Expand Down
1 change: 1 addition & 0 deletions SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,7 @@ private void ToggleDownloadDialog(object target, RoutedEventArgs e)
void NewWindowWithOptionsCmdExecuted(object target, ExecutedRoutedEventArgs e)
{
var dialog = new NewWindowOptionsDialog();
dialog.CreationProperties = webView.CreationProperties;
if (dialog.ShowDialog() == true)
{
new MainWindow(dialog.CreationProperties).Show();
Expand Down
2 changes: 1 addition & 1 deletion SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1777-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1829-prerelease" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>

0 comments on commit 197b4ac

Please sign in to comment.