Skip to content

Commit

Permalink
Smoketest/1.0.1988 testing (#200)
Browse files Browse the repository at this point in the history
* Updates for Win32, WPF and WinForms sample apps from 117.0.1988.0

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

---------

Co-authored-by: WebView2 Github Bot <webview2github@microsoft.com>
  • Loading branch information
plantree and WebView2GithubBot authored Jul 24, 2023
1 parent cb76e6d commit 0ed5a8c
Show file tree
Hide file tree
Showing 30 changed files with 1,694 additions and 432 deletions.
32 changes: 27 additions & 5 deletions SampleApps/WebView2APISample/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "ScenarioExtensionsManagement.h"
#include "ScenarioIFrameDevicePermission.h"
#include "ScenarioNavigateWithWebResourceRequest.h"
#include "ScenarioNotificationReceived.h"
#include "ScenarioPermissionManagement.h"
#include "ScenarioSharedBuffer.h"
#include "ScenarioSharedWorkerWRR.h"
Expand All @@ -50,7 +51,6 @@
#include "SettingsComponent.h"
#include "TextInputDialog.h"
#include "ViewComponent.h"

using namespace Microsoft::WRL;
static constexpr size_t s_maxLoadString = 100;
static constexpr UINT s_runAsyncWindowMessage = WM_APP;
Expand Down Expand Up @@ -554,6 +554,16 @@ bool AppWindow::ExecuteWebViewCommands(WPARAM wParam, LPARAM lParam)
L"CookieManagement", MB_OK);
return true;
}
case IDM_SCENARIO_EXTENSIONS_MANAGEMENT_INSTALL_DEFAULT:
{
NewComponent<ScenarioExtensionsManagement>(this, false);
return true;
}
case IDM_SCENARIO_EXTENSIONS_MANAGEMENT_OFFLOAD_DEFAULT:
{
NewComponent<ScenarioExtensionsManagement>(this, true);
return true;
}
case IDM_SCENARIO_CUSTOM_SCHEME:
{
NewComponent<ScenarioCustomScheme>(this);
Expand Down Expand Up @@ -584,6 +594,11 @@ bool AppWindow::ExecuteWebViewCommands(WPARAM wParam, LPARAM lParam)
NewComponent<ScenarioNavigateWithWebResourceRequest>(this);
return true;
}
case IDM_SCENARIO_NOTIFICATION:
{
NewComponent<ScenarioNotificationReceived>(this);
return true;
}
case IDM_SCENARIO_TESTING_FOCUS:
{
WCHAR testingFocusPath[] = L"ScenarioTestingFocus.html";
Expand Down Expand Up @@ -964,7 +979,7 @@ bool AppWindow::PrintToDefaultPrinter()
printStatus == COREWEBVIEW2_PRINT_STATUS_SUCCEEDED)
{
message = L"Printing " + std::wstring(title.get()) +
L" document to printer is succedded";
L" document to printer is succeeded";
}
else if (
errorCode == S_OK &&
Expand Down Expand Up @@ -1090,7 +1105,7 @@ bool AppWindow::PrintToPrinter()
if (errorCode == S_OK && printStatus == COREWEBVIEW2_PRINT_STATUS_SUCCEEDED)
{
message = L"Printing " + std::wstring(title.get()) +
L" document to printer is succedded";
L" document to printer is succeeded";
}
else if (
errorCode == S_OK &&
Expand Down Expand Up @@ -1298,6 +1313,12 @@ void AppWindow::InitializeWebView()
options5->put_EnableTrackingPrevention(m_TrackingPreventionEnabled ? TRUE : FALSE));
}

Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalEnvironmentOptions> optionsExperimental;
if (options.As(&optionsExperimental) == S_OK)
{
CHECK_FAILURE(optionsExperimental->put_AreBrowserExtensionsEnabled(TRUE));
}

