Skip to content

Commit 8332830

Browse files
Smoketest/1.0.1222 testing (#126)
* Updates for Win32, WPF and WinForms sample apps from 102.0.1222.0 * Updated package version for Win32, WPF and WinForms sample apps to 1.0.1222-prerelease * Add update windows SDK in steps The CI build failed due to error "error MSB8036: The Windows SDK version 10.0.18362.0 was not found.", so need to install the specific version of Windows SDK on the virtual machine. Co-authored-by: WebView2 Github Bot <[email protected]>
1 parent 1b2542f commit 8332830

22 files changed

+517
-109
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ jobs:
2121
steps:
2222
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2323
- uses: actions/checkout@v2
24+
25+
- name: "Update windows SDK"
26+
uses: fbactions/setup-winsdk@v1
27+
with:
28+
winsdk-build-version: 18362
2429

2530
- name: setup-msbuild
2631
uses: microsoft/setup-msbuild@v1

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "ScenarioClientCertificateRequested.h"
3333
#include "ScenarioCookieManagement.h"
3434
#include "ScenarioCustomDownloadExperience.h"
35+
#include "ScenarioCustomScheme.h"
3536
#include "ScenarioDOMContentLoaded.h"
3637
#include "ScenarioIFrameDevicePermission.h"
3738
#include "ScenarioNavigateWithWebResourceRequest.h"
@@ -525,7 +526,6 @@ bool AppWindow::ExecuteWebViewCommands(WPARAM wParam, LPARAM lParam)
525526
case IDM_SCENARIO_AUTHENTICATION:
526527
{
527528
NewComponent<ScenarioAuthentication>(this);
528-
529529
return true;
530530
}
531531
case IDM_SCENARIO_COOKIE_MANAGEMENT:
@@ -716,13 +716,13 @@ bool AppWindow::ExecuteAppCommands(WPARAM wParam, LPARAM lParam)
716716
//! [ClearBrowsingData]
717717
bool AppWindow::ClearBrowsingData(COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds)
718718
{
719-
auto webView2Experimental8 =
720-
m_webView.try_query<ICoreWebView2Experimental8>();
721-
CHECK_FEATURE_RETURN(webView2Experimental8);
722-
wil::com_ptr<ICoreWebView2ExperimentalProfile> webView2ExperimentalProfile;
723-
CHECK_FAILURE(webView2Experimental8->get_Profile(&webView2ExperimentalProfile));
724-
CHECK_FEATURE_RETURN(webView2ExperimentalProfile);
725-
auto webView2ExperimentalProfile4 = webView2ExperimentalProfile.try_query<ICoreWebView2ExperimentalProfile4>();
719+
auto webView2_12 = m_webView.try_query<ICoreWebView2_12>();
720+
CHECK_FEATURE_RETURN(webView2_12);
721+
wil::com_ptr<ICoreWebView2Profile> webView2Profile;
722+
CHECK_FAILURE(webView2_12->get_Profile(&webView2Profile));
723+
CHECK_FEATURE_RETURN(webView2Profile);
724+
auto webView2ExperimentalProfile4 =
725+
webView2Profile.try_query<ICoreWebView2ExperimentalProfile4>();
726726
CHECK_FEATURE_RETURN(webView2ExperimentalProfile4);
727727
// Clear the browsing data from the last hour.
728728
double endTime = (double)std::time(nullptr);
@@ -978,17 +978,16 @@ HRESULT AppWindow::OnCreateEnvironmentCompleted(
978978
HRESULT AppWindow::CreateControllerWithOptions()
979979
{
980980
//! [CreateControllerWithOptions]
981-
auto webViewEnvironment8 =
982-
m_webViewEnvironment.try_query<ICoreWebView2ExperimentalEnvironment8>();
983-
if (!webViewEnvironment8)
981+
auto webViewEnvironment10 = m_webViewEnvironment.try_query<ICoreWebView2Environment10>();
982+
if (!webViewEnvironment10)
984983
{
985984
FeatureNotAvailable();
986985
return S_OK;
987986
}
988987

989-
Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalControllerOptions> options;
990-
HRESULT hr = webViewEnvironment8->CreateCoreWebView2ControllerOptions(
991-
m_webviewOption.profile.c_str(), m_webviewOption.isInPrivate, options.GetAddressOf());
988+
wil::com_ptr<ICoreWebView2ControllerOptions> options;
989+
// The validation of parameters occurs when setting the properties.
990+
HRESULT hr = webViewEnvironment10->CreateCoreWebView2ControllerOptions(&options);
992991
if (hr == E_INVALIDARG)
993992
{
994993
ShowFailure(hr, L"Unable to create WebView2 due to an invalid profile name.");
@@ -998,14 +997,19 @@ HRESULT AppWindow::CreateControllerWithOptions()
998997
CHECK_FAILURE(hr);
999998
//! [CreateControllerWithOptions]
1000999

1000+
// If call 'put_ProfileName' with an invalid profile name, the 'E_INVALIDARG' returned
1001+
// immediately. ProfileName could be reused.
1002+
CHECK_FAILURE(options->put_ProfileName(m_webviewOption.profile.c_str()));
1003+
CHECK_FAILURE(options->put_IsInPrivateModeEnabled(m_webviewOption.isInPrivate));
1004+
10011005
#ifdef USE_WEBVIEW2_WIN10
10021006
if (m_dcompDevice || m_wincompCompositor)
10031007
#else
10041008
if (m_dcompDevice)
10051009
#endif
10061010
{
1007-
CHECK_FAILURE(webViewEnvironment8->CreateCoreWebView2CompositionControllerWithOptions(
1008-
m_mainWindow, options.Get(),
1011+
CHECK_FAILURE(webViewEnvironment10->CreateCoreWebView2CompositionControllerWithOptions(
1012+
m_mainWindow, options.get(),
10091013
Callback<ICoreWebView2CreateCoreWebView2CompositionControllerCompletedHandler>(
10101014
[this](
10111015
HRESULT result,
@@ -1019,8 +1023,8 @@ HRESULT AppWindow::CreateControllerWithOptions()
10191023
}
10201024
else
10211025
{
1022-
CHECK_FAILURE(webViewEnvironment8->CreateCoreWebView2ControllerWithOptions(
1023-
m_mainWindow, options.Get(),
1026+
CHECK_FAILURE(webViewEnvironment10->CreateCoreWebView2ControllerWithOptions(
1027+
m_mainWindow, options.get(),
10241028
Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
10251029
this, &AppWindow::OnCreateCoreWebView2ControllerCompleted)
10261030
.Get()));
@@ -1078,27 +1082,23 @@ HRESULT AppWindow::OnCreateCoreWebView2ControllerCompleted(HRESULT result, ICore
10781082
// available.
10791083
CHECK_FAILURE(m_webView->get_BrowserProcessId(&m_newestBrowserPid));
10801084
//! [CoreWebView2Profile]
1081-
auto webview2Experimental8 = coreWebView2.try_query<ICoreWebView2Experimental8>();
1082-
if (webview2Experimental8)
1085+
auto webView2_12 = coreWebView2.try_query<ICoreWebView2_12>();
1086+
if (webView2_12)
10831087
{
1084-
wil::com_ptr<ICoreWebView2ExperimentalProfile> profile;
1085-
CHECK_FAILURE(webview2Experimental8->get_Profile(&profile));
1086-
wil::unique_cotaskmem_string profile_path;
1087-
CHECK_FAILURE(profile->get_ProfilePath(&profile_path));
1088-
std::wstring str(profile_path.get());
1089-
m_profileDirName = str.substr(str.find_last_of(L'\\') + 1);
1088+
wil::com_ptr<ICoreWebView2Profile> profile;
1089+
CHECK_FAILURE(webView2_12->get_Profile(&profile));
1090+
wil::unique_cotaskmem_string profile_name;
1091+
CHECK_FAILURE(profile->get_ProfileName(&profile_name));
1092+
m_profileName = profile_name.get();
10901093
BOOL inPrivate = FALSE;
10911094
CHECK_FAILURE(profile->get_IsInPrivateModeEnabled(&inPrivate));
10921095
if (!m_webviewOption.downloadPath.empty())
10931096
{
1094-
auto webView2ExperimentalProfile3 =
1095-
profile.try_query<ICoreWebView2ExperimentalProfile3>();
1096-
CHECK_FAILURE(webView2ExperimentalProfile3->
1097-
put_DefaultDownloadFolderPath(
1098-
m_webviewOption.downloadPath.c_str()));
1097+
CHECK_FAILURE(profile->put_DefaultDownloadFolderPath(
1098+
m_webviewOption.downloadPath.c_str()));
10991099
}
11001100

1101-
// update window title with m_profileDirName
1101+
// update window title with m_profileName
11021102
UpdateAppTitle();
11031103

11041104
// update window icon
@@ -1513,7 +1513,7 @@ bool AppWindow::CloseWebView(bool cleanupUserDataFolder)
15131513
}
15141514

15151515
// reset profile name
1516-
m_profileDirName = L"";
1516+
m_profileName = L"";
15171517
m_documentTitle = L"";
15181518
return true;
15191519
}
@@ -1631,9 +1631,9 @@ std::wstring AppWindow::GetDocumentTitle()
16311631

16321632
void AppWindow::UpdateAppTitle() {
16331633
std::wstring str(m_appTitle);
1634-
if (!m_profileDirName.empty())
1634+
if (!m_profileName.empty())
16351635
{
1636-
str += L" - " + m_profileDirName;
1636+
str += L" - " + m_profileName;
16371637
}
16381638
if (!m_documentTitle.empty())
16391639
{

SampleApps/WebView2APISample/AppWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class AppWindow
222222
std::vector<std::unique_ptr<ComponentBase>> m_components;
223223
// options for creation of webview controller
224224
WebViewCreateOption m_webviewOption;
225-
std::wstring m_profileDirName;
225+
std::wstring m_profileName;
226226

227227
std::unique_ptr<SettingsComponent> m_oldSettingsComponent;
228228

SampleApps/WebView2APISample/ScenarioClientCertificateRequested.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
using namespace Microsoft::WRL;
1111

12-
static PCWSTR NameOfCertificateKind(COREWEBVIEW2_CERTIFICATE_KIND kind);
12+
static PCWSTR NameOfCertificateKind(COREWEBVIEW2_CLIENT_CERTIFICATE_KIND kind);
1313

1414
ScenarioClientCertificateRequested::ScenarioClientCertificateRequested(AppWindow* appWindow)
1515
: m_appWindow(appWindow), m_webView(appWindow->GetWebView())
@@ -23,13 +23,15 @@ ScenarioClientCertificateRequested::ScenarioClientCertificateRequested(AppWindow
2323
m_webView2_5 = m_webView.try_query<ICoreWebView2_5>();
2424
if (m_webView2_5)
2525
{
26-
CHECK_FAILURE(m_webView2_5->add_ClientCertificateRequested(
27-
Callback<ICoreWebView2ClientCertificateRequestedEventHandler>(
28-
[this](
29-
ICoreWebView2* sender,
30-
ICoreWebView2ClientCertificateRequestedEventArgs* args) {
26+
CHECK_FAILURE(
27+
m_webView2_5->add_ClientCertificateRequested(
28+
Callback<ICoreWebView2ClientCertificateRequestedEventHandler>(
29+
[this](
30+
ICoreWebView2* sender,
31+
ICoreWebView2ClientCertificateRequestedEventArgs* args) {
3132
auto showDialog = [this, args] {
32-
wil::com_ptr<ICoreWebView2CertificateCollection> certificateCollection;
33+
wil::com_ptr<ICoreWebView2ClientCertificateCollection>
34+
certificateCollection;
3335
CHECK_FAILURE(args->get_MutuallyTrustedCertificates(&certificateCollection));
3436

3537
wil::unique_cotaskmem_string host;
@@ -41,7 +43,7 @@ ScenarioClientCertificateRequested::ScenarioClientCertificateRequested(AppWindow
4143
UINT certificateCollectionCount;
4244
CHECK_FAILURE(certificateCollection->get_Count(&certificateCollectionCount));
4345

44-
wil::com_ptr<ICoreWebView2Certificate> certificate = nullptr;
46+
wil::com_ptr<ICoreWebView2ClientCertificate> certificate = nullptr;
4547

4648
if (certificateCollectionCount > 0)
4749
{
@@ -57,7 +59,7 @@ ScenarioClientCertificateRequested::ScenarioClientCertificateRequested(AppWindow
5759

5860
CHECK_FAILURE(certificate->get_Issuer(&clientCertificate.Issuer));
5961

60-
COREWEBVIEW2_CERTIFICATE_KIND Kind;
62+
COREWEBVIEW2_CLIENT_CERTIFICATE_KIND Kind;
6163
CHECK_FAILURE(
6264
certificate->get_Kind(&Kind));
6365
clientCertificate.CertificateKind = NameOfCertificateKind(Kind);
@@ -107,9 +109,9 @@ ScenarioClientCertificateRequested::ScenarioClientCertificateRequested(AppWindow
107109
});
108110

109111
return S_OK;
110-
})
111-
.Get(),
112-
&m_ClientCertificateRequestedToken));
112+
})
113+
.Get(),
114+
&m_ClientCertificateRequestedToken));
113115

114116
MessageBox(
115117
nullptr, L"Custom Client Certificate selection dialog will be used next when WebView2 "
@@ -123,13 +125,13 @@ ScenarioClientCertificateRequested::ScenarioClientCertificateRequested(AppWindow
123125
//! [ClientCertificateRequested2]
124126
}
125127

126-
static PCWSTR NameOfCertificateKind(COREWEBVIEW2_CERTIFICATE_KIND kind)
128+
static PCWSTR NameOfCertificateKind(COREWEBVIEW2_CLIENT_CERTIFICATE_KIND kind)
127129
{
128130
switch (kind)
129131
{
130-
case COREWEBVIEW2_CERTIFICATE_KIND_SMART_CARD:
132+
case COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_SMART_CARD:
131133
return L"Smart Card";
132-
case COREWEBVIEW2_CERTIFICATE_KIND_PIN:
134+
case COREWEBVIEW2_CLIENT_CERTIFICATE_KIND_PIN:
133135
return L"PIN";
134136
default:
135137
return L"Other";

SampleApps/WebView2APISample/ScenarioCookieManagement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ ScenarioCookieManagement::ScenarioCookieManagement(AppWindow* appWindow)
2525
CHECK_FAILURE(settings->put_IsWebMessageEnabled(TRUE));
2626

2727
//! [CookieManager]
28-
wil::com_ptr<ICoreWebView2_2> m_webview2;
29-
CHECK_FAILURE(m_appWindow->GetWebView()->QueryInterface(IID_PPV_ARGS(&m_webview2)));
30-
CHECK_FAILURE(m_webview2->get_CookieManager(&m_cookieManager));
28+
auto webview2_2 = m_webView.try_query<ICoreWebView2_2>();
29+
CHECK_FEATURE_RETURN_EMPTY(webview2_2);
30+
CHECK_FAILURE(webview2_2->get_CookieManager(&m_cookieManager));
3131
//! [CookieManager]
3232

3333
SetupEventsOnWebview();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (C) Microsoft Corporation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
#include "stdafx.h"
5+
6+
#include "ScenarioCustomScheme.h"
7+
8+
#include "AppWindow.h"
9+
#include "CheckFailure.h"
10+
11+
#include <Shlwapi.h>
12+
13+
using namespace Microsoft::WRL;
14+
15+
ScenarioCustomScheme::ScenarioCustomScheme(AppWindow* appWindow) : m_appWindow(appWindow)
16+
{
17+
}
18+
ScenarioCustomScheme::~ScenarioCustomScheme()
19+
{
20+
CHECK_FAILURE(
21+
m_appWindow->GetWebView()->remove_WebResourceRequested(m_webResourceRequestedToken));
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (C) Microsoft Corporation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#pragma once
6+
#include "stdafx.h"
7+
8+
#include <string>
9+
10+
#include "AppWindow.h"
11+
#include "ComponentBase.h"
12+
13+
class ScenarioCustomScheme : public ComponentBase
14+
{
15+
public:
16+
ScenarioCustomScheme(AppWindow* appWindow);
17+
~ScenarioCustomScheme() override;
18+
19+
private:
20+
EventRegistrationToken m_webResourceRequestedToken = {};
21+
22+
AppWindow* m_appWindow = nullptr;
23+
};

0 commit comments

Comments
 (0)