Scenario A (URL) : Lumenci Technical Assessment #3: Firefox iOS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Lumenci Technical Assessment #3: Firefox iOS

Scenario A (URL)

Function:​ t​ extFieldShouldReturn(_ textField: UITextField) 

File: ​Apple Developer Function 

Description:  

1. Apple Developer Function that will process the user input for the “return” button. 
This function is imported with “UIKit” and the developer can write a process that will 
start when the user clicks “return” or “go” on the iPhone keyboard. This is used to 
initiate the URL loading process. 
2. In this case, the “Go” button will initiate textFieldShouldReturn(), which first calls 
autoCompletion(). 
3. Returns a call to autocompleteTextFieldShouldReturn(self) to continue the Webpage 
Load Process 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ a
​ pplyCompletion() 

File: ​AutocompleteTextField.swift 

Description: ​When a user enters a URL, firefox will autocomplete with suggestions. If the 
user clicks “Go” while the autocomplete URL is shown, autoCompletion() will turn the 
suggestion into a real text input and complete it for the user. If the user types the URL 
themselves, then this will not affect it and the process will continue with the input text. 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ a
​ utocompleteTextFieldShouldReturn(self) 

File: ​URLBarView.swift 

Description: ​This function transfers the text in the URL Bar into a variable, trims the white 
space, and calls urlbar() with the “didSubmit” text. The “didSubmit” text distinguishes which 
urlbar() function to run and implies the user requested to go to the page via the “go” 
button. Lastly, if the URL Bar has no text, then the function will just return false. 

------------------------------------------------------------------------------------------------------------------------------------ 
Lumenci Technical Assessment #3: Firefox iOS

Function:​ u
​ rlBar(_ urlBar: URLBarView, didSubmitText text: String) 

File: ​BrowserViewController.swift 

Description: ​Decides what action to take based on the input text in the URL bar. If it passes 
as a valid “URL” then it will call “finishEditingAndSubmit()”. If it does not, this function will 
then treat it as a search text. 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ U
​ RIFixup.getURL(text) 

File: ​URIFixup.swift 

Description: ​Converts the text into a valid URL for the network to receive. It may add “http” 
or any special characters needed to create a valid URL. If it cannot build a URL, the function 
will return nil. 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ f​ inishEditingandSubmit() 

File: ​BrowserViewController.swift 

Description: ​Returns back to the normal browser view and will call 
loadRequest(URLRequest(url: url)) to retrieve the web page. This webpage is then shown on 
the screen with self.recordNavigationInTab() 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ U
​ RLRequest() 

File: ​Apple Developer Function 

Description: ​Encapsulates the URL and the policies to load it as well as the HTTP request to 
get it. 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ l​ oadRequest() 

File: ​Apple Developer Function 

Description: ​Receives the URL information, obtains the information from the server, loads 
the webpage, and navigates to the page. 
Lumenci Technical Assessment #3: Firefox iOS