HRESULT hr = CreateCoreWebView2EnvironmentWithOptions(
subFolder, m_userDataFolder.c_str(), options.Get(),
Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
Expand Down Expand Up @@ -1353,11 +1374,11 @@ HRESULT AppWindow::OnCreateEnvironmentCompleted(
CHECK_FAILURE(result);
m_webViewEnvironment = environment;

if (m_webviewOption.entry == WebViewCreateEntry::EVER_FROM_CREATE_WITH_OPTION_MENU)
if (m_webviewOption.entry == WebViewCreateEntry::EVER_FROM_CREATE_WITH_OPTION_MENU
)
{
return CreateControllerWithOptions();
}

auto webViewEnvironment3 = m_webViewEnvironment.try_query<ICoreWebView2Environment3>();

if (webViewEnvironment3 && (m_dcompDevice || m_wincompCompositor))
Expand Down Expand Up @@ -1547,6 +1568,7 @@ HRESULT AppWindow::OnCreateCoreWebView2ControllerCompleted(
//! [AddVirtualHostNameToFolderMapping]
}
NewComponent<ScenarioPermissionManagement>(this);
NewComponent<ScenarioNotificationReceived>(this);

// We have a few of our own event handlers to register here as well
RegisterEventHandlers();
Expand Down
22 changes: 8 additions & 14 deletions SampleApps/WebView2APISample/ClientCertificateSelectionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <ctime>
#include <Windows.h>

#include "stdafx.h"

#include "App.h"
#include "resource.h"
#include "ClientCertificateSelectionDialog.h"

std::wstring UnixEpochToDateTime(double value) {
WCHAR rawResult[32] = {};
std::time_t rawTime = std::time_t(value);
struct tm timeStruct = {};
gmtime_s(&timeStruct, &rawTime);
_wasctime_s(rawResult, 32, &timeStruct);
std::wstring result(rawResult);
return result;
}
#include "Util.h"
#include "resource.h"

static INT_PTR CALLBACK ClientCertificateSelectionBoxDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
Expand Down Expand Up @@ -95,9 +85,13 @@ static INT_PTR CALLBACK ClientCertificateSelectionBoxDlg(HWND hDlg, UINT message
int i = (int)SendMessage(hwndList, LB_GETITEMDATA, lbItem, 0);

TCHAR buff[MAX_PATH];
StringCbPrintf(buff, ARRAYSIZE(buff),
StringCbPrintf(
buff, ARRAYSIZE(buff),
TEXT("Subject: %s\nValid From: %s\nValid To: %s\nCertificate Kind: %s"),
self->clientCertificates[i].Subject, UnixEpochToDateTime(self->clientCertificates[i].ValidFrom).c_str(), UnixEpochToDateTime(self->clientCertificates[i].ValidTo).c_str(), self->clientCertificates[i].CertificateKind);
self->clientCertificates[i].Subject,
Util::UnixEpochToDateTime(self->clientCertificates[i].ValidFrom).c_str(),
Util::UnixEpochToDateTime(self->clientCertificates[i].ValidTo).c_str(),
self->clientCertificates[i].CertificateKind);

SetDlgItemText(hDlg, IDC_CERTIFICATE_STATIC, buff);
return TRUE;
Expand Down
1 change: 0 additions & 1 deletion SampleApps/WebView2APISample/ControlComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ ControlComponent::~ControlComponent()
m_webView->remove_FrameNavigationCompleted(m_frameNavigationCompletedToken);
m_controller->remove_MoveFocusRequested(m_moveFocusRequestedToken);
m_controller->remove_AcceleratorKeyPressed(m_acceleratorKeyPressedToken);

// Undo our modifications to the toolbar elements
for (auto pair : m_tabbableWindows)
{
Expand Down
2 changes: 1 addition & 1 deletion SampleApps/WebView2APISample/ControlComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class ControlComponent : public ComponentBase
wil::com_ptr<ICoreWebView2Controller> m_controller;
wil::com_ptr<ICoreWebView2> m_webView;
Toolbar* m_toolbar;

std::vector<std::pair<HWND, WNDPROC>> m_tabbableWindows;

EventRegistrationToken m_navigationStartingToken = {};
Expand All @@ -49,5 +48,6 @@ class ControlComponent : public ComponentBase
EventRegistrationToken m_navigationCompletedToken = {};
EventRegistrationToken m_moveFocusRequestedToken = {};
EventRegistrationToken m_acceleratorKeyPressedToken = {};
EventRegistrationToken m_unhandledKeyPressedToken = {};
EventRegistrationToken m_frameNavigationCompletedToken = {};
};
Loading

0 comments on commit 0ed5a8c

Please sign in to comment.