From 928fe12d4f7a61f0e7d53c26f9538598a15195d5 Mon Sep 17 00:00:00 2001 From: Ognjen Sobajic Date: Mon, 25 Mar 2024 13:55:54 -0700 Subject: [PATCH] Update projects to use latest WebView2 SDK 1.0.2470-prerelease (#239) * Updates for Win32, WPF, WinForms, UWP and WinUI3 sample apps from 124.0.2470.0 * Updated package version for Win32, WPF and WinForms sample apps to 1.0.2470-prerelease --- SampleApps/WebView2APISample/AppWindow.cpp | 8 + .../WebView2APISample/ProcessComponent.cpp | 2 +- .../ScenarioFileSystemHandleShare.cpp | 74 +++ .../ScenarioFileSystemHandleShare.h | 22 + .../WebView2APISample.vcxproj | 10 +- .../assets/ScenarioFileSystemHandleShare.html | 94 ++++ .../documentation/Testing-Instructions.md | 434 +++++++++++------- SampleApps/WebView2APISample/packages.config | 2 +- SampleApps/WebView2APISample/small.ico | Bin 0 -> 46227 bytes .../WebView2WindowsFormsBrowser.csproj | 2 +- SampleApps/WebView2WpfBrowser/MainWindow.xaml | 2 + .../WebView2WpfBrowser/MainWindow.xaml.cs | 17 + .../WebView2WpfBrowser.csproj | 2 +- SampleApps/webview2_sample_uwp/readme.md | 4 +- 14 files changed, 499 insertions(+), 174 deletions(-) create mode 100644 SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.cpp create mode 100644 SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.h create mode 100644 SampleApps/WebView2APISample/assets/ScenarioFileSystemHandleShare.html create mode 100644 SampleApps/WebView2APISample/small.ico diff --git a/SampleApps/WebView2APISample/AppWindow.cpp b/SampleApps/WebView2APISample/AppWindow.cpp index 7fceeb78..d0f9005c 100644 --- a/SampleApps/WebView2APISample/AppWindow.cpp +++ b/SampleApps/WebView2APISample/AppWindow.cpp @@ -43,6 +43,7 @@ #include "ScenarioNonClientRegionSupport.h" #include "ScenarioNotificationReceived.h" #include "ScenarioPermissionManagement.h" +#include "ScenarioFileSystemHandleShare.h" #include "ScenarioSharedBuffer.h" #include "ScenarioSharedWorkerWRR.h" #include "ScenarioVirtualHostMappingForPopUpWindow.h" @@ -1333,6 +1334,13 @@ void AppWindow::InitializeWebView() CHECK_FAILURE(options6->put_AreBrowserExtensionsEnabled(TRUE)); } + Microsoft::WRL::ComPtr exp_options2; + if (options.As(&exp_options2) == S_OK) + { + COREWEBVIEW2_SCROLLBAR_STYLE style = COREWEBVIEW2_SCROLLBAR_STYLE_FLUENT_OVERLAY; + CHECK_FAILURE(exp_options2->put_ScrollBarStyle(style)); + } + HRESULT hr = CreateCoreWebView2EnvironmentWithOptions( subFolder, m_userDataFolder.c_str(), options.Get(), Callback( diff --git a/SampleApps/WebView2APISample/ProcessComponent.cpp b/SampleApps/WebView2APISample/ProcessComponent.cpp index 72dda647..a5b9f85b 100644 --- a/SampleApps/WebView2APISample/ProcessComponent.cpp +++ b/SampleApps/WebView2APISample/ProcessComponent.cpp @@ -107,7 +107,7 @@ ProcessComponent::ProcessComponent(AppWindow* appWindow) CHECK_FAILURE(args2->get_ExitCode(&exitCode)); auto argFailedModule = - args.try_query(); + args.try_query(); if (argFailedModule) { CHECK_FAILURE( diff --git a/SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.cpp b/SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.cpp new file mode 100644 index 00000000..5a29e8f1 --- /dev/null +++ b/SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.cpp @@ -0,0 +1,74 @@ +// Copyright (C) Microsoft Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "stdafx.h" + +#include "ScenarioFileSystemHandleShare.h" + +#include "AppWindow.h" +#include "CheckFailure.h" + +#include + +using namespace Microsoft::WRL; + +static constexpr WCHAR c_samplePath[] = L"ScenarioFileSystemHandleShare.html"; + +extern wil::unique_bstr GetDomainOfUri(PWSTR uri); + +ScenarioFileSystemHandleShare::ScenarioFileSystemHandleShare(AppWindow* appWindow) + : m_appWindow(appWindow) +{ + m_webView = m_appWindow->GetWebView(); + + CHECK_FAILURE(m_webView->Navigate(m_appWindow->GetLocalUri(c_samplePath).c_str())); + + CHECK_FAILURE(m_webView->add_NavigationCompleted( + Callback( + [this, appWindow]( + ICoreWebView2* sender, + ICoreWebView2NavigationCompletedEventArgs* args) -> HRESULT + { + wil::com_ptr webview24 = + m_webView.try_query(); + CHECK_FEATURE_RETURN_HRESULT(webview24); + wil::com_ptr environment = + appWindow->GetWebViewEnvironment(); + wil::com_ptr + environment_experimental14 = + environment.try_query(); + CHECK_FEATURE_RETURN_HRESULT(environment_experimental14); + wil::com_ptr rootHandle; + CHECK_FAILURE(environment_experimental14->CreateWebFileSystemDirectoryHandle( + L"C:\\", COREWEBVIEW2_FILE_SYSTEM_HANDLE_PERMISSION_READ_ONLY, + &rootHandle)); + wil::com_ptr webObjectCollection; + IUnknown* webObjects[] = {rootHandle.get()}; + CHECK_FAILURE(environment_experimental14->CreateObjectCollection( + ARRAYSIZE(webObjects), webObjects, &webObjectCollection)); + wil::com_ptr webObjectCollectionView = + webObjectCollection.try_query(); + wil::unique_cotaskmem_string source; + CHECK_FAILURE(m_webView->get_Source(&source)); + + static const wchar_t* expectedDomain = L"appassets.example"; + wil::unique_bstr sourceDomain = GetDomainOfUri(source.get()); + + // Check the source to ensure the message is sent to the correct target content. + if (std::wstring(expectedDomain) == sourceDomain.get()) + { + CHECK_FAILURE(webview24->PostWebMessageAsJsonWithAdditionalObjects( + L"{ \"messageType\" : \"RootDirectoryHandle\" }", + webObjectCollectionView.get())); + } + + return S_OK; + }) + .Get(), + &m_navigationCompletedToken)); +} + +ScenarioFileSystemHandleShare::~ScenarioFileSystemHandleShare() +{ + CHECK_FAILURE(m_webView->remove_WebMessageReceived(m_navigationCompletedToken)); +} diff --git a/SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.h b/SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.h new file mode 100644 index 00000000..7e986148 --- /dev/null +++ b/SampleApps/WebView2APISample/ScenarioFileSystemHandleShare.h @@ -0,0 +1,22 @@ +// Copyright (C) Microsoft Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#pragma once +#include "stdafx.h" + +#include "AppWindow.h" +#include "ComponentBase.h" + +class ScenarioFileSystemHandleShare : public ComponentBase +{ +public: + ScenarioFileSystemHandleShare(AppWindow* appWindow); + ~ScenarioFileSystemHandleShare() override; + +private: + EventRegistrationToken m_navigationCompletedToken = {}; + + AppWindow* m_appWindow = nullptr; + wil::com_ptr m_webView = nullptr; +}; \ No newline at end of file diff --git a/SampleApps/WebView2APISample/WebView2APISample.vcxproj b/SampleApps/WebView2APISample/WebView2APISample.vcxproj index 64df7948..8404cab0 100644 --- a/SampleApps/WebView2APISample/WebView2APISample.vcxproj +++ b/SampleApps/WebView2APISample/WebView2APISample.vcxproj @@ -237,6 +237,7 @@ + @@ -287,6 +288,7 @@ + @@ -320,6 +322,7 @@ + @@ -354,6 +357,9 @@ $(OutDir)\assets + + $(OutDir)\assets + $(OutDir)\assets @@ -452,13 +458,13 @@ - + 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}. - + diff --git a/SampleApps/WebView2APISample/assets/ScenarioFileSystemHandleShare.html b/SampleApps/WebView2APISample/assets/ScenarioFileSystemHandleShare.html new file mode 100644 index 00000000..2e776bd6 --- /dev/null +++ b/SampleApps/WebView2APISample/assets/ScenarioFileSystemHandleShare.html @@ -0,0 +1,94 @@ + + + + + + + + +

File System Explorer

+ +
+
    +
    + + + + \ No newline at end of file diff --git a/SampleApps/WebView2APISample/documentation/Testing-Instructions.md b/SampleApps/WebView2APISample/documentation/Testing-Instructions.md index d2392b68..6b1d21b0 100644 --- a/SampleApps/WebView2APISample/documentation/Testing-Instructions.md +++ b/SampleApps/WebView2APISample/documentation/Testing-Instructions.md @@ -4,101 +4,121 @@ These are instructions for manually testing all the features of the WebView2 API ## Table Of Contents -* [Getting started](#Getting-started) - * [Install a NuGet package Locally in VS](#Install-a-NuGet-package-Locally-in-VS) -* [UI Entries](#ui-entries) - * [File](#File) - * [Save Screenshot](#Save-Screenshot) - * [Get Document Title](#Get-Document-Title) - * [Get Browser Version After Creation](#Get-Browser-Version-After-Creation) - * [Get Browser Version Before Creation](#Get-Browser-Version-After-Creation) - * [Exit](#Exit) - * [Script](#Script) - * [Inject Script](#Inject-Script) - * [Inject Script With Result](#Inject-Script-With-Result) - * [Post Message String](#Post-Message-String) - * [Post Message JSON](#Post-Message-JSON) - * [Add Initialize Script](#addremove-initialize-script) - * [Remove Initialize Script](#addremove-initialize-script) - * [Subscribe to CDP event & Call CDP method](#subscribe-to-cdp-event--call-cdp-method) - * [Open DevTools Window](#Open-DevTools-Window) - * [Window](#Window) - * [Close WebView](#Close-WebView) - * [Create WebView](#Create-WebView) - * [Create New Window](#Create-New-Window) - * [Create New Window With Options](#Create-New-Window-With-Options) - * [Create New Thread](#Create-New-Thread) - * [Process](#Process) - * [Browser Process Info](#Browser-Process-Info) - * [Crash Browser Process](#Crash-Browser-Process) - * [Unresponsive Browser Process](#Unresponsive-Browser-Process) - * [Show Performance Info](#Show-Performance-Info) - * [Process Info With Frame](#Process-Info-With-Frame) - * [Setting](#Setting) - * [Blocked Domains](#Blocked-Domains) - * [Set User Agent](#Set-User-Agent) - * [Toggle JavaScript](#Toggle-JavaScript) - * [Toggle Web Messaging](#Toggle-Web-Messaging) - * [Toggle Fullscreen allowed](#Toggle-Fullscreen-allowed) - * [Toggle Status Bar enabled](#Toggle-Status-Bar-enabled) - * [Toggle DevTools enabled](#Toggle-DevTools-enabled) - * [Toggle ZoomControl enabled](#Toggle-ZoomControl-enabled) - * [Toggle Client Certificate Requested](#Toggle-Client-Certificate-Requested) - * [Toggle Pinch Zoom enabled](#Toggle-Pinch-Zoom-enabled) - * [Toggle Block images](#Toggle-Block-images) - * [JavaScript Dialogs](#JavaScript-Dialogs) - * [Toggle context menus enabled](#Toggle-context-menus-enabled) - * [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) - * [Toggle Hidden PDF toolbar items](#Toggle-hide-PDF-toolbar-items) - * [Toggle Allow External Drop](#Toggle-Allow-External-Drop) - * [Toggle Server Certificate Error](#Toggle-Custom-Server-Certificate-Support) - * [Toggle Launching External URI Scheme enabled](#Toggle-launching-external-uri-scheme-enabled) - * [View](#View) - * [Toggle Visibility](#Toggle-Visibility) - * [WebView Bounds Reference](#WebView-Bounds-Reference) - * [WebView Area](#WebView-Area) - * [WebView Zoom](#WebView-Zoom) - * [WebView Scale](#WebView-Scale) - * [Set Focus](#Set-Focus) - * [Tab In](#Tab-In) - * [Reverse Tab In](#Reverse-Tab-In) - * [Toggle Tab Handling](#Toggle-Tab-Handling) - * [Scenario](#Scenario) - * [Web Messaging](#Web-Messaging) - * [Host Objects](#Host-Objects) - * [Script Debugging](#Script-Debugging) - * [Cookie Management](#Cookie-Management) - * [Cookie Management(Profile)](#Cookie-Management(Profile)) - * [NavigateWithWebResourceRequest](#NavigateWithWebResourceRequest) - * [Client Certificate Requested](#ClientCertificateRequested) - * [Clear Browsing Data](#ClearBrowsingData) - * [Single sign on](#SingleSignOn) - * [Print](#Print) - * [IFrame Device Permission](#IFrame-Device-Permission) - * [Help](#Help) - * [About ...](#about-) - * [Dialogs](#Dialogs) - * [Download Dialog](#Download-Dialog) - * [Find Dialog](#Find-Dialog) - * [Miscellaneous](#Miscellaneous) - * [Accelerator Key Support](#Accelerator-Key-Support) - * [Language](#Language) - * [Saving Password](#Saving-Password) - * [Open Link in New Window From PDF](#Open-Link-in-New-Window-from-PDF) - * [WebView Does Not Crash](#WebView-Does-Not-Crash) - * [Draggable Regions](#Draggable-Regions) - * [Drag and Drop](#Drag-and-Drop) +- [WebView2 API Testing Instructions](#webview2-api-testing-instructions) + - [Table Of Contents](#table-of-contents) + - [Getting started](#getting-started) + - [Install a NuGet package Locally in VS](#install-a-nuget-package-locally-in-vs) + - [UI Entries](#ui-entries) + - [File](#file) + - [Save Screenshot](#save-screenshot) + - [Get Document Title](#get-document-title) + - [Get Browser Version After Creation](#get-browser-version-after-creation) + - [Get Browser Version Before Creation](#get-browser-version-before-creation) + - [Exit](#exit) + - [Script](#script) + - [Inject Script](#inject-script) + - [Inject Script With Result](#inject-script-with-result) + - [Post Message string](#post-message-string) + - [Post Message JSON](#post-message-json) + - [Add/Remove Initialize Script](#addremove-initialize-script) + - [Subscribe to CDP event \& Call CDP method](#subscribe-to-cdp-event--call-cdp-method) + - [Open DevTools Window](#open-devtools-window) + - [Window](#window) + - [Close WebView](#close-webview) + - [Create WebView](#create-webview) + - [Create New Window](#create-new-window) + - [Create New Window With Options](#create-new-window-with-options) + - [Create New Thread](#create-new-thread) + - [Process](#process) + - [Browser Process Info](#browser-process-info) + - [Crash Browser Process](#crash-browser-process) + - [Unresponsive Browser Process](#unresponsive-browser-process) + - [Settings](#settings) + - [Blocked Domains](#blocked-domains) + - [Set User Agent](#set-user-agent) + - [Toggle JavaScript](#toggle-javascript) + - [Toggle Web Messaging](#toggle-web-messaging) + - [Toggle Fullscreen allowed](#toggle-fullscreen-allowed) + - [Toggle Status Bar enabled](#toggle-status-bar-enabled) + - [Toggle DevTools enabled](#toggle-devtools-enabled) + - [Toggle ZoomControl enabled](#toggle-zoomcontrol-enabled) + - [Toggle Pinch Zoom enabled](#toggle-pinch-zoom-enabled) + - [Toggle Client Certificate Requested](#toggle-client-certificate-requested) + - [Toggle Block images](#toggle-block-images) + - [JavaScript Dialogs](#javascript-dialogs) + - [Toggle context menus enabled](#toggle-context-menus-enabled) + - [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) + - [Toggle hide PDF toolbar items](#toggle-hide-pdf-toolbar-items) + - [Toggle Allow External Drop](#toggle-allow-external-drop) + - [Toggle Server Certificate Error](#toggle-server-certificate-error) + - [Toggle Launching External URI Scheme](#toggle-launching-external-uri-scheme) + - [View](#view) + - [Toggle Visibility](#toggle-visibility) + - [WebView Bounds Reference](#webview-bounds-reference) + - [Bounds A](#bounds-a) + - [Bounds B](#bounds-b) + - [Bounds C](#bounds-c) + - [Bounds D](#bounds-d) + - [WebView Area](#webview-area) + - [WebView Zoom](#webview-zoom) + - [WebView Scale](#webview-scale) + - [Set Focus](#set-focus) + - [Tab In](#tab-in) + - [ReverseTab In](#reversetab-in) + - [Toggle Tab Handling](#toggle-tab-handling) + - [WebView DefaultBackgroundColor](#webview-defaultbackgroundcolor) + - [Scenario](#scenario) + - [Web Messaging](#web-messaging) + - [Host Objects](#host-objects) + - [DOM Content Loaded](#dom-content-loaded) + - [Script Debugging](#script-debugging) + - [\[VSCode\] Debugging Setup](#vscode-debugging-setup) + - [\[VSCode\] Single WebView JavaScript Debugging](#vscode-single-webview-javascript-debugging) + - [\[VSCode\] Single WebView TypeScript Debugging](#vscode-single-webview-typescript-debugging) + - [\[VSCode\] Single WebView JavaScript Debugging Using Attach](#vscode-single-webview-javascript-debugging-using-attach) + - [\[VSCode\] Single WebView TypeScript Debugging Using Attach](#vscode-single-webview-typescript-debugging-using-attach) + - [\[VS\] Single WebView JavaScript Debugging (Debugger For Microsoft Edge)](#vs-single-webview-javascript-debugging-debugger-for-microsoft-edge) + - [\[VS\] Single WebView TypeScript Debugging (Debugger For Microsoft Edge)](#vs-single-webview-typescript-debugging-debugger-for-microsoft-edge) + - [Cookie Management](#cookie-management) + - [Cookie Management(Profile)](#cookie-managementprofile) + - [NavigateWithWebResourceRequest](#navigatewithwebresourcerequest) + - [ClientCertificateRequested](#clientcertificaterequested) + - [SingleSignOn](#singlesignon) + - [Clear Browsing Data](#clear-browsing-data) + - [Print](#print) + - [IFrame-Device-Permission](#iframe-device-permission) + - [Accelerator Key Pressed IsBrowserAcceleratorKeyEnabled](#accelerator-key-pressed-is-browser-accelerator-key-enabled) + - [Help](#help) + - [About](#about) + - [Dialogs](#dialogs) + - [Download Dialog](#download-dialog) + - [Find Dialog](#find-dialog) + - [Dragging](#dragging) + - [Draggable Regions](#draggable-regions) + - [Interactive Dragging](#interactive-dragging) + - [Drag and Drop](#drag-and-drop) + - [Hosting Modes](#hosting-modes) + - [Windowed Hosting](#windowed-hosting) + - [Visual Hosting](#visual-hosting) + - [Miscellaneous](#miscellaneous) + - [Accelerator Key Support](#accelerator-key-support) + - [Language](#language) + - [Saving Password](#saving-password) + - [Ctrl Cick a form with post method](#ctrl-cick-a-form-with-post-method) + - [Open Link in New Window from PDF](#open-link-in-new-window-from-pdf) + - [WebView Does Not Crash](#webview-does-not-crash) + - [HTTPS upgrades disabled for API navigations](#https-upgrades-disabled-for-api-navigations) ## Getting started -* Install the [latest Edge Canary Channel](https://www.microsoftedgeinsider.com/download) +- Install the [latest Edge Canary Channel](https://www.microsoftedgeinsider.com/download) ### Install a NuGet package Locally in VS @@ -177,7 +197,7 @@ Test that prompts the user for some script to run in the WebView 4. Click `Cancel` 5. Repeat steps 2-3 6. Type `confirm("Confirm?")` in the text input box and click `OK` -7. Expected: www.bing.com says popup that says `Confirm?` +7. Expected: says popup that says `Confirm?` 8. Click `OK` inside the Confirm Box 9. Expected: dialog closed 10. Expected: ExecuteScript Result popup that says `true` @@ -205,13 +225,13 @@ Test that prompts the user for some script to run in the WebView, and get the er Test that prompts the user for some string web message to the top level document -1. See [Web Messaging](#Web-Messaging) +1. See [Web Messaging](#web-messaging) #### Post Message JSON Test that prompts the user for some JSON web message to the top level document -1. See [Web Messaging](#Web-Messaging) +1. See [Web Messaging](#web-messaging) #### Add/Remove Initialize Script @@ -372,11 +392,11 @@ _It includes foo.com and bar.org by default_ 2. Load 3. Go to `Settings -> Blocked Domains` 4. Expected: Text Input Dialog that prompts the user for a list of blocked domains -5. Add www.bing.com to the list of blocked domains and click `OK` +5. Add to the list of blocked domains and click `OK` 6. Load 7. Expected: Navigation to fails 8. Repeat steps 3-4 -9. Remove www.bing.com from the list of blocked domains and click `OK` +9. Remove from the list of blocked domains and click `OK` 10. Repeat step 6 11. Expected: Navigation to completes @@ -819,6 +839,7 @@ _Swipe left/right to navigate is enabled by default._ 1. Verify that swipe to navigate works again. #### Toggle SmartScreen enabled + Test that enables/disables SmartScreen 1. Launch the sample app @@ -845,6 +866,7 @@ Test that enables/disables SmartScreen 1. Expected: The popup will no longer appear #### Toggle hide PDF toolbar items + Test that hide/show PDF save button and print button. 1. Launch the sample app @@ -923,9 +945,9 @@ Test that makes WebView visible/invisible Notes: -* Top is always 32 (or some non-zero value) to account for sample app UI such as menu bar and address bar -* WebView height is (Bottom - Top) -* WebView width is equal to Right +- Top is always 32 (or some non-zero value) to account for sample app UI such as menu bar and address bar +- WebView height is (Bottom - Top) +- WebView width is equal to Right ##### Bounds A @@ -943,7 +965,7 @@ Top: 32 Right: 712 Bottom: 366 -or, height/width should be 0.5x of [Bounds A](#bounds-A) +or, height/width should be 0.5x of [Bounds A](#bounds-a) ##### Bounds C @@ -952,7 +974,7 @@ Top: 32 Right: 1006 Bottom: 504 -or, height/width should be ~0.707x of [Bounds A](#bounds-A) +or, height/width should be ~0.707x of [Bounds A](#bounds-a) ##### Bounds D @@ -961,7 +983,7 @@ Top: 32 Right: 1509 Bottom: 740 -or, height/width should be ~1.06x of [Bounds A](#bounds-A) +or, height/width should be ~1.06x of [Bounds A](#bounds-a) #### WebView Area @@ -969,13 +991,13 @@ Test that resizes WebView window _Updates the bounds of the WebView window to resize_ 1. Launch the sample app. -1. Go to `View -> WebView Area -> Get WebView Bounds`. Note the current bounds. (See [Bounds A](#Bounds-A)) +1. Go to `View -> WebView Area -> Get WebView Bounds`. Note the current bounds. (See [Bounds A](#bounds-a)) 1. Go to `View -> WebView Area -> 25%` 1. Go to `View -> WebView Area -> Get WebView Bounds`. -1. Expected: WebView size ratio is 25% of bounds in step 2 and WebView was resized. (See [Bounds B](#Bounds-B)) +1. Expected: WebView size ratio is 25% of bounds in step 2 and WebView was resized. (See [Bounds B](#bounds-b)) 1. Go to `View -> WebView Area -> 50%` 1. Go to `View -> WebView Area -> Get WebView Bounds`. -1. Expected: WebView size ratio to 50% of bounds in step 2 and WebView was resized. (See [Bounds C](#Bounds-C)) +1. Expected: WebView size ratio to 50% of bounds in step 2 and WebView was resized. (See [Bounds C](#bounds-c)) 1. Go to `View -> WebView Area -> 100%` 1. Go to `View -> WebView Area -> Get WebView Bounds`. 1. Expected: WebView size matches bounds in step 2 and WebView was resized. @@ -1010,10 +1032,10 @@ getting larger or smaller without the layout of the page changing._ 1. Launch the sample app. 1. Go to `View -> WebView Area -> 50%` -1. Go to `View -> WebView Area -> Get WebView Bounds`. Note the current bounds. (See [Bounds C](#Bounds-C)) +1. Go to `View -> WebView Area -> Get WebView Bounds`. Note the current bounds. (See [Bounds C](#bounds-c)) 1. Go to `View -> WebView Scale -> 1.5x` 1. Go to `View -> WebView Area -> Get WebView Bounds` -1. Expected: WebView size is 1.5x larger than bounds in step 2 - current WebView height is 1.5x larger than height in step 2 and current WebView width is 1.5x larger than width in step 2. (See [Bounds D](#Bounds-D)) +1. Expected: WebView size is 1.5x larger than bounds in step 2 - current WebView height is 1.5x larger than height in step 2 and current WebView width is 1.5x larger than width in step 2. (See [Bounds D](#bounds-d)) 1. Go to `View -> WebView Zoom -> Get WebView Zoom` 1. Expected: WebView zoom factor is set to 1.5x 1. Expected: WebView renders at the new size/zoom (looks larger) without the @@ -1245,7 +1267,7 @@ Test that demonstrates cookie management related APIs using cookie manager got f 1. Close sample app if it is open and re-launch. 2. Go to `Scenario -> Client Certificate Requested -> Use Deferred Custom Client Certificate Selection Dialog`. 3. Expected: Message Box that says `Custom Client Certificate selection dialog will be used next when WebView2 is making a request to an HTTP server that needs a client certificate.` -4. Follow steps 8-19 from [Toggle Client Certificate Requested](#Toggle-Client-Certificate-Requested) if client certificate is not installed, otherwise skip this. +4. Follow steps 8-19 from [Toggle Client Certificate Requested](#toggle-client-certificate-requested) if client certificate is not installed, otherwise skip this. 5. Navigate to . 6. Expected: A custom dialog box with title `Select a certificate for authentication` and certificate/s in the list box. 7. Select a certificate from the list. @@ -1259,6 +1281,7 @@ Test that demonstrates cookie management related APIs using cookie manager got f 14. Expected: Dialog box is closed and server responds with 400 Bad Request (No required SSL Certificate was sent). #### SingleSignOn + 1. Set environment variable WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--enable-features=msSingleSignOnOSForPrimaryAccountIsShared 2. Launch sample app 3. Go to `Scenario -> WebView Event Monitor` @@ -1335,9 +1358,18 @@ Test that demonstrates the frame Permission Requested API. 7. Click `Location Test` for the main frame. 8. Expected: The CoreWebView2Frame permission requests opens a message box to ask user whether they want to accept or deny. +#### Accelerator Key Pressed IsBrowserAcceleratorKeyEnabled +Test that app can allow/block specific browser accelerator keys when `IsBrowserAcceleratorKeyEnabled` settings is set to `FALSE`/`TRUE`. +1. Launch the sample app. +1. Go to `Scenario -> Accelerator Key Pressed`. F7 is expected to always be enabled and Ctr + P is always disabled in this scenario. +1. Click on `Disable all Browser Accelerator`, close pop up dialog, then reload the page. +1. Expected: All browser accelerator keys are disabled, but F7 works. +1. Click on `Enable all Browser Accelerator`, close pop up dialog, then reload the page. +1. Expected: All browser accelerator keys are now enabled, but Ctrl + P will not work. + ### Help -#### About ... +#### About Test that gets `About …` @@ -1348,13 +1380,15 @@ Test that gets `About …` 5. Expected: dialog closed ### Dialogs + Test that various dialogs work as expected. Uses two windows because some crashes are only caught if the app is still running. #### Download Dialog + 1. Launch the sample app. 2. Go to `Window -> Create New Thread`. 3. Expected: A new app window is opened. -4. Navigate to https://demo.smartscreen.msft.net. +4. Navigate to . 5. Scroll down to `App Rep Demos` section and click on `Known Good Program` to download. 6. Expected: Download dialog appears. 7. Minimize app window with download dialog. @@ -1366,6 +1400,7 @@ Test that various dialogs work as expected. Uses two windows because some crashe 13. Expected: App window and download dialog are closed. #### Find Dialog + 1. Launch the sample app. 2. Go to `Window -> Create New Thread`. 3. Expected: A new app window is opened. @@ -1373,6 +1408,117 @@ Test that various dialogs work as expected. Uses two windows because some crashe 5. Close new window. 6. Expected: New window and find dialog are closed. +### Dragging + +#### Draggable Regions + +Test that draggable regions work on WebView2. + +1. Enable Draggable Regions by adding the feature flag `msWebView2EnableDraggableRegions` to `put_AdditionalBrowserArguments` args in `AppWindow::InitializeWebView`. +1. Build and launch the sample app. +1. Select `Script > Inject Script` and paste this code into the text box: + + ```javascript + document.getElementsByClassName('header')[0].style.appRegion = "drag"; + document.getElementsByClassName('center')[0].style.appRegion = "no-drag"; + document.getElementsByClassName('header')[0].style.width = "99%"; + setTimeout(1, function() { document.getElementsByClassName('header')[0].style.width = "100%";}); + ``` + +NOTE: this code briefly changes the size of the 'Microsoft Edge WebView2' header +element on the webpage. This is to trigger a reflow of the document. Without +this the `appRegion` changes would not take place until some document element was resized + +1. Click and drag over the text of 'Microsoft Edge WebView2' header element +1. Expected: Cursor changes to I-bar, text highlights if applicable, sample app + does not drag. Note: may drag if click and drag point is too far from the + text. +1. For following instructions, click in the box, not the text of the 'Microsoft + Edge WebView2' header element. +1. Click and drag 'Microsoft Edge WebView2' element. +1. Expected: Entire sample app should drag +1. Double click on the 'Microsoft Edge WebView2' element. +1. Expected: Sample app should maximize +1. Double click on the 'Microsoft Edge WebView2' element again. +1. Expected: Sample app should restore to previous size +1. Right click on 'Microsoft Edge WebView2' element. +1. Expected: Title bar context menu (non-WebView) should appear +1. Select `maximize` +1. Expected: Sample app will maximize +1. Right click 'Microsoft Edge WebView2' element and select `restore` +1. Expected: Sample app will restore. + +#### Interactive Dragging + +Test that interactive dragging works on Webview2. + +1. Run the application with the following flag + --edge-webview-interactive-dragging. +1. Click Scenario > Non-Client Region Support. +1. Look under the Heading "Interactive Elements". +1. Hover the mouse on the textarea and button. +1. Expected: Cursor should be arrow, the element border should turn red and + increase in size. +1. Drag on text area and button. +1. Expected: The entire app should drag. +1. Click into text area. +1. Expected: Cursor changes to I-bar. +1. Type text into textarea then try to select/highlight it +1. Expected: Text should highlight and the entire app should not drag +1. Click button. +1. Expected: The click counter should increment. + +#### Drag and Drop + +Test that Drag and Drop is supported in WebView2 using both hosting modes. + +1. Launch the sample app. +1. Select text "Runtime version". +1. Click, hold, and drag the selected text to the Query text box. +1. Release mouse over text box to drop text. +1. Expected: "Runtime version" text is inserted into Query text box. +1. Go to `Window -> Close WebView.` +1. Go to `Window -> WebView Creation Mode -> Visual - DComp.` +1. Go to `Window -> Create WebView.` +1. Select text "Runtime version". +1. Click, hold, and drag the selected text to the Query text box. +1. Release mouse over text box to drop text. +1. Expected: "Runtime version" text is inserted into Query text box. +1. Go to `Window -> Close WebView.` +1. Expected: App does not crash. + +### Hosting Modes + +#### Windowed Hosting + +The majority of the tests in this document are tested using Windowed/HWND hosting, which is the default. +We don't need other specific tests for Windowed Hosting. + +#### Visual Hosting + +Verify that basic hosting functionality continues to work when hosted using visuals. + +1. Launch the sample app. +1. Go to `Window -> Close WebView`. +1. Go to `Window -> WebView Creation Mode -> Visual - DComp`. +1. Go to `Window -> Create WebView`. +1. Move mouse to the Query text box in the webpage. +1. Expected: Cursor should change from a pointer to I-beam text cursor. +1. Click in Query text box. +1. Expected: Focus moves to the text box and insertion caret shows up in the text box. +1. Type "Hello world" in the Query text box. +1. Expected: Text shows up in text box. +1. Press `Windows + period` on the keyboard. +1. Expected: Emoji picker popup appears, positioned to the bottom right of the insertion point. +1. Click on any emoji to insert it. +1. Expected: Chosen emoji is inserted in the text box. +1. Close the emoji picker. +1. Drag the window to a new location on screen. +1. Repeat steps 5 - 15. +1. Expected: Webpage moves to new location. +1. Expected: Cursor changes from hovering and clicking text box are in the new location. +1. Expected: Emoji picker is in the new location. + ### Miscellaneous #### Accelerator Key Support @@ -1382,11 +1528,11 @@ Verify that accelerator key routing works 1. Launch the sample app. 2. Put focus inside the webpage. 3. For each of the following accelerator keys, press it while the webview is focused, and verify that the expected result happens. - * `CTRL-S`: The save screenshot dialog opens. Press cancel to close it. - * `CTRL-N`: A new app window opens. - * `CTRL-T`: A new app window opens. - * `CTRL-W`: The webview inside the current app window closes. - * `CTRL-Q`: The current app window closes. + - `CTRL-S`: The save screenshot dialog opens. Press cancel to close it. + - `CTRL-N`: A new app window opens. + - `CTRL-T`: A new app window opens. + - `CTRL-W`: The webview inside the current app window closes. + - `CTRL-Q`: The current app window closes. #### Language @@ -1410,7 +1556,7 @@ Verify that we don't offer saving password. 1. Launch the sample app. 2. Load , ignore any iframe navigation failure messages during the test. -3. Type in some test email and password, like test@example.com and 12345678 in Email and Password field on the right part of the page. +3. Type in some test email and password, like and 12345678 in Email and Password field on the right part of the page. 4. Click `Submit` button, the page should show the inputted values. 5. Make sure that there is no browser prompt for saving password with strings like `Microsoft Edge will save and fill your password for this site next time`. 6. Reload the page, ignore any iframe navigation failure messages during the test. @@ -1442,6 +1588,7 @@ Verify that the `NewWindowRequested` event is fired when opening a link in new w 6. Expected: Event Monitor displays `NewWindowRequested`. #### WebView Does Not Crash + Test that there is no crash in WebView processes for some of the error prone scenarios. 1. Launch the sample app. @@ -1455,54 +1602,9 @@ Test that there is no crash in WebView processes for some of the error prone sce 1. Expected: The WebView in first app window does not render the start page anymore, while no browser process failure message box is observed for the newly created app window. 1. Wait for 1 minute, expect no browser process failure message box is observed for the newly created app window. -#### Draggable Regions -Test that draggable regions work on WebView2. -1. Enable Draggable Regions by adding the feature flag `msWebView2EnableDraggableRegions` to `put_AdditionalBrowserArguments` args in `AppWindow::InitializeWebView`. -1. Build and launch the sample app. -1. Select `Script > Inject Script` and paste this code into the text box: - - ```javascript - document.getElementsByClassName('header')[0].style.appRegion = "drag"; - document.getElementsByClassName('center')[0].style.appRegion = "no-drag"; - document.getElementsByClassName('header')[0].style.width = "99%"; - setTimeout(1, function() { document.getElementsByClassName('header')[0].style.width = "100%";}); - ``` - -NOTE: this code briefly changes the size of the 'Microsoft Edge WebView2' header -element on the webpage. This is to trigger a reflow of the document. Without -this the `appRegion` changes would not take place until some document element was resized -1. Click and drag over the text of 'Microsoft Edge WebView2' header element -1. Expected: Cursor changes to I-bar, text highlights if applicable, sample app - does not drag. Note: may drag if click and drag point is too far from the - text. -1. For following instructions, click in the box, not the text of the 'Microsoft - Edge WebView2' header element. -1. Click and drag 'Microsoft Edge WebView2' element. -1. Expected: Entire sample app should drag -1. Double click on the 'Microsoft Edge WebView2' element. -1. Expected: Sample app should maximize -1. Double click on the 'Microsoft Edge WebView2' element again. -1. Expected: Sample app should restore to previous size -1. Right click on 'Microsoft Edge WebView2' element. -1. Expected: Title bar context menu (non-WebView) should appear -1. Select `maximize` -1. Expected: Sample app will maximize -1. Right click 'Microsoft Edge WebView2' element and select `restore` -1. Expected: Sample app will restore. +#### HTTPS upgrades disabled for API navigations -#### Drag and Drop -Test that Drag and Drop is supported in WebView2 using both hosting modes. 1. Launch the sample app. -1. Select text "Runtime version". -1. Click, hold, and drag the selected text to the Query text box. -1. Release mouse over text box to drop text. -1. Expected: "Runtime version" text is inserted into Query text box. -1. Go to `Window -> Close WebView.` -1. Go to `Window -> WebView Creation Mode -> Visual - DComp.` -1. Go to `Window -> Create WebView.` -1. Select text "Runtime version". -1. Click, hold, and drag the selected text to the Query text box. -1. Release mouse over text box to drop text. -1. Expected: "Runtime version" text is inserted into Query text box. -1. Go to `Window -> Close WebView.` -1. Expected: App does not crash. +2. Navigate to `http://privacy-test-pages.site/privacy-protections/https-upgrades/` +3. Expected: Observe that the page loads on http and does not try to redirect to https + and go into a redirect loop. diff --git a/SampleApps/WebView2APISample/packages.config b/SampleApps/WebView2APISample/packages.config index a1f4e011..76b23789 100644 --- a/SampleApps/WebView2APISample/packages.config +++ b/SampleApps/WebView2APISample/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/SampleApps/WebView2APISample/small.ico b/SampleApps/WebView2APISample/small.ico new file mode 100644 index 0000000000000000000000000000000000000000..b3ec03bd617f32e58128fa977fd6ac9605124f4b GIT binary patch literal 46227 zcmeG_3s@7^(i=en%FAlCDneRC>$M_k6<<8GwYF8!R&T*-0nuNr4^Sy8A`n5bmRqT{ zK5o_G(b(u^yZQ8UkW5(>;x9{lDqk(~eD_5>eNlDqb zapUaSv*o2vfswy>543gya=eTKJ}bJsb08RyLkrbzg~EDF)&yx{%~3lMOmjI z2r>fq&!#BLn;*SDdg=``Ge%vn(_ zHtGJ!s?^=xQ)VolXES2J@MURR$8V^WUk}@~H&O9u;)XhDr?A*8NV1jpnGS9@R3zjJlMS^bL*v(^3?X@it_xf^eOAIF1)HHQBqYfeohaonv$Cm)jId+ zOVxIDS1y%GYM&OxMbuR%tEwZv6c&U_detcl+-(L0I+vtX6%TS(6-esN{F)w7bMOD| zOWW0^33nGuWA6=U_k~Z`_8H2%Xi~K^>vZ`oLJj;+dof+Rb*dtUE!B9(#yAE zinCMDvqwpLLl>`DVqzVqn&SNSS4zywZ(O!oQ5+P}ZqDo*iQywp2?H;6m*1FM+v(ik zKuPue2llH<lpzzQC0ZQ&fW!@2| zCA+sBFDXoZ&s`OJt!UeG*-;nSw@IqwS!bgXV{4brPy0l^ru(7V((LEr;MieH9$eol ztF#|gWOnaxM#TNAhX?ycZV#28>t6U2vUhev*6X=!y^Cyctm@*mSw&||2b89k2T12S zs5WPQGwMKAfV2p*(!)o6B2$E!rv#ZHO0PlduB^0pWIyVm*{I^DzUzC8eCW8? z=BFT&pQ;pzy=-=tzc!;ZH7GzD1d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_1BtfjM--f`=9IcLrc-IVu9EHCBN^1_rLc0 zHMpJwVULHV@)_IzP1U2Re7ydA{NPyNnvh=mXDmQrl zgvC#v#cJ#<57EsKj50Z#^J8#ivG&ywlWS6_Jpec?yx zxj<(;>ygOTy{SG&Uy}1OnAWGOzVZh80(I0nYXN!m`3vV%3^}*Q)`NLg6Mew0=bA?y z*gnBizg*Y9cYJY_@nqfC^oix4Qmc+gMvaf#%Wl+G8F*R8j$Df>NMHP`dl6Do;zmXf zBMwMBvTwC zx39j>7!rS6{Q6h+KReEwlW$7=HK#o`Z)qBF5hqHnq=@mnn;+b+r$5xQ~!YXt>yn zzw>PDchx$4fo*6#2|*s8mGem3Ty4g^FRpu;EMH(-9_R;6+stQlgMS;`*!Kpwm&M#S z)!2z`5*>8z;ozPO>dp2s?lm#@YcS1@5#+)BD<++$T?t@60IfbiU*HAhA^jo~Ren=!kukg)&8SBOE_~-UA>GK&yWsuhIb4Bal23BMSwUQPd=3>6gt zkl&Mem_kO+1$GfTIbpUKAnyCPU - + diff --git a/SampleApps/WebView2WpfBrowser/MainWindow.xaml b/SampleApps/WebView2WpfBrowser/MainWindow.xaml index d81f5e5e..a4dcfde3 100644 --- a/SampleApps/WebView2WpfBrowser/MainWindow.xaml +++ b/SampleApps/WebView2WpfBrowser/MainWindow.xaml @@ -98,6 +98,7 @@ found in the LICENSE file. + @@ -225,6 +226,7 @@ found in the LICENSE file. + diff --git a/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs b/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs index 95129b52..5c302eb0 100644 --- a/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs +++ b/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs @@ -3317,7 +3317,24 @@ string GetJSONStringField(string jsonMessage, string fieldName) void FileExplorerExecuted(object target, ExecutedRoutedEventArgs e) { +#if USE_WEBVIEW2_EXPERIMENTAL + webView.CoreWebView2.NavigationCompleted += delegate ( + object webview2, CoreWebView2NavigationCompletedEventArgs args) + { + if (args.IsSuccess && webView.CoreWebView2.Source.Equals("https://appassets.example/ScenarioFileSystemHandleShare.html")) + { + webView.CoreWebView2.PostWebMessageAsJsonWithAdditionalObjects("{ \"messageType\" : \"RootDirectoryHandle\" }", new List() + { + webView.CoreWebView2.Environment.CreateWebFileSystemDirectoryHandle( + "C:\\", + CoreWebView2FileSystemHandlePermission.ReadOnly) + }); + } + }; + webView.Source = new Uri("https://appassets.example/ScenarioFileSystemHandleShare.html"); +#endif } + void ThrottlingControlExecuted(object target, ExecutedRoutedEventArgs e) { } diff --git a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj index cdc97525..7a1b01ff 100644 --- a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj +++ b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj @@ -61,7 +61,7 @@ - + diff --git a/SampleApps/webview2_sample_uwp/readme.md b/SampleApps/webview2_sample_uwp/readme.md index 045549c2..ce2ba5e9 100644 --- a/SampleApps/webview2_sample_uwp/readme.md +++ b/SampleApps/webview2_sample_uwp/readme.md @@ -19,8 +19,8 @@ urlFragment: webview2_sample_uwp This sample, **webview2_sample_uwp**, embeds a WebView2 control within a WinUI 2 (UWP) app. -This sample is built as a UWP Visual Studio 2019 project. It uses C++ and HTML/CSS/JavaScript in the WebView2 environment. +This sample is built as a UWP Visual Studio 2022 project. It uses C++ and HTML/CSS/JavaScript in the WebView2 environment. For more information, see [WinUI 2 (UWP) sample app](https://learn.microsoft.com/microsoft-edge/webview2/samples/webview2_sample_uwp). -![The running WinUI 2 (UWP) sample app](screenshots/webview2_sample_uwp-webpage-content.png) +![The running WinUI 2 (UWP) sample app](screenshots/webview2_sample_uwp-webpage-content.png) \ No newline at end of file