also looking at this
fix(mobile): preserve native editing, navigation, and durable media requests
#369
36 files
+864
-185
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -174,7 +174,7 @@ pub const Flags = std.EnumSet(Feature); | ||
| 174 | 174 | const string_keys = [_][]const u8{ "appName", "bundleId", "renderer", "backgroundColor" }; |
| 175 | 175 | const extra_bool_keys = [_][]const u8{"darkMode"}; |
| 176 | 176 | const array_of_string_keys = [_][]const u8{ "associatedDomains", "trustedOrigins" }; |
| 177 | const optional_string_keys = [_][]const u8{ "appearance", "backgroundColorDark", "devServerURL", "nativeApp", "sessionTokenKey" }; | |
| 177 | const optional_string_keys = [_][]const u8{ "appearance", "backgroundColorDark", "devServerURL", "nativeApp", "nativeScriptThread", "sessionTokenKey" }; | |
| 178 | 178 | const optional_bool_keys = [_][]const u8{ "swipeNavigation", "limitNavigationsToAppBoundDomains", "allowsLinkPreview", "keyboardAccessory", "disableZoom" }; |
| 179 | 179 | /// Swift `Double`s with a default. Any JSON number decodes; a string or a |
| 180 | 180 | /// boolean throws. |
| @@ -781,6 +781,19 @@ test "optional fields are type-checked when present" { | ||
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | test "the native script thread matches Swift optional string decoding" { | |
| 785 | inline for (.{ "\"nativeScriptThread\":\"main\"", "\"nativeScriptThread\":\"background\"", "\"nativeScriptThread\":null" }) |good| { | |
| 786 | const json = try completeConfig(testing.allocator, good); | |
| 787 | defer testing.allocator.free(json); | |
| 788 | try testing.expectEqual(std.enums.values(Feature).len, parse(testing.allocator, json).count()); | |
| 789 | } | |
| 790 | inline for (.{ "\"nativeScriptThread\":true", "\"nativeScriptThread\":1", "\"nativeScriptThread\":[]" }) |bad| { | |
| 791 | const json = try completeConfig(testing.allocator, bad); | |
| 792 | defer testing.allocator.free(json); | |
| 793 | try testing.expectEqual(@as(usize, 0), parse(testing.allocator, json).count()); | |
| 794 | } | |
| 795 | } | |
| 796 | ||
| 784 | 797 | test "number fields take any JSON number and nothing else" { |
| 785 | 798 | // `Double` decodes an integer as readily as a fraction; a quoted number |
| 786 | 799 | // or a boolean throws. Checked against `swiftc`. |