Skip to content

Commit

Permalink
Merge branch 'main' into wt/FXIOS-10088-Add-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thatswinnie committed Nov 13, 2024
2 parents 1accff5 + 13b1f16 commit 337edb1
Show file tree
Hide file tree
Showing 51 changed files with 904 additions and 587 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/firefox-ios-autofill-playwrite-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ jobs:
env:
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ jobs:
call-firefox-ios-autofill-playwrite-tests:
uses: ./.github/workflows/firefox-ios-autofill-playwrite-tests.yml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
env:
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_SLACK_TOKEN }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload-file-path: "./test-fixtures/ci/slack-notification-payload-remote-settings-fetch.json"
2 changes: 1 addition & 1 deletion BrowserKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let package = Package(
exact: "2.0.0"),
.package(
url: "https://github.com/getsentry/sentry-cocoa.git",
exact: "8.36.0"),
exact: "8.21.0"),
.package(
url: "https://github.com/nbhasin2/GCDWebServer.git",
branch: "master"),
Expand Down
1 change: 1 addition & 0 deletions BrowserKit/Sources/Redux/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class Store<State: StateType>: DefaultDispatchStore {
// (Note: this is true even if the action's UUID differs from the screen's window's UUID).
// Typically, reducers should compare the action's UUID to the incoming state UUID and skip
// processing for actions originating in other windows.
// Note that only reducers for active screens are processed.
let newState = reducer(state, action)

// Middlewares are all given an opportunity to respond to the action. This is only done once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ final class LocationView: UIView,
urlTextField.text = text

// Start overlay mode & select text when in edit mode with a search term
if shouldShowKeyboard == true && state.shouldSelectSearchTerm == true {
if shouldShowKeyboard, state.shouldSelectSearchTerm {
DispatchQueue.main.async {
self.urlTextField.text = text
self.urlTextField.selectAll(nil)
Expand Down
57 changes: 33 additions & 24 deletions firefox-ios/Account/FxAPushMessageHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Shared
import Account
import Common
import enum MozillaAppServices.IncomingDeviceCommand
import enum MozillaAppServices.AccountEvent

let PendingAccountDisconnectedKey = "PendingAccountDisconnect"

Expand Down Expand Up @@ -34,36 +35,15 @@ extension FxAPushMessageHandler {
RustFirefoxAccounts.reconfig(prefs: self.profile.prefs) { accountManager in
accountManager.deviceConstellation()?.handlePushMessage(pushPayload: message) { result in
guard case .success(let event) = result else {
let err: PushMessageError
if case .failure(let error) = result {
self.logger.log("Failed to get any events from FxA",
level: .warning,
category: .sync,
description: error.localizedDescription)
err = PushMessageError.messageIncomplete(error.localizedDescription)
} else {
self.logger.log("Got zero events from FxA",
level: .warning,
category: .sync,
description: "No events retrieved from fxa")
err = PushMessageError.messageIncomplete("empty message")
}
let err = self.makePushErrorMessageFrom(result: result)
completion(.failure(err))
return
}

switch event {
case .commandReceived(let deviceCommand):
switch deviceCommand {
case .tabReceived(_, let tabData):
let title = tabData.entries.last?.title ?? ""
let url = tabData.entries.last?.url ?? ""
let command = CommandReceived.tabReceived(tab: ["title": title, "url": url])
completion(.success(PushMessage.commandReceived(command: command)))
case .tabsClosed(_, let payload):
let command = CommandReceived.tabsClosed(urls: payload.urls)
completion(.success(PushMessage.commandReceived(command: command)))
}
let pushMessage = self.makePushMessageFrom(deviceCommand: deviceCommand)
completion(.success(pushMessage))
case .deviceConnected(let deviceName):
completion(.success(PushMessage.deviceConnected(deviceName)))
case let .deviceDisconnected(_, isLocalDevice):
Expand All @@ -83,6 +63,35 @@ extension FxAPushMessageHandler {
}
}
}

private func makePushErrorMessageFrom(result: Result<AccountEvent, Error>) -> PushMessageError {
if case .failure(let error) = result {
self.logger.log("Failed to get any events from FxA",
level: .warning,
category: .sync,
description: error.localizedDescription)
return PushMessageError.messageIncomplete(error.localizedDescription)
} else {
self.logger.log("Got zero events from FxA",
level: .warning,
category: .sync,
description: "No events retrieved from fxa")
return PushMessageError.messageIncomplete("empty message")
}
}

private func makePushMessageFrom(deviceCommand: IncomingDeviceCommand) -> PushMessage {
switch deviceCommand {
case .tabReceived(_, let tabData):
let title = tabData.entries.last?.title ?? ""
let url = tabData.entries.last?.url ?? ""
let command = CommandReceived.tabReceived(tab: ["title": title, "url": url])
return PushMessage.commandReceived(command: command)
case .tabsClosed(_, let payload):
let command = CommandReceived.tabsClosed(urls: payload.urls)
return PushMessage.commandReceived(command: command)
}
}
}

enum PushMessageType: String {
Expand Down
6 changes: 5 additions & 1 deletion firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@
BD57D9A729D4C42B00039394 /* ZoomLevelStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD57D9A629D4C42B00039394 /* ZoomLevelStoreTests.swift */; };
BD6B361E2B3C2511005E5345 /* CircularProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD6B361D2B3C2511005E5345 /* CircularProgressView.swift */; };
BD6CC84229CDDA3400546A5D /* ZoomLevelStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD6CC84129CDDA3400546A5D /* ZoomLevelStore.swift */; };
BDD262562CE3AC8200DF2C62 /* PrivacyWindowHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD262552CE3AC8200DF2C62 /* PrivacyWindowHelper.swift */; };
C2200A6A2B7D148C00DC062A /* ContentBlockerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2200A692B7D148C00DC062A /* ContentBlockerTests.swift */; };
C22753402A3C9E1300B9C0D1 /* WebsiteDataManagementViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C227533F2A3C9E1300B9C0D1 /* WebsiteDataManagementViewModel.swift */; };
C2296FCC2A601C190046ECA6 /* IntensityVisualEffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2296FCB2A601C190046ECA6 /* IntensityVisualEffectView.swift */; };
Expand Down Expand Up @@ -8074,6 +8075,7 @@
BD7B4C6BBA14B1437A321E78 /* hi-IN */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "hi-IN"; path = "hi-IN.lproj/3DTouchActions.strings"; sourceTree = "<group>"; };
BDB24F4C850C4A269C205FDF /* br */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = br; path = br.lproj/LoginManager.strings; sourceTree = "<group>"; };
BDB444F281416E39E6A11588 /* af */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = af; path = af.lproj/Menu.strings; sourceTree = "<group>"; };
BDD262552CE3AC8200DF2C62 /* PrivacyWindowHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyWindowHelper.swift; sourceTree = "<group>"; };
BDF24048A0CB24CA7CBDB0AF /* hsb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hsb; path = hsb.lproj/3DTouchActions.strings; sourceTree = "<group>"; };
BE3B484FBA5F1ECC0994D694 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/ErrorPages.strings; sourceTree = "<group>"; };
BE7C456B81F81CACE2AC654A /* an */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = an; path = an.lproj/3DTouchActions.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -10409,6 +10411,7 @@
962F39492672D57A006BDA2A /* BookmarkItemsHelper.swift */,
39A359E31BFCCE94006B9E87 /* UserActivityHandler.swift */,
E18259DE29B25E4F00E6BE76 /* UserNotificationCenterProtocol.swift */,
BDD262552CE3AC8200DF2C62 /* PrivacyWindowHelper.swift */,
);
name = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -16745,6 +16748,7 @@
EB98550124226EF70040F24B /* AppDelegate+SyncSentTabs.swift in Sources */,
744ED5611DBFEB8D00A2B5BE /* MailtoLinkHandler.swift in Sources */,
8A720C622A4CBB370003018A /* SupportSettingsDelegate.swift in Sources */,
BDD262562CE3AC8200DF2C62 /* PrivacyWindowHelper.swift in Sources */,
DF1E6AAB2A976FE7000D4854 /* FakespotNoAnalysisCardView.swift in Sources */,
DA4F826729AD221600189590 /* ZoomPageBar.swift in Sources */,
59A68E0B4ABBF55E14819668 /* LegacyBookmarksPanel.swift in Sources */,
Expand Down Expand Up @@ -25665,7 +25669,7 @@
repositoryURL = "https://github.com/getsentry/sentry-cocoa.git";
requirement = {
kind = exactVersion;
version = 8.36.0;
version = 8.21.0;
};
};
5A984D322C8A31A0007938C9 /* XCRemoteSwiftPackageReference "Kingfisher" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/getsentry/sentry-cocoa.git",
"state" : {
"revision" : "5575af93efb776414f243e93d6af9f6258dc539a",
"version" : "8.36.0"
"revision" : "38f4f70d07117b9f958a76b1bff278c2f29ffe0e",
"version" : "8.21.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,8 @@ class BrowserViewController: UIViewController,
var topTabsVisible: Bool {
return topTabsViewController != nil
}
// Backdrop used for displaying greyed background for private tabs
private lazy var webViewContainerBackdrop: UIView = .build { containerBackdrop in
containerBackdrop.alpha = 0
}
// Window helper used for displaying an opaque background for private tabs.
private lazy var privacyWindowHelper = PrivacyWindowHelper()
var keyboardBackdrop: UIView?

lazy var scrollController = TabScrollingController(windowUUID: windowUUID)
Expand Down Expand Up @@ -510,9 +508,8 @@ class BrowserViewController: UIViewController,
canShowPrivacyView
else { return }

view.bringSubviewToFront(webViewContainerBackdrop)
webViewContainerBackdrop.alpha = 1
contentStackView.alpha = 0
privacyWindowHelper.showWindow(withThemedColor: currentTheme().colors.layer3)

if isToolbarRefactorEnabled {
addressToolbarContainer.alpha = 0
Expand Down Expand Up @@ -547,8 +544,7 @@ class BrowserViewController: UIViewController,
self.presentedViewController?.popoverPresentationController?.containerView?.alpha = 1
self.presentedViewController?.view.alpha = 1
}, completion: { _ in
self.webViewContainerBackdrop.alpha = 0
self.view.sendSubviewToBack(self.webViewContainerBackdrop)
self.privacyWindowHelper.removeWindow()
})

if let tab = tabManager.selectedTab, !tab.isFindInPageMode {
Expand Down Expand Up @@ -927,7 +923,7 @@ class BrowserViewController: UIViewController,
}

func addSubviews() {
view.addSubviews(webViewContainerBackdrop, contentStackView)
view.addSubviews(contentStackView)

contentStackView.addArrangedSubview(contentContainer)

Expand Down Expand Up @@ -1170,13 +1166,6 @@ class BrowserViewController: UIViewController,
}
}

NSLayoutConstraint.activate([
webViewContainerBackdrop.topAnchor.constraint(equalTo: view.topAnchor),
webViewContainerBackdrop.leadingAnchor.constraint(equalTo: view.leadingAnchor),
webViewContainerBackdrop.trailingAnchor.constraint(equalTo: view.trailingAnchor),
webViewContainerBackdrop.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])

NSLayoutConstraint.activate([
contentStackView.topAnchor.constraint(equalTo: header.bottomAnchor),
contentStackView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
Expand Down Expand Up @@ -3064,7 +3053,6 @@ class BrowserViewController: UIViewController,
statusBarOverlay.hasTopTabs = ToolbarHelper().shouldShowTopTabs(for: traitCollection)
statusBarOverlay.applyTheme(theme: currentTheme)
keyboardBackdrop?.backgroundColor = currentTheme.colors.layer1
webViewContainerBackdrop.backgroundColor = currentTheme.colors.layer3
setNeedsStatusBarAppearanceUpdate()

tabManager.selectedTab?.applyTheme(theme: currentTheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ struct MainMenuConfigurationUtility: Equatable, FeatureFlaggable {
MainMenuAction(
windowUUID: uuid,
actionType: MainMenuActionType.tapToggleUserAgent,
telemetryInfo: TelemetryInfo(isHomepage: tabInfo.isHomepage)
telemetryInfo: TelemetryInfo(isHomepage: tabInfo.isHomepage,
isDefaultUserAgentDesktop: tabInfo.isDefaultUserAgentDesktop,
hasChangedUserAgent: tabInfo.hasChangedUserAgent)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ import Foundation
import Glean

struct MainMenuTelemetry {
func optionTapped(with isHomepage: Bool, and option: String) {
func mainMenuOptionTapped(with isHomepage: Bool, and option: String) {
let extra = GleanMetrics.AppMenu.MainMenuOptionSelectedExtra(isHomepage: isHomepage, option: option)
GleanMetrics.AppMenu.mainMenuOptionSelected.record(extra)
}

func saveSubmenuOptionTapped(with isHomepage: Bool, and option: String) {
let extra = GleanMetrics.AppMenu.SaveMenuOptionSelectedExtra(isHomepage: isHomepage, option: option)
GleanMetrics.AppMenu.saveMenuOptionSelected.record(extra)
}

func toolsSubmenuOptionTapped(with isHomepage: Bool, and option: String) {
let extra = GleanMetrics.AppMenu.ToolsMenuOptionSelectedExtra(isHomepage: isHomepage, option: option)
GleanMetrics.AppMenu.toolsMenuOptionSelected.record(extra)
}

func closeButtonTapped(isHomepage: Bool) {
let extra = GleanMetrics.AppMenu.CloseButtonExtra(isHomepage: isHomepage)
GleanMetrics.AppMenu.closeButton.record(extra)
Expand Down
Loading

0 comments on commit 337edb1

Please sign in to comment.