Skip to content
Merged

Dev #203

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2db4652
refactor(browser): inject browser into window view model
Mzying2001 Oct 19, 2026
230ea71
refactor(browser): require browser constructor injection
Mzying2001 Oct 19, 2026
b77b233
fix(browser): supply browser for design-time view model
Mzying2001 Oct 19, 2026
ed1c9d3
Merge branch 'master' into dev
Mzying2001 Oct 20, 2026
4b80a5c
refactor(browser): extract reusable browser view and view model
Mzying2001 Oct 24, 2026
9c95b0c
fix(browser): preserve behavior after browser view extraction
Mzying2001 Oct 24, 2026
18272de
style(browser): align formatting with project conventions
Mzying2001 Oct 24, 2026
d3e430d
refactor(browser): extract CEF callback dispatch helper
Mzying2001 Oct 24, 2026
4839e89
refactor(browser): reuse BrowserView in auxiliary windows
Mzying2001 Oct 24, 2026
3637529
docs(agents): clarify code style guidance
Mzying2001 Oct 24, 2026
eb65e0d
refactor(browser): centralize view model initialization
Mzying2001 Oct 24, 2026
752c558
refactor(browser): use BrowserViewModel for command parameters
Mzying2001 Oct 24, 2026
1fff629
refactor(browser): extract browser readiness check
Mzying2001 Oct 24, 2026
de8ec81
refactor(browser): encapsulate browser operations in view model
Mzying2001 Oct 24, 2026
e2f75b4
refactor(tests): organize browser regression suite
Mzying2001 Oct 24, 2026
bb9fb6b
docs(agents): separate build and test commands
Mzying2001 Oct 24, 2026
de25c09
fix(browser): handle disposed browser callbacks
Mzying2001 Oct 24, 2026
686b005
fix(browser): defer navigation until native hosting is ready
Mzying2001 Oct 24, 2026
d389db1
fix(vscode): use .NET Framework OmniSharp for project loading
Mzying2001 Oct 25, 2026
3454a05
refactor(browser): extract reusable browser icon control
Mzying2001 Oct 25, 2026
a1cea60
Revert "fix(vscode): use .NET Framework OmniSharp for project loading"
Mzying2001 Oct 25, 2026
f6b7bcb
refactor(browser): remove WSH shortcut COM reference
Mzying2001 Oct 25, 2026
ac68b93
refactor(converters): standardize Converter suffixes
Mzying2001 Oct 25, 2026
de31082
feat(browser): add multi-tab backend and close lifecycle
Mzying2001 Oct 25, 2026
83e2e5d
feat(browser): add interactive multi-tab browsing
Mzying2001 Oct 25, 2026
e61b2d4
fix(browser): keep new tab button beside tabs
Mzying2001 Oct 25, 2026
e96b67e
fix(browser): make tab close button background transparent
Mzying2001 Oct 25, 2026
663fb8d
refactor(settings): list new tab behavior first
Mzying2001 Oct 25, 2026
34cb041
feat(settings): open new pages in tabs by default
Mzying2001 Oct 25, 2026
c475beb
feat(browser): hide tab strip for single-tab windows
Mzying2001 Oct 25, 2026
64b7fc1
feat(browser): add dedicated new tab toolbar icon
Mzying2001 Oct 25, 2026
6b40943
style(browser): increase tab corner radius
Mzying2001 Oct 25, 2026
29bccf6
fix(browser): insert page-opened tabs after their source
Mzying2001 Oct 25, 2026
70fcb9f
fix(browser): honor page settings in context menu actions
Mzying2001 Oct 25, 2026
cad6e0b
chore(browser): remove design-time window data context
Mzying2001 Oct 25, 2026
e6981ca
Merge pull request #202 from Mzying2001/feat/browser-tabs
Mzying2001 Oct 25, 2026
e125012
refactor(browser): centralize tab strip visibility state
Mzying2001 Oct 25, 2026
79fcbd8
feat(browser): add always-show tab bar setting
Mzying2001 Oct 25, 2026
78c137a
feat(browser): support drag reordering of tabs
Mzying2001 Oct 25, 2026
c1fe2a5
feat(browser): show tab previews during drag reordering
Mzying2001 Oct 25, 2026
243572a
fix(browser): render drag previews for later tabs
Mzying2001 Oct 25, 2026
56d2404
fix(browser): show default icon when favicon loading fails
Mzying2001 Oct 25, 2026
374ca6f
fix(browser): use close icon for tab controls
Mzying2001 Oct 25, 2026
25efebb
fix(browser): enable pixel scrolling for tab bar
Mzying2001 Oct 26, 2026
639f545
fix(browser): reduce toolbar spacing when tab strip is visible
Mzying2001 Oct 26, 2026
afd508e
fix(browser): stabilize status popup cursor avoidance
Mzying2001 Oct 26, 2026
37ffcaa
fix(browser): add shortcut hints to tab button tooltips
Mzying2001 Oct 26, 2026
177d69e
feat(browser): add tab context menu actions
Mzying2001 Oct 26, 2026
89d2ba7
feat(settings): add configurable new tab address
Mzying2001 Oct 26, 2026
0698330
ci: run tests for master and dev pull requests
Mzying2001 Oct 26, 2026
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
49 changes: 49 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Tests

