chore(flow): expand host-return whitelist and add a DEBUG host bundle probe

- Rebuild the return-to-host whitelist from the CN/US top charts plus Apple
  system apps; drop the canOpenURL pre-check (LSApplicationQueriesSchemes
  is capped at 50) and let open() report failure.
- Never record an OSG bundle id as the host to return to.
- DEBUG only: probe the host bundle id through the keyboard arbiter
  callback and surface the log on a Home test card. Release builds keep
  the previous behaviour (no host identification).
This commit is contained in:
2026-10-20 20:06:36 +02:00
parent d540a58594
commit ad79c2ea13
16 changed files with 807 additions and 327 deletions
+38 -3
View File
@@ -11,18 +11,53 @@ final class HostAppURLRegistryTests: XCTestCase {
XCTAssertEqual(entry?.displayNameKey, "hostApp.wechat")
}
/// App Store bundle ids; the earlier `com.tencent.wework` / `tv.danmaku.bili` never matched.
func testCorrectedBundleIds() {
XCTAssertEqual(HostAppURLRegistry.lookup(bundleId: "com.tencent.ww")?.returnURLString, "wxwork://")
XCTAssertEqual(HostAppURLRegistry.lookup(bundleId: "tv.danmaku.bilianime")?.returnURLString, "bilibili://")
}
func testSystemAppLookup() {
XCTAssertEqual(HostAppURLRegistry.lookup(bundleId: "com.apple.mobilenotes")?.returnURLString, "mobilenotes://")
XCTAssertNil(HostAppURLRegistry.lookup(bundleId: "com.apple.mobilesafari"))
}
func testUnknownBundleReturnsNil() {
XCTAssertNil(HostAppURLRegistry.lookup(bundleId: "com.apple.MobileSMS"))
XCTAssertNil(HostAppURLRegistry.lookup(bundleId: "com.example.unknown"))
XCTAssertNil(HostAppURLRegistry.lookup(bundleId: nil))
XCTAssertNil(HostAppURLRegistry.lookup(bundleId: ""))
}
func testQuerySchemesIncludesWeChat() {
XCTAssertTrue(HostAppURLRegistry.querySchemes.contains("weixin"))
func testEveryEntryHasParseableReturnURL() {
for entry in HostAppURLRegistry.entries {
XCTAssertNotNil(entry.returnURL?.scheme, entry.bundleId)
}
}
func testOwnBundleIdsAreNeverReturnTargets() {
XCTAssertTrue(HostAppURLRegistry.isOwnBundleId("com.osgkeyboard"))
XCTAssertTrue(HostAppURLRegistry.isOwnBundleId("com.osgkeyboard.ios"))
XCTAssertTrue(HostAppURLRegistry.isOwnBundleId("com.osgkeyboard.ios.keyboard"))
XCTAssertFalse(HostAppURLRegistry.isOwnBundleId("com.osgkeyboardx.ios"))
XCTAssertFalse(HostAppURLRegistry.isOwnBundleId("com.tencent.xin"))
}
func testEntriesHaveUniqueBundleIds() {
let ids = HostAppURLRegistry.entries.map(\.bundleId)
XCTAssertEqual(Set(ids).count, ids.count)
}
func testEveryEntryHasLocalizedDisplayName() throws {
let bundle = Bundle(identifier: "com.osgkeyboard.ios") ?? .main
for language in ["en", "zh-Hans"] {
let path = try XCTUnwrap(bundle.path(forResource: language, ofType: "lproj"), language)
let strings = try XCTUnwrap(
NSDictionary(contentsOfFile: "\(path)/Localizable.strings") as? [String: String],
language
)
for entry in HostAppURLRegistry.entries {
XCTAssertNotNil(strings[entry.displayNameKey], "\(language): \(entry.displayNameKey)")
}
}
}
}