-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix FXIOS-10251 iPad not recognizing Firefox pair website (#23089)
* Add firefox.com in the list of custom agent for Desktop version aka iPad * Added user agent tests * Added UserAgentBuilderTest --------- Co-authored-by: Filippo <[email protected]>
- Loading branch information
1 parent
b3c6687
commit 05c6620
Showing
4 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
73 changes: 73 additions & 0 deletions
73
firefox-ios/firefox-ios-tests/Tests/SharedTests/UserAgentBuilderTests.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import XCTest | ||
import Common | ||
@testable import Shared | ||
|
||
final class UserAgentBuilderTests: XCTestCase { | ||
func testUserAgent_generateCorrectString() { | ||
let builder = createSubject( | ||
product: "FXIOS", | ||
systemInfo: "iPhone", | ||
platform: "Apple", | ||
platformDetails: "", | ||
extensions: "15.09.0" | ||
) | ||
let agent = builder.userAgent() | ||
|
||
XCTAssertEqual(agent, "FXIOS iPhone Apple 15.09.0") | ||
} | ||
|
||
func testClone_generateCorrectString() { | ||
let builder = createSubject( | ||
product: "FXIOS", | ||
systemInfo: "iPhone", | ||
platform: "Apple ", | ||
platformDetails: " Details ", | ||
extensions: " 15.09.0 " | ||
) | ||
|
||
let agent = builder.clone( | ||
product: "FXIOS1", | ||
systemInfo: "iPhone12", | ||
platform: "Apple 5", | ||
platformDetails: "New details", | ||
extensions: "14.090" | ||
) | ||
return XCTAssertEqual(agent, "FXIOS1 iPhone12 Apple 5 New details 14.090") | ||
} | ||
|
||
func testDefaultMobileUserAgent() { | ||
let builder = UserAgentBuilder.defaultMobileUserAgent() | ||
let systemInfo = "(\(UIDevice.current.model); CPU iPhone OS \(UIDevice.current.systemVersion.replacingOccurrences(of: ".", with: "_")) like Mac OS X)" | ||
let extensions = "FxiOS/\(AppInfo.appVersion) \(UserAgent.uaBitMobile) \(UserAgent.uaBitSafari)" | ||
let testAgent = "\(UserAgent.product) \(systemInfo) \(UserAgent.platform) \(UserAgent.platformDetails) \(extensions)" | ||
XCTAssertEqual(builder.userAgent(), testAgent) | ||
} | ||
|
||
func testDefaultDesktopUserAgent() { | ||
let builder = UserAgentBuilder.defaultDesktopUserAgent() | ||
let systemInfo = "(Macintosh; Intel Mac OS X 10.15)" | ||
let extensions = "FxiOS/\(AppInfo.appVersion) \(UserAgent.uaBitSafari)" | ||
let testAgent = "\(UserAgent.product) \(systemInfo) \(UserAgent.platform) \(UserAgent.platformDetails) \(extensions)" | ||
XCTAssertEqual(builder.userAgent(), testAgent) | ||
} | ||
|
||
private func createSubject( | ||
product: String, | ||
systemInfo: String, | ||
platform: String, | ||
platformDetails: String, | ||
extensions: String | ||
) -> UserAgentBuilder { | ||
return UserAgentBuilder( | ||
product: product, | ||
systemInfo: systemInfo, | ||
platform: platform, | ||
platformDetails: platformDetails, | ||
extensions: extensions | ||
) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
firefox-ios/firefox-ios-tests/Tests/SharedTests/UserAgentTests.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import XCTest | ||
@testable import Shared | ||
import Common | ||
|
||
final class UserAgentTests: XCTestCase { | ||
func testGetUserAgentDesktop_withListedDomain_returnProperUserAgent() { | ||
let domains = CustomUserAgentConstant.customDesktopUAForDomain | ||
domains.forEach { domain, agent in | ||
XCTAssertEqual(agent, UserAgent.getUserAgent(domain: domain, platform: .Desktop)) | ||
} | ||
} | ||
|
||
func testGetUserAgentMobile_withListedDomain_returnProperUserAgent() { | ||
let domains = CustomUserAgentConstant.customMobileUAForDomain | ||
domains.forEach { domain, agent in | ||
XCTAssertEqual(agent, UserAgent.getUserAgent(domain: domain, platform: .Mobile)) | ||
} | ||
} | ||
} |