Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ steps:
arguments: 'restore build\packages.TestInProduction.config -Source $(WinUIInternalFeedUri) -PackagesDirectory $(Build.SourcesDirectory)\packages'
includeNuGetOrg: false

# Note: Restore the WebView2 Runtime package from the authenticated WinUI.Dependencies feed.
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet restore WebView2 Runtime installer'
condition: succeeded()
inputs:
command: 'custom'
arguments: 'restore build\packages.webview2.config -Source $(WinUIInternalFeedUri) -PackagesDirectory $(Build.SourcesDirectory)\packages'
includeNuGetOrg: false

- task: VSBuild@1
displayName: 'Restore Maestro dependencies'
condition: and(succeeded(), ne(variables['Build.Repository.Provider'], 'GitHub'), ne(variables['Build.Repository.Provider'], 'GitHubEnterprise'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ jobs:
script: |
Get-Item -Path 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion'

# Validation-only provisioning until Evergreen is included in the Win10-2019-LTSC image.
- ${{ if eq( parameters.testOS, 'Win10-RS5' ) }}:
- task: PowerShell@2
displayName: 'Install Evergreen WebView2 Runtime on RS5'
inputs:
targetType: 'inline'
script: |
$ErrorActionPreference = 'Stop'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$installerPath = Join-Path $env:Agent_TempDirectory 'MicrosoftEdgeWebview2Setup.exe'
try {
Invoke-WebRequest -UseBasicParsing -Uri 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' -OutFile $installerPath

$signature = Get-AuthenticodeSignature -FilePath $installerPath
if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'O=Microsoft Corporation') {
throw "Evergreen WebView2 bootstrapper signature validation failed. Status: $($signature.Status); signer: $($signature.SignerCertificate.Subject)"
}

$installer = Start-Process -FilePath $installerPath -ArgumentList '/silent', '/install' -Wait -PassThru
if ($installer.ExitCode -ne 0) {
throw "Evergreen WebView2 bootstrapper exited with code $($installer.ExitCode)."
}
}
finally {
Remove-Item -Path $installerPath -Force -ErrorAction SilentlyContinue
}

- template: WinUI-DownloadPipelineArtifacts-Steps.yml
parameters:
itemPattern: '**/@(helixworkitems|TestPayload)/**'
Expand Down
70 changes: 10 additions & 60 deletions controls/dev/WebView2/InteractionTests/WebView2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void ClassInitialize(TestContext testContext)
EnsureBrowser();
}

// Ensure a suitable version of Edge browser or WebView2 runtime is present. If not, use mini_installer to install the runtime.
// Ensure the test image provides a WebView2 Runtime compatible with the SDK.
public static void EnsureBrowser()
{
// If a previous run of CoreWebView2Initialized_FailedTest failed to clean up the
Expand All @@ -60,24 +60,21 @@ public static void EnsureBrowser()
// 3. Check if a runtime is already installed, and if it's compatible.
bool hasCompatibleRuntimeInstalled = GetHasCompatibleRuntimeInstalled(browserBuildVersion, sdkBuildVersion);

// 4a. If we have a compatible runtime installed, continue on to the tests!
// 4. If we have a compatible runtime installed, continue on to the tests.
if (hasCompatibleRuntimeInstalled)
{
return;
}

// 4b. If we don't have a compatible runtime, try to install one.

// 5. Before installing, check if Edge is already installing/updating. We can't run the standalone installer if it is.
// An Evergreen update may already be in progress. Wait for it before failing the test.
bool didWait = WaitForEdgeIfAlreadyInstalling();

if (didWait && IsEdgeAlreadyInstalling())
{
Log.Error("WebView2Tests Init: Edge took more than 3 minutes to install, give up.");
Verify.Fail("WebView2Tests Init: Evergreen WebView2 Runtime update did not finish within 3 minutes.");
}
else if (didWait)
{
// If we waited for Edge to finish installing/updating and it finished, check the versions again
browserBuildVersion = GetInstalledBrowserVersion();
hasCompatibleRuntimeInstalled = GetHasCompatibleRuntimeInstalled(browserBuildVersion, sdkBuildVersion);
if (hasCompatibleRuntimeInstalled)
Expand All @@ -86,21 +83,11 @@ public static void EnsureBrowser()
}
}

