Skip to content

Fix/dedupe on quefix(QueueItViewManager): dedupe onQueuePassed callbacks per queue presentation#3

Open
Jim-Rouse wants to merge 2 commits into
masterfrom
fix/dedupe-onQueuePassed-listener-callbacks
Open

Fix/dedupe on quefix(QueueItViewManager): dedupe onQueuePassed callbacks per queue presentation#3
Jim-Rouse wants to merge 2 commits into
masterfrom
fix/dedupe-onQueuePassed-listener-callbacks

Conversation

@Jim-Rouse
Copy link
Copy Markdown

Problem
When the user passes the queue, WKWebView.decidePolicyFor fires multiple times before hideQueue()'s about:blank swap takes effect. Each navigation step the URI overrider classifies as .passed re-invokes queueListener.onQueuePassed, so consumers see 2–3 callbacks per pass with distinct ts_…/h_… tokens. Reproduced against 1.0.1 in QueueItRetailDemo with a rt_queue redirect.

Fix
Adds a one-shot hasFiredQueuePassed flag on QueueItViewManager:
• Cleared in showQueue(...) so re-presentation still triggers exactly one callback per session.
• Gated in the .passed branch of decidePolicyFor: subsequent intercepts still cancel the navigation but no longer re-invoke the listener.

Test
Adds test_decidePolicyFor_passed_firesListenerOnceAcrossMultipleIntercepts to QueueItViewManagerTests. Drives the delegate three times with distinct queue-exit URLs and asserts onQueuePassedCallCount == 1, with the listener receiving the first token. Extends MockListener with an onQueuePassedCallCount counter (the existing onQueuePassedCalled Bool is preserved for other suites).

Jim-Rouse added 2 commits June 3, 2026 09:41
…sentation

During the queue-exit redirect chain, `WKWebView.decidePolicyFor` can fire
multiple times before `hideQueue()`'s `about:blank` swap takes effect.
Each navigation step the URI overrider classifies as `.passed` invokes
`queueListener.onQueuePassed`, so consumers observed 2–3 callbacks per
pass — each carrying a distinct token with a fresh `ts_…/h_…` segment.

Add a one-shot `hasFiredQueuePassed` flag on `QueueItViewManager`:
- Cleared in `showQueue(...)` so re-presentation still triggers exactly one.
- Gated in the `.passed` branch of `decidePolicyFor`: subsequent intercepts
  are still cancelled but the listener is not re-invoked.

Net result: exactly one `onQueuePassed` per queue presentation.
….passed intercepts

Adds a regression test that drives `webView(_:decidePolicyFor:preferences:decisionHandler:)`
three times with `<targetUrl>?queueittoken=…` URLs and asserts the listener
receives exactly one `onQueuePassed` callback. The token from the *first*
intercept is the one delivered; subsequent ones are suppressed.

Also extends MockListener with `onQueuePassedCallCount` for invocation counting.
The existing `onQueuePassedCalled` boolean is left intact for backwards
compatibility with the other test suites.

Test stub doubles for `WKNavigationAction` / `WKFrameInfo` are file-private
to QueueItViewManagerTests since no other suite needs them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant