Skip to content

Commit

Permalink
Bug 1860725 - Revert "Bug 1812797 - Add referrerUrl to Request"
Browse files Browse the repository at this point in the history
This reverts commit 9947b70.
  • Loading branch information
mcarare authored and mergify[bot] committed Oct 24, 2023
1 parent 676b500 commit e0b3b74
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ private fun Request.toWebRequest(): WebRequest = WebRequest.Builder(url)
.method(method.name)
.addHeadersFrom(this)
.addBodyFrom(this)
.referrer(referrerUrl)
.cacheMode(if (useCaches) CACHE_MODE_DEFAULT else CACHE_MODE_RELOAD)
// Turn off bleeding-edge network features to avoid breaking core browser functionality.
.beConservative(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,6 @@ class GeckoViewFetchUnitTestCases : FetchTestCases() {
assertEquals(Response.SUCCESS, builder.toResponse().status)
}

@Test
fun get200WithReferrerUrl() {
mockResponse(200)

val request = mock<Request>()
whenever(request.url).thenReturn("https://mozilla.org")
whenever(request.method).thenReturn(Request.Method.GET)
whenever(request.referrerUrl).thenReturn("https://mozilla.org")
createNewClient().fetch(request)

val captor = ArgumentCaptor.forClass(WebRequest::class.java)

verify(geckoWebExecutor)!!.fetch(captor.capture(), eq(GeckoWebExecutor.FETCH_FLAGS_NONE))
assertEquals("https://mozilla.org", captor.value.referrer)
}

@Test
fun toResponseMustReturn200ForDataUrls() {
val builder = WebResponse.Builder("data:,Hello%2C%20World!").statusCode(0).build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ data class ShareInternetResourceState(
val contentType: String? = null,
val private: Boolean = false,
val response: Response? = null,
val referrerUrl: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ data class Request(
val cookiePolicy: CookiePolicy = CookiePolicy.INCLUDE,
val useCaches: Boolean = true,
val private: Boolean = false,
val referrerUrl: String? = null,
) {
/**
* A [Body] to be send with the [Request].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class RequestTest {
redirect = Request.Redirect.MANUAL,
cookiePolicy = Request.CookiePolicy.INCLUDE,
useCaches = true,
referrerUrl = "https://mozilla.org",
)

assertEquals("https://www.mozilla.org", request.url)
Expand All @@ -64,7 +63,6 @@ class RequestTest {
assertEquals(Request.Redirect.MANUAL, request.redirect)
assertEquals(Request.CookiePolicy.INCLUDE, request.cookiePolicy)
assertEquals(true, request.useCaches)
assertEquals("https://mozilla.org", request.referrerUrl)

val headers = request.headers!!
assertEquals(3, headers.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,7 @@ data class ContextMenuCandidate(
action = { tab, hitResult ->
contextMenuUseCases.injectDownload(
tab.id,
DownloadState(
hitResult.src,
skipConfirmation = true,
private = tab.content.private,
referrerUrl = tab.content.url,
),
DownloadState(hitResult.src, skipConfirmation = true, private = tab.content.private),
)
},
)
Expand Down Expand Up @@ -395,7 +390,6 @@ data class ContextMenuCandidate(
ShareInternetResourceState(
url = hitResult.src,
private = tab.content.private,
referrerUrl = tab.content.url,
),
)
},
Expand Down Expand Up @@ -424,12 +418,7 @@ data class ContextMenuCandidate(
action = { tab, hitResult ->
contextMenuUseCases.injectDownload(
tab.id,
DownloadState(
hitResult.src,
skipConfirmation = true,
private = tab.content.private,
referrerUrl = tab.content.url,
),
DownloadState(hitResult.src, skipConfirmation = true, private = tab.content.private),
)
},
)
Expand Down Expand Up @@ -457,12 +446,7 @@ data class ContextMenuCandidate(
action = { tab, hitResult ->
contextMenuUseCases.injectDownload(
tab.id,
DownloadState(
hitResult.src,
skipConfirmation = true,
private = tab.content.private,
referrerUrl = tab.content.url,
),
DownloadState(hitResult.src, skipConfirmation = true, private = tab.content.private),
)
},
)
Expand Down Expand Up @@ -526,7 +510,6 @@ data class ContextMenuCandidate(
ShareInternetResourceState(
url = hitResult.src,
private = tab.content.private,
referrerUrl = tab.content.url,
),
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ abstract class AbstractFetchDownloadService : Service() {
download.url.sanitizeURL(),
headers = headers,
private = download.private,
referrerUrl = download.referrerUrl,
)
// When resuming a download we need to use the httpClient as
// download.response doesn't support adding headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ abstract class TemporaryDownloadFeature(
@WorkerThread
@VisibleForTesting
internal fun download(internetResource: ShareInternetResourceState): File {
val request = Request(
internetResource.url.sanitizeURL(),
private = internetResource.private,
referrerUrl = internetResource.referrerUrl,
)
val request = Request(internetResource.url.sanitizeURL(), private = internetResource.private)
val response = if (internetResource.response == null) {
httpClient.fetch(request)
} else {
Expand Down

0 comments on commit e0b3b74

Please sign in to comment.