-
-
Notifications
You must be signed in to change notification settings - Fork 32
Fix an overlay crash and two dead settings (pre-release audit, wave 2) #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,4 +146,20 @@ final class AXTextGeometryResolverTests: XCTestCase { | |
| XCTAssertTrue(resolver.rectIsNearAnchor(rect, anchor: nil)) | ||
| XCTAssertTrue(resolver.rectIsNearAnchor(rect, anchor: .zero)) | ||
| } | ||
|
|
||
| // MARK: - Non-finite AX rect rejection (crash guard) | ||
|
|
||
| func test_rectHasFiniteComponents_rejectsNaNAndInfinity() { | ||
| XCTAssertTrue(AXHelper.rectHasFiniteComponents(CGRect(x: 1, y: 2, width: 3, height: 4))) | ||
| XCTAssertFalse(AXHelper.rectHasFiniteComponents(CGRect(x: CGFloat.nan, y: 0, width: 10, height: 10))) | ||
| XCTAssertFalse(AXHelper.rectHasFiniteComponents(CGRect(x: 0, y: 0, width: CGFloat.infinity, height: 10))) | ||
| XCTAssertFalse(AXHelper.rectHasFiniteComponents(CGRect(x: 0, y: CGFloat.nan, width: 10, height: CGFloat.nan))) | ||
| } | ||
|
|
||
| func test_validatedCocoaTextRect_collapsesNonFiniteRectToZero() { | ||
| // A NaN/Inf AX rect must collapse to .zero, never propagate toward NSWindow.setFrame (a crash). | ||
| let nan = CGRect(x: CGFloat.nan, y: 10, width: 20, height: 14) | ||
| XCTAssertEqual(AXHelper.validatedCocoaTextRect(fromAccessibilityRect: nan, anchorFrame: nil), .zero) | ||
| XCTAssertEqual(AXHelper.cocoaRect(fromAccessibilityRect: nan), .zero) | ||
| } | ||
|
Comment on lines
+159
to
+164
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGRect.nullsilently collapses to.zeroCGRect.nullhas its origin at(+∞, +∞)in CoreGraphics, sorectHasFiniteComponents(CGRect.null)returnsfalseand bothcocoaRectandvalidatedCocoaTextRectnow return.zerofor a null rect. Previously theguard !rect.isNullbranch caught it and returned the null rect itself. Any downstream caller that distinguishes null from zero (e.g. anisNullcheck) will now see.zeroinstead. Worth verifying that every caller only guards with!= .zero(not.isNull) so no silent pass-through occurs after this change.