Scenario B (Download)
Function:​ w
​ ebView(_ webView: WKWebView, contextMenuConfigurationForElement elementInfo: 
WKContextMenuElementInfo, completionHandler: @escaping (UIContextMenuConfiguration?) 

File: ​BrowserViewController+WebViewDelegates.swift 

Description: ​Context Menu (“Open in New Tab”, “Bookmark Link”, “Download Link”, etc.) is 
triggered when the user performs a long press on an element such as a link. This runs 
webView(), which previews the link and displays action buttons for the user. One action 
button (UIAction) is the “Download Link” button. When pressed, the program checks if the 
link is a blob or not.  

● If it is a blob, it will run requestBlobDownload() 


● If not. It will begin the download using URLRequest() and webview() (Note: this 
webview is a different function from this one) 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ r​ equestBlobDownload(url: url, tab: currentTab) 

File: ​DownloadContentScript.swift 

Description: ​Executes a blob download and then follows the same process as a normal 
download (Seen below) 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ w
​ ebView(_ webView: WKWebView, decidePolicyFor navigationResponse: 
WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) 

File: ​BrowserViewController+WebViewDelegates.swift 

Description: ​Checks to see if the call was for a download. If it is, the function calls 
downloadHelper.open() to open the next menu to initiate download. 

------------------------------------------------------------------------------------------------------------------------------------ 

 
Lumenci Technical Assessment #3: Firefox iOS

Function:​ D
​ ownloadHelper.open() 

File: ​OpeninHelper.swift 

Description:  

1. Creates an HTTPDownload object to retrieve file name and size and to create a 
DownloadTask object 
2. Creates one PhotonActionSheetItem object to display the file name and size to the 
user if the size variable contains a valid value 
3. Creates a second PhotonActionSheetItem object to prompt the user to initiate the 
download with a “Download Now” button. This particular object also has code that 
will run if the user clicks the button.  
4. An action is created to initiate the code if the user clicks “Download Now”. This will 
call “self.browserViewController.downloadQueue.enqueue(download)” to initiate 
the download. 

------------------------------------------------------------------------------------------------------------------------------------ 

Object:​ ​HTTPDownload() 

File: ​DownloadQueue.swift 

Description:  

1. When initialized, this object receives a URLRequest and URLResponse object. It uses 
these objects to store file name and file size into class variables to be used by any 
calling code (i.e. DownloadHelper.open()).  
2. More importantly, this initializes a download task which is how the device retrieves 
the data for the download. The download will not start until resume() is called.  
3. A URLSession Object is initialized, which is an API used to download and upload 
from URLs. 

------------------------------------------------------------------------------------------------------------------------------------ 

Object:​ ​PhotonActionSheetItem() 

File: ​PhotonActionSheetWidgets.swift 

Description: ​When initialized, this object receives attributes that describe a simple widget 
popup for the user to interact with when browsing. This can be the title, font, text, position, 
or button etc. 
Lumenci Technical Assessment #3: Firefox iOS

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ p
​ resentSheetWith(actions: actions, on: browserViewController, from: 
browserViewController.urlBar, closeButtonTitle: Strings.CancelString, suppressPopover: true) 

File: ​PhotonActionSheetProtocol.swift 

Description: ​Displays the desired actions, buttons, and text onto the screen for the user to 
interact with. Inputs consist of actions, titles, controller, and cancel action. 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ s​ elf.browserViewController.downloadQueue.enqueue(download) 

File: ​DownloadQueue.swift 

Description:  

1. Clears the Download Queue if it was already empty at the start 


2. Updates the total bytes to download. For example, if user was already downloading 
an item of 500 bytes and decides to download a 250 byte file, then the total bytes 
would be 750 bytes. 
3. Resumes the download with download.resume(), which belongs to the 
HTTPDownload Class and actually starts the download process. 
4. calls downloadQueue() 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ d
​ ownload.resume() 

File: ​DownloadQueue.swift 

Description: ​Calls the resume() functions associated with the downloadTask that was 
created with the download initialization. This begins the download process and saves the 
file to the device. 

------------------------------------------------------------------------------------------------------------------------------------ 
Lumenci Technical Assessment #3: Firefox iOS

Function:​ d
​ ownloadQueue(_ downloadQueue: DownloadQueue, didStartDownload download: 
Download) 

File: ​BrowserViewController+DownloadQueueDelegate.swift 

Description:  

1. Creates a download toast if one does not already exist with DownloadToast(). To 
define, a download toast displays the progress of the download to the user.  
2. If a download is in progress, the download will just be added to the existing toast. 

------------------------------------------------------------------------------------------------------------------------------------ 

Object:​ ​DownloadToast() 

File: ​DownloadToast.swift 

Description: ​Creates a DownloadToast object with a Download object as a passing 


parameter. Using the Download object, it receives values like expected file size and file 
name and displays the progress of the download for the user by number of bytes. 

------------------------------------------------------------------------------------------------------------------------------------ 

Function:​ a
​ ddDownload() 

File: ​DownloadToast.swift 

Description: ​Updates the total expected bytes to download to reflect new download. This 
updated number will display in the widget 

------------------------------------------------------------------------------------------------------------------------------------ 

Object:​ ​downloadTask() 

File: ​Apple Developer Function 


Lumenci Technical Assessment #3: Firefox iOS

Description: ​Creates a task to download a file from a URL. This function takes the contents 
of the URL and saves it to the device. This task contains functions to pause, resume, and 
cancel download or all downloads. 

 
Lumenci Technical Assessment #3: Firefox iOS

You might also like