Skip to content

Commit b3336b8

Browse files
authored
Merge pull request #196 from MicrosoftEdge/smoketest/1.0.1905-testing
Smoketest/1.0.1905 testing
2 parents d0cad11 + fae190c commit b3336b8

25 files changed

+594
-220
lines changed

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ PCWSTR AppWindow::GetWindowClass()
290290
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
291291
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_WEBVIEW2APISAMPLE);
292292
wcex.lpszClassName = windowClass;
293-
wcex.hIconSm = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SMALL));
293+
wcex.hIconSm = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_WEBVIEW2APISAMPLE));
294294

295295
RegisterClassExW(&wcex);
296296
return windowClass;
@@ -1465,26 +1465,13 @@ HRESULT AppWindow::CreateControllerWithOptions()
14651465

14661466
void AppWindow::SetAppIcon(bool inPrivate)
14671467
{
1468-
HICON newSmallIcon = nullptr;
1469-
HICON newBigIcon = nullptr;
1470-
if (inPrivate)
1471-
{
1472-
static HICON smallInPrivateIcon = reinterpret_cast<HICON>(LoadImage(
1473-
g_hInstance, MAKEINTRESOURCEW(IDI_WEBVIEW2APISAMPLE_INPRIVATE), IMAGE_ICON, 16, 16,
1474-
LR_DEFAULTCOLOR));
1475-
static HICON bigInPrivateIcon = reinterpret_cast<HICON>(LoadImage(
1476-
g_hInstance, MAKEINTRESOURCEW(IDI_WEBVIEW2APISAMPLE_INPRIVATE), IMAGE_ICON, 32, 32,
1477-
LR_DEFAULTCOLOR));
1478-
newSmallIcon = smallInPrivateIcon;
1479-
newBigIcon = bigInPrivateIcon;
1480-
}
1481-
else
1482-
{
1483-
static HICON smallIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_WEBVIEW2APISAMPLE));
1484-
static HICON bigIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SMALL));
1485-
newSmallIcon = smallIcon;
1486-
newBigIcon = bigIcon;
1487-
}
1468+
int iconID = inPrivate ? IDI_WEBVIEW2APISAMPLE_INPRIVATE : IDI_WEBVIEW2APISAMPLE;
1469+
1470+
HICON newSmallIcon = reinterpret_cast<HICON>(
1471+
LoadImage(g_hInstance, MAKEINTRESOURCEW(iconID), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
1472+
HICON newBigIcon = reinterpret_cast<HICON>(
1473+
LoadImage(g_hInstance, MAKEINTRESOURCEW(iconID), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR));
1474+
14881475
reinterpret_cast<HICON>(SendMessage(
14891476
m_mainWindow, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(newSmallIcon)));
14901477
reinterpret_cast<HICON>(
@@ -1804,10 +1791,10 @@ void AppWindow::RegisterEventHandlers()
18041791
[this]
18051792
{
18061793
std::wstring message =
1807-
L"A new version of the Microsoft Edge WebView2 Runtime is available on this machine. ";
1794+
L"We detected there is a new version for the browser.";
18081795
if (m_webView)
18091796
{
1810-
message += L"Do you want to restart the WebView2APISample app? \n\n";
1797+
message += L"Do you want to restart the app? \n\n";
18111798
message +=
18121799
L"Click No if you only want to re-create the webviews. \n";
18131800
message += L"Click Cancel for no action. \n";

SampleApps/WebView2APISample/ProcessComponent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ bool ProcessComponent::HandleWindowMessage(
180180
}
181181
return false;
182182
}
183-
184183
// Show the WebView's PID to the user.
185-
void ProcessComponent::ShowBrowserProcessInfo() {
184+
void ProcessComponent::ShowBrowserProcessInfo()
185+
{
186186
UINT32 processId;
187187
m_webView->get_BrowserProcessId(&processId);
188188

SampleApps/WebView2APISample/ProcessComponent.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class ProcessComponent : public ComponentBase
3232
void CrashBrowserProcess();
3333
void CrashRenderProcess();
3434
void PerformanceInfo();
35-
3635
~ProcessComponent() override;
3736

3837
// Wait for process to exit for timeoutMs, then force quit it if it hasn't.
@@ -50,7 +49,6 @@ class ProcessComponent : public ComponentBase
5049

5150
UINT m_browserProcessId = 0;
5251
wil::com_ptr<ICoreWebView2ProcessInfoCollection> m_processCollection;
53-
5452
EventRegistrationToken m_processFailedToken = {};
5553
EventRegistrationToken m_processInfosChangedToken = {};
5654
};

SampleApps/WebView2APISample/README.md

Lines changed: 337 additions & 14 deletions
Large diffs are not rendered by default.

SampleApps/WebView2APISample/ScenarioWebViewEventMonitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ using namespace Microsoft::WRL;
2020
using namespace std;
2121

2222
static constexpr wchar_t c_samplePath[] = L"ScenarioWebViewEventMonitor.html";
23+
2324
std::wstring WebResourceSourceToString(COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS source)
2425
{
2526
switch (source)

SampleApps/WebView2APISample/ScriptComponent.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ void ScriptComponent::HandleIFrames()
10141014
})
10151015
.Get(),
10161016
NULL));
1017+
10171018
//! [AdditionalAllowedFrameAncestors_2]
10181019
// Set up the event listeners to handle site embedding scenario. The code will take effect
10191020
// when the site embedding page is navigated to and the embedding iframe navigates to the

SampleApps/WebView2APISample/SettingsComponent.cpp

Lines changed: 114 additions & 123 deletions
Large diffs are not rendered by default.

SampleApps/WebView2APISample/SettingsComponent.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class SettingsComponent : public ComponentBase
5656
wil::com_ptr<ICoreWebView2_13> m_webView2_13;
5757
wil::com_ptr<ICoreWebView2_14> m_webView2_14;
5858
wil::com_ptr<ICoreWebView2_15> m_webView2_15;
59+
wil::com_ptr<ICoreWebView2_18> m_webView2_18;
5960
wil::com_ptr<ICoreWebView2Settings> m_settings;
6061
wil::com_ptr<ICoreWebView2Settings2> m_settings2;
6162
wil::com_ptr<ICoreWebView2Settings3> m_settings3;
@@ -67,8 +68,6 @@ class SettingsComponent : public ComponentBase
6768
wil::com_ptr<ICoreWebView2Controller> m_controller;
6869
wil::com_ptr<ICoreWebView2Controller3> m_controller3;
6970
wil::com_ptr<ICoreWebView2Environment> m_webViewEnvironment;
70-
wil::com_ptr<ICoreWebView2Experimental5> m_webViewExperimental5;
71-
wil::com_ptr<ICoreWebView2Experimental21> m_webViewExperimental21;
7271
wil::com_ptr<ICoreWebView2ContextMenuItem> m_displayPageUrlContextSubMenuItem;
7372

7473
bool m_blockImages = false;

SampleApps/WebView2APISample/ViewComponent.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,7 @@ void ViewComponent::Suspend()
422422
{
423423
wil::com_ptr<ICoreWebView2_3> webView;
424424
webView = m_webView.try_query<ICoreWebView2_3>();
425-
if (!webView)
426-
{
427-
ShowFailure(E_NOINTERFACE, L"TrySuspend API not available");
428-
return;
429-
}
425+
CHECK_FEATURE_RETURN_EMPTY(webView);
430426
HRESULT hr = webView->TrySuspend(
431427
Callback<ICoreWebView2TrySuspendCompletedHandler>(
432428
[this](HRESULT errorCode, BOOL isSuccessful) -> HRESULT {
@@ -449,13 +445,9 @@ void ViewComponent::Suspend()
449445
//! [MemoryUsageTargetLevel]
450446
void ViewComponent::ToggleMemoryUsageTargetLevel()
451447
{
452-
wil::com_ptr<ICoreWebView2Experimental5> webView;
453-
webView = m_webView.try_query<ICoreWebView2Experimental5>();
454-
if (!webView)
455-
{
456-
ShowFailure(E_NOINTERFACE, L"MemoryUsageTargetLevel API not available");
457-
return;
458-
}
448+
wil::com_ptr<ICoreWebView2_19> webView;
449+
webView = m_webView.try_query<ICoreWebView2_19>();
450+
CHECK_FEATURE_RETURN_EMPTY(webView);
459451
COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL memory_target_level =
460452
COREWEBVIEW2_MEMORY_USAGE_TARGET_LEVEL_NORMAL;
461453
CHECK_FAILURE(webView->get_MemoryUsageTargetLevel(&memory_target_level));
@@ -477,11 +469,7 @@ void ViewComponent::Resume()
477469
{
478470
wil::com_ptr<ICoreWebView2_3> webView;
479471
webView = m_webView.try_query<ICoreWebView2_3>();
480-
if (!webView)
481-
{
482-
ShowFailure(E_NOINTERFACE, L"Resume API not available");
483-
return;
484-
}
472+
CHECK_FEATURE_RETURN_EMPTY(webView);
485473
webView->Resume();
486474
}
487475
//! [Resume]
Binary file not shown.

0 commit comments

Comments
 (0)