on:
pull_request:
branches:
- master
- dev
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
unit-tests:
name: Unit tests (x64 Debug)
runs-on: windows-2022

env:
DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR: C:\Program Files\dotnet

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up MSBuild
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64

- name: Build test project
shell: cmd
run: >-
msbuild CefFlashBrowser.Tests\CefFlashBrowser.Tests.csproj
/restore /m /p:Configuration=Debug /p:Platform=x64 /verbosity:minimal

- name: Run unit tests
run: >-
dotnet test CefFlashBrowser.Tests\CefFlashBrowser.Tests.csproj
-p:Platform=x64 --no-build --no-restore
--logger "trx;LogFileName=test-results.trx"
--results-directory TestResults

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults/**/*.trx
if-no-files-found: warn
21 changes: 18 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,33 @@ set DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=C:\Program Files\dotnet
```

```cmd
:: Build and run unit tests
:: Build unit test project only (x64 Debug)
set DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=C:\Program Files\dotnet
"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe" ^
CefFlashBrowser.Tests\CefFlashBrowser.Tests.csproj -p:Configuration=Debug -p:Platform=x64 -restore
dotnet test CefFlashBrowser.Tests/CefFlashBrowser.Tests.csproj -p:Platform=x64 --no-build
```

```cmd
:: Build Release (x86 + x64) and create versioned zip archives in bin\Publish\
publish
```

## Test Commands

Build the required Debug|x64 outputs first. Unit tests require the test project; browser regression checks require the full solution.

```cmd
:: Run unit tests (x64 Debug)
dotnet test CefFlashBrowser.Tests/CefFlashBrowser.Tests.csproj -p:Platform=x64 --no-build
```

```cmd
:: Run browser regression checks (fresh x64 STA process)
powershell -NoProfile -STA -ExecutionPolicy Bypass -File CefFlashBrowser.Tests\BrowserRegression\Run.ps1
```

For browser regression setup, x86/Release commands, and diagnostics, see `CefFlashBrowser.Tests/BrowserRegression/README.md`.

## Project Structure

- **CefFlashBrowser/**: Main WPF application.
Expand Down Expand Up @@ -57,7 +72,7 @@ publish
- Builds target both x86 and x64; output paths differ: `bin\Release\` (x86) vs `bin\x64\Release\` (x64)
- Entry point is `Program.cs` (not the default `App.xaml.cs`)
- CefSharp version 84.4.10 is pinned for Flash compatibility
- UI controls from HandyControl library
- Follow the project's existing code style when modifying or adding code
- Keep text and source files using CRLF line endings to match the repository's Windows/WPF conventions

## Git Commit Conventions
Expand Down
207 changes: 207 additions & 0 deletions CefFlashBrowser.Tests/BrowserRegression/Environment.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
function New-RegressionContext([string]$ScriptPath, [string]$Platform, [string]$Configuration) {
$repositoryPath = Split-Path (Split-Path $ScriptPath -Parent) -Parent
$buildPath = if ($Platform -eq 'x64') { "bin\x64\$Configuration" } else { "bin\$Configuration" }
$applicationPath = Join-Path $repositoryPath $buildPath

return [pscustomobject]@{
ScriptPath = $ScriptPath
RepositoryPath = $repositoryPath
Platform = $Platform
Configuration = $Configuration
ApplicationPath = $applicationPath
CefPath = Join-Path $applicationPath 'Assets\CefSharp'
TemporaryPath = Join-Path ([IO.Path]::GetTempPath()) ('CefFlashBrowser-regression-' + [Guid]::NewGuid())
Application = $null
Logger = $null
CefStarted = $false
AuxiliaryTypes = @()
AuxiliaryAddress = $null
AuxiliarySecondAddress = $null
DisposedBrowser = $null
BrowserCommandNames = @(
'CreateShortcutCommand', 'AddFavoriteCommand', 'ToggleLoadingStateCommand',
'FindNextTextCommand', 'FindPrevTextCommand'
)
}
}

function Get-RegressionDependencyPath($Context, [string]$Dependency) {
$applicationPath = Join-Path $Context.ApplicationPath $Dependency
$projectOutputPath = Join-Path $Context.RepositoryPath (
"$([IO.Path]::GetFileNameWithoutExtension($Dependency))\bin\$($Context.Platform)\$($Context.Configuration)\net462\$Dependency")

if (Test-Path -LiteralPath $projectOutputPath -PathType Leaf) {
if (!(Test-Path -LiteralPath $applicationPath -PathType Leaf) -or
(Get-Item -LiteralPath $projectOutputPath).LastWriteTimeUtc -gt (Get-Item -LiteralPath $applicationPath).LastWriteTimeUtc) {
return $projectOutputPath
}
}

return $applicationPath
}

function Initialize-RegressionEnvironment($Context) {
$dependencies = @(
'SimpleMvvm.dll',
'Microsoft.Xaml.Behaviors.dll',
'HandyControl.dll',
'Newtonsoft.Json.dll',
'SharpVectors.Core.dll',
'SharpVectors.Runtime.Wpf.dll',
'SharpVectors.Converters.Wpf.dll',
'CefFlashBrowser.Log.dll',
'CefFlashBrowser.WinformCefSharp4WPF.dll',
'CefFlashBrowser.FlashBrowser.dll'
)
$cefDependencies = @('CefSharp.dll', 'CefSharp.Core.dll', 'CefSharp.WinForms.dll')
$requiredFiles = @('CefFlashBrowser.exe', 'Assets\SwfPlayer\swfplayer.html') + @(
($cefDependencies + @('CefSharp.BrowserSubprocess.exe', 'libcef.dll')) | ForEach-Object { "Assets\CefSharp\$_" }
)
foreach ($file in $requiredFiles) {
$path = Join-Path $Context.ApplicationPath $file
if (!(Test-Path -LiteralPath $path -PathType Leaf)) {
throw "Build output not found: $path. Build the solution with VS MSBuild for $($Context.Configuration)|$($Context.Platform) first."
}
}
foreach ($dependency in $dependencies) {
$path = Get-RegressionDependencyPath $Context $dependency
if (!(Test-Path -LiteralPath $path -PathType Leaf)) {
throw "Build output not found: $path. Build the solution with VS MSBuild for $($Context.Configuration)|$($Context.Platform) first."
}
}

[void][IO.Directory]::CreateDirectory($Context.TemporaryPath)
Write-Host "Isolated test data: $($Context.TemporaryPath)"
Add-Type -AssemblyName PresentationFramework, PresentationCore, WindowsBase, System.Xaml, System.Windows.Forms
if ($null -ne [System.Windows.Application]::Current) {
throw 'Run the regression in a fresh Windows PowerShell process.'
}
foreach ($dependency in $dependencies) {
[void][Reflection.Assembly]::LoadFrom((Get-RegressionDependencyPath $Context $dependency))
}
[void][Reflection.Assembly]::LoadFrom((Join-Path $Context.CefPath 'CefSharp.dll'))
$applicationAssembly = [Reflection.Assembly]::LoadFrom((Join-Path $Context.ApplicationPath 'CefFlashBrowser.exe'))
[void][CefFlashBrowser.Utils.Win32]::SetDllDirectory($Context.CefPath)
foreach ($dependency in @('CefSharp.Core.dll', 'CefSharp.WinForms.dll')) {
[void][Reflection.Assembly]::LoadFrom((Join-Path $Context.CefPath $dependency))
}

$references = @(
(Join-Path $Context.CefPath 'CefSharp.dll'),
$applicationAssembly.FullName,
(Get-RegressionDependencyPath $Context 'CefFlashBrowser.FlashBrowser.dll')
)
Add-Type -ReferencedAssemblies $references -Path (Join-Path $Context.ScriptPath 'TestDoubles.cs')
$Context.DisposedBrowser = (New-Object DisposedBrowserProxy([CefSharp.IBrowser])).GetTransparentProxy()
$Context.AuxiliaryTypes = @(
[CefFlashBrowser.Views.PopupWebPage],
[CefFlashBrowser.Views.SwfPlayerWindow],
[CefFlashBrowser.Views.ViewSourceWindow]
)

[System.Windows.Application]::ResourceAssembly = $applicationAssembly
$Context.Application = New-Object System.Windows.Application
$Context.Application.ShutdownMode = [System.Windows.ShutdownMode]::OnExplicitShutdown
$globalDataType = $applicationAssembly.GetType('CefFlashBrowser.Data.GlobalData')
$privateStatic = [Reflection.BindingFlags]'Static,NonPublic'
$globalDataType.GetField('<Settings>k__BackingField', $privateStatic).SetValue($null, [CefFlashBrowser.Models.Settings]::Default)
$globalDataType.GetField('<Favorites>k__BackingField', $privateStatic).SetValue($null,
(New-Object 'System.Collections.ObjectModel.ObservableCollection[CefFlashBrowser.Models.Website]'))
# PowerShell has a different application base directory than the deployed executable.
$globalDataType.GetField('<SwfPlayerPath>k__BackingField', $privateStatic).SetValue(
$null, (Join-Path $Context.ApplicationPath 'Assets\SwfPlayer\swfplayer.html'))
[CefFlashBrowser.Data.GlobalData]::IsStartWithoutMainWindow = $true
$locator = New-Object CefFlashBrowser.ViewModels.ViewModelLocator
$Context.Application.Resources.Add('Locator', $locator.PSObject.BaseObject)
$Context.Logger = New-Object CefFlashBrowser.Log.FileLogger((Join-Path $Context.TemporaryPath 'app.log'))
$registerInstance = [SimpleMvvm.Ioc.SimpleIoc].GetMethods() | Where-Object {
$_.Name -eq 'Register' -and $_.IsGenericMethodDefinition -and
$_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.IsGenericParameter
}
[void]$registerInstance.MakeGenericMethod([CefFlashBrowser.Log.ILogger]).Invoke(
[SimpleMvvm.Ioc.SimpleIoc]::Global, @($Context.Logger.PSObject.BaseObject))

foreach ($dictionaryUri in @(
'pack://application:,,,/CefFlashBrowser;component/Assets/Language/zh-CN.xaml',
'pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml',
'pack://application:,,,/HandyControl;component/Themes/Theme.xaml',
'pack://application:,,,/CefFlashBrowser;component/Views/Converters/Converters.xaml'
)) {
$dictionary = New-Object System.Windows.ResourceDictionary
$dictionary.set_Source([Uri]$dictionaryUri)
$Context.Application.Resources.MergedDictionaries.Add($dictionary)
}
# Supply LanguageManager lookups without starting App or loading the user's profile.
$languages = New-Object System.Windows.ResourceDictionary
$languages.set_Source([Uri]'pack://application:,,,/CefFlashBrowser;component/Assets/Language/langs.xaml')
$languageDictionaries = [CefFlashBrowser.Services.LanguageManager].GetProperty(
'LanguageDictionaries', $privateStatic).GetValue($null, $null)
foreach ($language in $languages.Keys) {
$languageDictionaries.Add($language, $languages[$language])
}

foreach ($icon in @('Add', 'Sub', 'Back', 'Forward', 'Reload', 'Stop', 'Warning', 'Search', 'More', 'Up', 'Down', 'Page', 'Close')) {
$Context.Application.Resources.Add($icon + 'IconUri', [Uri]('/Assets/Svgs/' + $icon.ToLowerInvariant() + '.svg', [UriKind]::Relative))
}
$Context.Application.Resources.Add('NewTabIconUri', [Uri]::new('/Assets/Svgs/new-tab.svg', [UriKind]::Relative))

$auxiliaryFile = Join-Path $Context.TemporaryPath 'auxiliary.html'
$auxiliarySecondFile = Join-Path $Context.TemporaryPath 'auxiliary-second.html'
[IO.File]::WriteAllText($auxiliaryFile, '<title>Auxiliary regression</title><p>auxiliary-source-token</p>')
[IO.File]::WriteAllText($auxiliarySecondFile, '<title>Second auxiliary page</title><p>second-source-token</p>')
$Context.AuxiliaryAddress = ([Uri]$auxiliaryFile).AbsoluteUri
$Context.AuxiliarySecondAddress = ([Uri]$auxiliarySecondFile).AbsoluteUri
}

function Start-RegressionCef($Context) {
$cefSettings = New-Object CefFlashBrowser.FlashBrowser.CefFlashSettings
$cefSettings.BrowserSubprocessPath = Join-Path $Context.CefPath 'CefSharp.BrowserSubprocess.exe'
$cefSettings.ResourcesDirPath = $Context.CefPath
$cefSettings.LocalesDirPath = Join-Path $Context.CefPath 'locales'
$cefSettings.CachePath = Join-Path $Context.TemporaryPath 'Cache'
$cefSettings.LogFile = Join-Path $Context.TemporaryPath 'cef.log'
$cefSettings.CefCommandLineArgs['disable-gpu'] = '1'
$Context.CefStarted = [CefSharp.Cef]::Initialize($cefSettings)
if (!$Context.CefStarted) {
throw 'CEF initialization failed'
}
}

function Stop-RegressionEnvironment($Context) {
$cleanupErrors = New-Object 'System.Collections.Generic.List[object]'
if ($null -ne $Context.Application) {
try {
$windows = @($Context.Application.Windows)
foreach ($window in $windows) {
try {
if ($window -is [CefFlashBrowser.Views.BrowserWindow] -or $Context.AuxiliaryTypes.Contains($window.GetType())) {
$window.ForceCloseWindow()
} else {
$window.Close()
}
} catch {
$cleanupErrors.Add($_)
}
}
} catch {
$cleanupErrors.Add($_)
}
}
if ($Context.CefStarted) {
try {
[CefSharp.Cef]::Shutdown()
} catch {
$cleanupErrors.Add($_)
} finally {
$Context.CefStarted = $false
}
}
if ($null -ne $Context.Logger) {
try {
$Context.Logger.Dispose()
} catch {
$cleanupErrors.Add($_)
}
}
return $cleanupErrors.ToArray()
}
Loading
Loading