Post

Replies

Boosts

Views

Activity

iOS 16 set and get cookie failure in WKHTTPCookieStore
Hi, I am not able to set and retrieve cookies from WKWebsiteDataStore when running the following test. The getCookies in the below code always comes empty. I dont understand its failing because it is unable to set the cookie or the get is failing to retrieve cookies. Here is the code: let cookieStorage = WKWebsiteDataStore.nonPersistent().httpCookieStore let properties: [HTTPCookiePropertyKey: Any] = [       .domain: "abc.com",       .path: "/",       .name: "name",       .value: "value",       .secure: "TRUE"     ] let cookie = HTTPCookie(properties: properties)! let cookies = [cookie] let cookieExpectation = self.expectation(description: "cookieExpectation")       cookieStorage.setCookie(cookies[0]) {     cookieStorage.getAllCookies { getCookies in      let mappedCookies = Dictionary(uniqueKeysWithValues: cookies.map { ($0.name, $0.value ) })      let mappedGetCookies = Dictionary(uniqueKeysWithValues: getCookies.map { ($0.name, $0.value ) })      XCTAssertEqual(mappedCookies, mappedGetCookies) cookieExpectation.fulfill()   } } This is failing on iOS 16 simulator. For iOS 15 simulator and mac Catalyst the test case succeeds without any problem. Checked this on xcode 14 release and xcode 14.1 Beta 2
0
1
1.2k
Sep ’22
iOS 16 set and get cookie failure in WKHTTPCookieStore
Hi, I am not able to set and retrieve cookies from WKWebsiteDataStore when running the following test. The getCookies in the below code always comes empty. I dont understand its failing because it is unable to set the cookie or the get is failing to retrieve cookies. Here is the code: let cookieStorage = WKWebsiteDataStore.nonPersistent().httpCookieStore let properties: [HTTPCookiePropertyKey: Any] = [       .domain: "abc.com",       .path: "/",       .name: "name",       .value: "value",       .secure: "TRUE"     ] let cookie = HTTPCookie(properties: properties)! let cookies = [cookie] let cookieExpectation = self.expectation(description: "cookieExpectation")       cookieStorage.setCookie(cookies[0]) {     cookieStorage.getAllCookies { getCookies in      let mappedCookies = Dictionary(uniqueKeysWithValues: cookies.map { ($0.name, $0.value ) })      let mappedGetCookies = Dictionary(uniqueKeysWithValues: getCookies.map { ($0.name, $0.value ) })      XCTAssertEqual(mappedCookies, mappedGetCookies) cookieExpectation.fulfill()   } } This is failing on iOS 16 simulator. For iOS 15 simulator and mac Catalyst the test case succeeds without any problem. Checked this on xcode 14 release and xcode 14.1 Beta 2
Replies
0
Boosts
1
Views
1.2k
Activity
Sep ’22