// 6. If Edge wasn't already installing/updating, or it was but installed something old (unlikely),
// run the standalone installer to install it.
// This installation can sometimes fail, so we'll try a number of times before failing out.
int attemptsLeft = 5;
bool successfullyInstalled = false;
while (attemptsLeft > 0)
{
attemptsLeft--;
successfullyInstalled = TryInstallingBrowser(attemptsLeft);
if (successfullyInstalled) break;
}
if (attemptsLeft == 0 && !successfullyInstalled)
{
Log.Error("WebView2Tests Init: Browser installation failed, out of retries.");
}
Verify.Fail(string.Format(
"WebView2Tests Init: The test image must provide a compatible Evergreen WebView2 Runtime. " +
"Installed Runtime build: {0}; required SDK build: {1}.",
browserBuildVersion,
sdkBuildVersion));
}

private static void RemoveFakeBrowserExecutableFolderKey()
Expand Down Expand Up @@ -180,7 +167,7 @@ private static bool GetHasCompatibleRuntimeInstalled(int browserBuildVersion, in
// Browser/Runtime version ex: 80.0.361.48
// WebView2 SDK version ex: 0.8.355
// Webview2Loader compares the build versions (361 and 355 in above example), we do so here as well
if (browserBuildVersion >= sdkBuildVersion)
if (browserBuildVersion > 0 && sdkBuildVersion > 0 && browserBuildVersion >= sdkBuildVersion)
{
Log.Comment("WebView2Tests Init: Installed Edge build will be used for testing... ");
hasCompatibleRuntime = true;
Expand Down Expand Up @@ -222,43 +209,6 @@ private static bool IsEdgeAlreadyInstalling()
return edgeUpdateIsRunning;
}

private static bool TryInstallingBrowser(int attemptsLeft)
{
bool successfullyInstalled = false;
string installer = "mini_installer.exe";
// Note: Starting with SDK 0.9.488 / Edge version 83, evergreen WebView2 no longer targets the Stable
// browser channel. Instead, it targets another set of binaries, branded Evergreen WebView2 Runtime.
// (See https://docs.microsoft.com/en-us/microsoft-edge/webview2/releasenotes).
//
// Accordingly, Update mini_installer args to install WV2Runtime instead of full browser.
string installerArgs_WV2Runtime = "--msedgewebview --system-level";
Log.Comment(@"WebView2Tests Init: Installing WebView2 runtime: '{0} {1}'", installer, installerArgs_WV2Runtime);
ProcessStartInfo installerStartInfo = new ProcessStartInfo(installer, installerArgs_WV2Runtime);

Process installerProcess = Process.Start(installerStartInfo);
installerProcess.WaitForExit();

if (installerProcess.ExitCode == 0)
{
Log.Comment("WebView2Tests Init: {0} exited successfully", installer);
successfullyInstalled = true;
}
else
{
Log.Warning("WebView2Tests Init: {0} failed with exit code {1}! Attempts left: {2}", installer, installerProcess.ExitCode, attemptsLeft);
// Print information about some of the error codes we sometimes hit
if (installerProcess.ExitCode == 4)
{
Log.Comment("Exit code 4 = HIGHER_VERSION_EXISTS, Higher version already exists");
}
else if (installerProcess.ExitCode == 60)
{
Log.Comment("Exit code 60 = SETUP_SINGLETON_ACQUISITION_FAILED, The setup process could not acquire the exclusive right to modify the installation.");
}
}
return successfullyInstalled;
}

[TestCleanup]
public void TestCleanup()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@
<Destination>$(TestDependenciesResourcesDestinationPath)</Destination>
</BinplaceItem>
</ItemGroup>
<!-- Copy mini_installer.exe if the Microsoft.UI.DCPP.Dependencies.Edge package has been restored (which only happens in the pipelines) -->
<ItemGroup Condition="('$(arch)'=='x86' or '$(arch)'=='amd64') and Exists('$(NugetPackageDirectory)\Microsoft.UI.DCPP.Dependencies.Edge.144.0.3719.82')">
<BinplaceItem Include="$(NugetPackageDirectory)\Microsoft.UI.DCPP.Dependencies.Edge.144.0.3719.82\edge\mini_installer\$(DependencyPlatform)\mini_installer.exe">
<Destination>$(TestDependenciesResourcesDestinationPath)</Destination>
</BinplaceItem>
</ItemGroup>
</Target>
<Target Name="AppxExternalBinaries" BeforeTargets="GetPackagingOutputs" DependsOnTargets="ChooseExternalBinaries">
<ItemGroup>
Expand Down
Loading