Skip to content

Commit

Permalink
Add possibility to stop page loading (#3553)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1206226850447395/1206267785501484/f
Tech Design URL:
CC:

**Description**:

Adds an additional OmniBar state variation when the website is loading,
allowing to stop the loading process.

**Steps to test this PR**:
💡 It's helpful to test on a physical device (with link conditioner
enabled to slow down loading) or using [link
conditioner](https://nshipster.com/network-link-conditioner/) for
simulator.

1. Start loading a website on 2 or more tabs.
2. Switch between them and observe if state is shown properly. (swiping
on address bar is helpful to do it quickly).
3. Stop loading. 
4. Verify omni bar state is valid (refresh is visible) and:
    a. if no valid resources were loaded error page should be presented
b. if some resources were loaded and can be displayed, partially loaded
website should be visible
    c. pixel is sent.

<!--
Before submitting a PR, please ensure you have tested the combinations
you expect the reviewer to test, then delete configurations you *know*
do not need explicit testing.

Using a simulator where a physical device is unavailable is acceptable.
-->

**Definition of Done (Internal Only)**:

* [x] Does this PR satisfy our [Definition of
Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?

**Orientation Testing**:

* [x] Portrait
* [x] Landscape

**Device Testing**:

* [ ] iPhone SE (1st Gen)
* [ ] iPhone 8
* [ ] iPhone X
* [x] iPhone 15 Pro
* [x] iPad

**OS Testing**:

* [x] iOS 15
* [ ] iOS 16
* [x] iOS 18

**Theme Testing**:

* [x] Light theme
* [x] Dark theme

---
###### Internal references:
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
  • Loading branch information
dus7 authored Nov 13, 2024
1 parent 1d14059 commit 5879142
Show file tree
Hide file tree
Showing 16 changed files with 614 additions and 307 deletions.
9 changes: 7 additions & 2 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ extension Pixel {
case protectedDataUnavailableWhenBecomeActive
case statisticsLoaderATBStateMismatch
case adAttributionReportStateMismatch

// MARK: Browsing
case stopPageLoad

// MARK: - DuckPlayer Overlay Navigation
case duckPlayerYouTubeOverlayNavigationBack
Expand Down Expand Up @@ -1702,6 +1705,9 @@ extension Pixel.Event {
case .protectedDataUnavailableWhenBecomeActive: return "m_protected_data_unavailable_when_become_active"
case .statisticsLoaderATBStateMismatch: return "m_statistics_loader_atb_state_mismatch"
case .adAttributionReportStateMismatch: return "m_ad_attribution_report_state_mismatch"

// MARK: Browsing
case .stopPageLoad: return "m_stop-page-load"

// MARK: - DuckPlayer Overlay Navigation
case .duckPlayerYouTubeOverlayNavigationBack: return "duckplayer.youtube.overlay.navigation.back"
Expand All @@ -1710,8 +1716,7 @@ extension Pixel.Event {
case .duckPlayerYouTubeOverlayNavigationOutsideYoutube: return "duckplayer.youtube.overlay.navigation.outside-youtube"
case .duckPlayerYouTubeOverlayNavigationClosed: return "duckplayer.youtube.overlay.navigation.closed"
case .duckPlayerYouTubeNavigationIdle30: return "duckplayer.youtube.overlay.idle-30"



}
}
}
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
6F04224D2CD2A3AD00729FA6 /* StorageInconsistencyMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F98573F2CD2933B001BE9A0 /* StorageInconsistencyMonitor.swift */; };
6F0FEF6B2C516D540090CDE4 /* NewTabPageSettingsStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F0FEF6A2C516D540090CDE4 /* NewTabPageSettingsStorage.swift */; };
6F0FEF6D2C52639E0090CDE4 /* ReorderableForEach.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F0FEF6C2C52639E0090CDE4 /* ReorderableForEach.swift */; };
6F3529FF2CDCEDFF00A59170 /* OmniBarLoadingStateBearerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F3529FE2CDCEDF700A59170 /* OmniBarLoadingStateBearerTests.swift */; };
6F35379E2C4AAF2E009F8717 /* NewTabPageSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F35379D2C4AAF2E009F8717 /* NewTabPageSettingsView.swift */; };
6F3537A02C4AAFD2009F8717 /* NewTabPageSettingsSectionItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F35379F2C4AAFD2009F8717 /* NewTabPageSettingsSectionItemView.swift */; };
6F3537A22C4AB97A009F8717 /* NewTabPageSettingsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F3537A12C4AB97A009F8717 /* NewTabPageSettingsModel.swift */; };
Expand Down Expand Up @@ -1599,6 +1600,7 @@
6F03CB082C32F331004179A8 /* PixelFiringAsync.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PixelFiringAsync.swift; sourceTree = "<group>"; };
6F0FEF6A2C516D540090CDE4 /* NewTabPageSettingsStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageSettingsStorage.swift; sourceTree = "<group>"; };
6F0FEF6C2C52639E0090CDE4 /* ReorderableForEach.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReorderableForEach.swift; sourceTree = "<group>"; };
6F3529FE2CDCEDF700A59170 /* OmniBarLoadingStateBearerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OmniBarLoadingStateBearerTests.swift; sourceTree = "<group>"; };
6F35379D2C4AAF2E009F8717 /* NewTabPageSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageSettingsView.swift; sourceTree = "<group>"; };
6F35379F2C4AAFD2009F8717 /* NewTabPageSettingsSectionItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageSettingsSectionItemView.swift; sourceTree = "<group>"; };
6F3537A12C4AB97A009F8717 /* NewTabPageSettingsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageSettingsModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6309,6 +6311,7 @@
F1D477C71F2139210031ED49 /* OmniBar */ = {
isa = PBXGroup;
children = (
6F3529FE2CDCEDF700A59170 /* OmniBarLoadingStateBearerTests.swift */,
BBFF18B02C76448100C48D7D /* QuerySubmittedTests.swift */,
8588026424E4209900C24AB6 /* LargeOmniBarStateTests.swift */,
85F20005221702F7006BB258 /* AddressDisplayHelperTests.swift */,
Expand Down Expand Up @@ -8107,6 +8110,7 @@
9F4CC51D2C48D240006A96EB /* CoreDataDatabaseTestUtilities.swift in Sources */,
C185ED672BD43DA100BAE9DC /* ImportPasswordsStatusHandlerTests.swift in Sources */,
F198D7981E3A45D90088DA8A /* WKWebViewConfigurationExtensionTests.swift in Sources */,
6F3529FF2CDCEDFF00A59170 /* OmniBarLoadingStateBearerTests.swift in Sources */,
564DE45E2C45218500D23241 /* OnboardingNavigationDelegateTests.swift in Sources */,
C14E2F7729DE14EA002AC515 /* AutofillInterfaceUsernameTruncatorTests.swift in Sources */,
9F7CFF782C86E3E10012833E /* OnboardingManagerTests.swift in Sources */,
Expand Down
25 changes: 19 additions & 6 deletions DuckDuckGo/Base.lproj/OmniBar.xib
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sek-4Y-GoT" customClass="SearchFieldContainerView" customModule="DuckDuckGo" customModuleProvider="target">
<rect key="frame" x="30" y="0.0" width="343" height="40"/>
<rect key="frame" x="30" y="0.0" width="313" height="40"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yEJ-P3-HpO" customClass="OmniBarNotificationContainerView" customModule="DuckDuckGo" customModuleProvider="target">
<rect key="frame" x="-4" y="0.0" width="347" height="40"/>
<rect key="frame" x="-4" y="0.0" width="317" height="40"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yGG-5L-D8Q" customClass="PrivacyInfoContainerView" customModule="DuckDuckGo" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="138" height="40"/>
Expand Down Expand Up @@ -217,7 +217,7 @@
</connections>
</view>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" adjustsFontSizeToFit="NO" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="fqM-N4-jNd" customClass="TextFieldWithInsets" customModule="DuckDuckGo" customModuleProvider="target">
<rect key="frame" x="30" y="0.0" width="313" height="40"/>
<rect key="frame" x="30" y="0.0" width="283" height="40"/>
<color key="tintColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<accessibility key="accessibilityConfiguration" identifier="searchEntry">
<accessibilityTraits key="traits" searchField="YES"/>
Expand Down Expand Up @@ -260,7 +260,7 @@
</connections>
</view>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ita-iD-8ad" userLabel="Voice Button">
<rect key="frame" x="373" y="5" width="30" height="30"/>
<rect key="frame" x="343" y="5" width="30" height="30"/>
<accessibility key="accessibilityConfiguration" label="Voice Search"/>
<constraints>
<constraint firstAttribute="width" priority="900" constant="30" id="80Y-p8-kj7"/>
Expand All @@ -272,7 +272,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Dt8-We-5tV">
<rect key="frame" x="403" y="0.0" width="30" height="40"/>
<rect key="frame" x="373" y="0.0" width="30" height="40"/>
<accessibility key="accessibilityConfiguration" label="Clear Text"/>
<constraints>
<constraint firstAttribute="width" priority="900" constant="30" id="Ym5-FI-uOP"/>
Expand All @@ -283,7 +283,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qea-QY-LVl">
<rect key="frame" x="433" y="8" width="30" height="24"/>
<rect key="frame" x="403" y="8" width="30" height="24"/>
<accessibility key="accessibilityConfiguration" label="Refresh Page"/>
<constraints>
<constraint firstAttribute="width" priority="900" constant="30" id="PHR-dd-ThY"/>
Expand All @@ -293,6 +293,17 @@
<action selector="onRefreshPressed:" destination="ojX-nM-dyN" eventType="touchUpInside" id="4Dg-IX-SdK"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gb5-wL-4OW" userLabel="Abort Button">
<rect key="frame" x="433" y="8" width="30" height="24"/>
<accessibility key="accessibilityConfiguration" label="Clear Text"/>
<constraints>
<constraint firstAttribute="width" priority="900" constant="30" id="MmC-kg-OHF"/>
</constraints>
<state key="normal" image="Close-24"/>
<connections>
<action selector="onAbortButtonPressed:" destination="ojX-nM-dyN" eventType="touchUpInside" id="AUa-p9-XUK"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" red="0.66666666669999997" green="0.66666666669999997" blue="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down Expand Up @@ -398,6 +409,7 @@
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="abortButton" destination="gb5-wL-4OW" id="khG-dO-p4p"/>
<outlet property="backButton" destination="i9n-fD-ncJ" id="5sk-Ld-2Pq"/>
<outlet property="bookmarksButton" destination="ii4-Sq-bD1" id="XN8-Yb-eXK"/>
<outlet property="cancelButton" destination="IHT-9R-ERy" id="XVf-QQ-jSa"/>
Expand Down Expand Up @@ -449,6 +461,7 @@
<image name="BrowseNext" width="24" height="24"/>
<image name="BrowsePrevious" width="24" height="24"/>
<image name="Clear-24" width="24" height="24"/>
<image name="Close-24" width="24" height="24"/>
<image name="Find-Search-20" width="20" height="20"/>
<image name="LogoIcon" width="24" height="24"/>
<image name="Microphone-24" width="24" height="24"/>
Expand Down
6 changes: 5 additions & 1 deletion DuckDuckGo/BlankSnapshotViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ extension BlankSnapshotViewController: UICollectionViewDataSource {
}

extension BlankSnapshotViewController: OmniBarDelegate {

func onVoiceSearchPressed() {
// No-op
}
Expand Down Expand Up @@ -202,6 +202,10 @@ extension BlankSnapshotViewController: OmniBarDelegate {
func onClearPressed() {
// No-op
}

func onAbortPressed() {
// no-op
}
}

extension BlankSnapshotViewController: TabSwitcherButtonDelegate {
Expand Down
Loading

0 comments on commit 5879142

Please sign in to comment.