Fix/dedupe on quefix(QueueItViewManager): dedupe onQueuePassed callbacks per queue presentation#3
Open
Jim-Rouse wants to merge 2 commits into
Open
Conversation
…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.
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.
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).