Repository navigation
test(desktop): main-frame e2e waits for the announced OS open, not a command, after a script navigation - #3937
Merged
Merged
Conversation
…command, after a script navigation
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3517
Closes #3933
Root cause
The test sent a command while a navigation it started was still loading, and on Linux Tauri refuses such a command.
location.assignstarts a navigation. WebKitGTK runsbeforeunloadand stops the page's loads (FrameLoader::continueLoadAfterNavigationPolicy:shouldClose(), thenstopAllLoaders()). That aborts theipc://fetches in flight: about 10 of the app's own commands at that moment, every run.postMessageand keeps using it for that document (customProtocolIpcFailedis sticky,tauri-2.12.5/scripts/ipc-protocol.js).postMessagecommand withwebview.uri()(wry-0.57.1/src/webkitgtk/mod.rs,attach_ipc_handler). While a main-frame load is provisional, that URI is the URL being loaded, which here is the refused fixture URL. Tauri's ACL treats that as a remote page, and no capability names it:e2e_os_opens not allowed. Plugin not found. Theipc://path reads theOriginheader instead and is not affected.e2e_os_opensright after eachlocation.assign. When the first read landed in that window, the poll threw./redirecthit it most because it has two round trips. The OS open is recorded inload-failed, which is also when the window closes.The error text does not point to a startup or plugin-registration race.
e2e_os_opensis an app command, and the app has no app ACL manifest. Tauri checks such a command against the ACL only when the request is not from a local origin (webview/mod.rs~2075:plugin_command.is_some() || has_app_acl_manifest || !is_local). "Plugin not found" is the textresolve_access_messagegives for any command with no ACL entry under the__app-acl__key (ipc/authority.rs:408). In every failing container run, the same app had already answeredvault_statusand the earliere2e_os_opensreads. In the instrumented runs, the identical call succeeded 3 s later in the same instance. #3924's linux-x64 failure (same spec, same text, rerun passed) is another occurrence of this flake.The page sees no event when the refused load ends (
window.navigationis undefined in WebKitGTK 2.50.4). So the app announces the event instead.This is not reachable in production: app code never navigates the main frame by script (
memry/no-location-navigation,external-link-guard.ts). The spec does this on purpose to exercise the guard's last line.Change
src-tauri/src/e2e/reveal.rs(e2e feature only):record_os_openalso emitse2e-os-openwith the recorded entry.main-frame.e2e.ts:watchOsOpens(page)listens for that event before the navigations. After a script navigation, the poll reads the page's list, which sends no command. Each test still checks the authoritativee2e_os_opensonce the open arrived, when commands work again. Three polls changed: the stop/chain/redirect/popup loop, thememry-filePDF, and back/forward's/stop.navigation_guard/linux.rs: the module doc said only that a resent command can run twice. It now also says the command is refused while the refused load is loading.No timeouts were raised and no retries were added. Every wait is on the app's announced open.
Proof
All runs were in an
ubuntu:22.04arm64 container (WebKitGTK 2.50.4-0ubuntu0.22.04.1, xvfb, one worker), withwdio --spec e2e/specs/shell/main-frame.e2e.ts.feat/tauri-v2cc23103 (run 41883239554,memry-tauri-e2e-linux-arm64)stop, chainstop, chaine2e_os_opens not allowed. Plugin not foundstop, chainThe diagnostic copy logged
beforeunload, then 10IPC custom protocol failed ... postMessagewarnings at the first navigation, and the failure at the/redirectstep. Three seconds later the same command succeeded.CI proof, all on the build of this PR's head (run 41904873929, commit 6c629aa):
memry-tauri-e2e-linux-arm64of run 41904873929stop, chaine2e_os_opens not allowed, and 1 app exited with code 101 at startup before any spec ran (see follow-ups)Build e2e 1/2 (linux-x64), attempt 1The other legs of the
full-cirun (macOS, Windows x64/arm64) are green on attempt 1.Local gate:
pnpm lint,pnpm typecheck,pnpm format:check,git diff --check,cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo clippy -p memry-tauri --features e2e(only a pre-existing unused import ine2e/vault_writeback.rs, see follow-up),cargo test -p memry-tauri,check-line-ceilings,check-test-timing.Follow-up (not in this PR)
cargo clippy -p memry-tauri --features e2e -- -D warningsfails on base: an unusedE2eGateimport insrc-tauri/src/e2e/vault_writeback.rs. CI never lints thee2efeature, so nothing catches it.main.logexisted. The harness spawns the app withstdio: 'ignore'(harness/app-process.ts), so the panic text was lost. A 40-launch probe that kept stderr did not reproduce it. Capturing stderr there would make the next one diagnosable.