Merge pull request #293 from fork-maintainers/upstream-sync
Pull in changes from Mozilla Firefox 86.1.1fix-addon-search iceraven-1.7.0
commit
1da7a9fac7
@ -1,5 +1,10 @@
|
||||
<html>
|
||||
<body>
|
||||
<a href="../resources/Globe.svg" download>Page content: Globe.svg</a>
|
||||
<a id="link" href="../resources/Globe.svg" download>Page content: Globe.svg</a>
|
||||
<script>
|
||||
(function() {
|
||||
document.getElementById("link").click()
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -0,0 +1,222 @@
|
||||
/* 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/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withParent
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.uiautomator.UiSelector
|
||||
import org.hamcrest.Matchers
|
||||
import org.hamcrest.Matchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the recently closed tabs menu.
|
||||
*/
|
||||
|
||||
class RecentlyClosedTabsRobot {
|
||||
|
||||
fun waitForListToExist() =
|
||||
mDevice.findObject(UiSelector().resourceId("org.mozilla.fenix.debug:id/recently_closed_list"))
|
||||
.waitForExists(
|
||||
TestAssetHelper.waitingTime
|
||||
)
|
||||
|
||||
fun verifyRecentlyClosedTabsMenuView() = assertRecentlyClosedTabsMenuView()
|
||||
|
||||
fun verifyEmptyRecentlyClosedTabsList() = assertEmptyRecentlyClosedTabsList()
|
||||
|
||||
fun verifyRecentlyClosedTabsPageTitle(title: String) = assertRecentlyClosedTabsPageTitle(title)
|
||||
|
||||
fun verifyRecentlyClosedTabsUrl(expectedUrl: Uri) = assertPageUrl(expectedUrl)
|
||||
|
||||
fun openRecentlyClosedTabsThreeDotMenu() = recentlyClosedTabsThreeDotButton().click()
|
||||
|
||||
fun verifyRecentlyClosedTabsMenuCopy() = assertRecentlyClosedTabsMenuCopy()
|
||||
|
||||
fun verifyRecentlyClosedTabsMenuShare() = assertRecentlyClosedTabsMenuShare()
|
||||
|
||||
fun verifyRecentlyClosedTabsMenuNewTab() = assertRecentlyClosedTabsOverlayNewTab()
|
||||
|
||||
fun verifyRecentlyClosedTabsMenuPrivateTab() = assertRecentlyClosedTabsMenuPrivateTab()
|
||||
|
||||
fun verifyRecentlyClosedTabsMenuDelete() = assertRecentlyClosedTabsMenuDelete()
|
||||
|
||||
fun clickCopyRecentlyClosedTabs() = recentlyClosedTabsCopyButton().click()
|
||||
|
||||
fun clickShareRecentlyClosedTabs() = recentlyClosedTabsShareButton().click()
|
||||
|
||||
fun clickDeleteCopyRecentlyClosedTabs() = recentlyClosedTabsDeleteButton().click()
|
||||
|
||||
fun verifyCopyRecentlyClosedTabsSnackBarText() = assertCopySnackBarText()
|
||||
|
||||
fun verifyShareOverlay() = assertRecentlyClosedShareOverlay()
|
||||
|
||||
fun verifyShareTabFavicon() = assertRecentlyClosedShareFavicon()
|
||||
|
||||
fun verifyShareTabTitle(title: String) = assetRecentlyClosedShareTitle(title)
|
||||
|
||||
fun verifyShareTabUrl(expectedUrl: Uri) = assertRecentlyClosedShareUrl(expectedUrl)
|
||||
|
||||
class Transition {
|
||||
fun clickOpenInNewTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
recentlyClosedTabsNewTabButton().click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickOpenInPrivateTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
recentlyClosedTabsNewPrivateTabButton().click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertRecentlyClosedTabsMenuView() {
|
||||
onView(
|
||||
allOf(
|
||||
withText("Recently closed tabs"),
|
||||
withParent(withId(R.id.navigationToolbar))
|
||||
)
|
||||
)
|
||||
.check(
|
||||
matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertEmptyRecentlyClosedTabsList() =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.recently_closed_empty_view),
|
||||
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)
|
||||
)
|
||||
)
|
||||
.check(
|
||||
matches(withText("No recently closed tabs here")))
|
||||
|
||||
private fun assertPageUrl(expectedUrl: Uri) = onView(
|
||||
allOf(
|
||||
withId(R.id.url),
|
||||
withEffectiveVisibility(
|
||||
Visibility.VISIBLE
|
||||
)
|
||||
)
|
||||
)
|
||||
.check(
|
||||
matches(withText(Matchers.containsString(expectedUrl.toString()))))
|
||||
|
||||
private fun recentlyClosedTabsPageTitle() = onView(
|
||||
allOf(
|
||||
withId(R.id.title),
|
||||
withText("Test_Page_1")
|
||||
)
|
||||
)
|
||||
|
||||
private fun assertRecentlyClosedTabsPageTitle(title: String) {
|
||||
recentlyClosedTabsPageTitle()
|
||||
.check(
|
||||
matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
.check(
|
||||
matches(withText(title)))
|
||||
}
|
||||
|
||||
private fun recentlyClosedTabsThreeDotButton() =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.overflow_menu),
|
||||
withEffectiveVisibility(
|
||||
Visibility.VISIBLE
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
private fun assertRecentlyClosedTabsMenuCopy() =
|
||||
onView(withText("Copy"))
|
||||
.check(
|
||||
matches(
|
||||
withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertRecentlyClosedTabsMenuShare() =
|
||||
onView(withText("Share"))
|
||||
.check(
|
||||
matches(
|
||||
withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun assertRecentlyClosedTabsOverlayNewTab() =
|
||||
onView(withText("Open in new tab"))
|
||||
.check(
|
||||
matches(
|
||||
withEffectiveVisibility(Visibility.VISIBLE))
|
||||
)
|
||||
|
||||
private fun assertRecentlyClosedTabsMenuPrivateTab() =
|
||||
onView(withText("Open in private tab"))
|
||||
.check(
|
||||
matches(
|
||||
withEffectiveVisibility(Visibility.VISIBLE)
|
||||
)
|
||||
)
|
||||
|
||||
private fun assertRecentlyClosedTabsMenuDelete() =
|
||||
onView(withText("Delete"))
|
||||
.check(
|
||||
matches(
|
||||
withEffectiveVisibility(Visibility.VISIBLE)
|
||||
)
|
||||
)
|
||||
|
||||
private fun recentlyClosedTabsCopyButton() = onView(withText("Copy"))
|
||||
|
||||
private fun copySnackBarText() = onView(withId(R.id.snackbar_text))
|
||||
|
||||
private fun assertCopySnackBarText() = copySnackBarText()
|
||||
.check(
|
||||
matches
|
||||
(withText("URL copied")))
|
||||
|
||||
private fun recentlyClosedTabsShareButton() = onView(withText("Share"))
|
||||
|
||||
private fun assertRecentlyClosedShareOverlay() =
|
||||
onView(withId(R.id.shareWrapper))
|
||||
.check(
|
||||
matches(ViewMatchers.isDisplayed()))
|
||||
|
||||
private fun assetRecentlyClosedShareTitle(title: String) =
|
||||
onView(withId(R.id.share_tab_title))
|
||||
.check(
|
||||
matches(ViewMatchers.isDisplayed()))
|
||||
.check(
|
||||
matches(withText(title)))
|
||||
|
||||
private fun assertRecentlyClosedShareFavicon() =
|
||||
onView(withId(R.id.share_tab_favicon))
|
||||
.check(
|
||||
matches(ViewMatchers.isDisplayed()))
|
||||
|
||||
private fun assertRecentlyClosedShareUrl(expectedUrl: Uri) =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.share_tab_url),
|
||||
withEffectiveVisibility(Visibility.VISIBLE)
|
||||
)
|
||||
)
|
||||
.check(
|
||||
matches(withText(Matchers.containsString(expectedUrl.toString()))))
|
||||
|
||||
private fun recentlyClosedTabsNewTabButton() = onView(withText("Open in new tab"))
|
||||
|
||||
private fun recentlyClosedTabsNewPrivateTabButton() = onView(withText("Open in private tab"))
|
||||
|
||||
private fun recentlyClosedTabsDeleteButton() = onView(withText("Delete"))
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
package org.mozilla.fenix.home.intent
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.navigation.NavController
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.sessionsOfType
|
||||
|
||||
/**
|
||||
* The Private Browsing Mode notification has an "Delete and Open" button to let users delete all
|
||||
* of their private tabs.
|
||||
*/
|
||||
class NotificationsIntentProcessor(
|
||||
private val activity: HomeActivity
|
||||
) : HomeIntentProcessor {
|
||||
|
||||
override fun process(intent: Intent, navController: NavController, out: Intent): Boolean {
|
||||
return if (intent.extras?.getBoolean(HomeActivity.EXTRA_DELETE_PRIVATE_TABS) == true) {
|
||||
out.putExtra(HomeActivity.EXTRA_DELETE_PRIVATE_TABS, false)
|
||||
activity.components.core.sessionManager.run {
|
||||
sessionsOfType(private = true).forEach { remove(it) }
|
||||
}
|
||||
true
|
||||
} else intent.extras?.getBoolean(HomeActivity.EXTRA_OPENED_FROM_NOTIFICATION) == true
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/* 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/. */
|
||||
|
||||
package org.mozilla.fenix.perf
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import org.mozilla.fenix.ext.getAndIncrementNoOverflow
|
||||
import java.lang.reflect.Modifier.PRIVATE
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
private val classPrefixList = arrayOf(
|
||||
"android.widget.",
|
||||
"android.webkit.",
|
||||
"android.app."
|
||||
)
|
||||
/**
|
||||
* Counts the number of inflations fenix does. This class behaves only as an inflation counter since
|
||||
* it takes the `inflater` that is given by the base system. This is done in order not to change
|
||||
* the behavior of the app since all we want to do is count the inflations done.
|
||||
*
|
||||
*/
|
||||
open class PerformanceInflater(
|
||||
inflater: LayoutInflater,
|
||||
context: Context
|
||||
) : LayoutInflater(
|
||||
inflater,
|
||||
context
|
||||
) {
|
||||
|
||||
override fun cloneInContext(newContext: Context?): LayoutInflater {
|
||||
return PerformanceInflater(this, newContext!!)
|
||||
}
|
||||
|
||||
override fun inflate(resource: Int, root: ViewGroup?, attachToRoot: Boolean): View {
|
||||
InflationCounter.inflationCount.getAndIncrementNoOverflow()
|
||||
return super.inflate(resource, root, attachToRoot)
|
||||
}
|
||||
|
||||
/**
|
||||
* This code was taken from the PhoneLayoutInflater.java located in the android source code
|
||||
* (Similarly, AsyncLayoutInflater implements it the exact same way too which can be found in the
|
||||
* Android Framework). This piece of code was taken from the other inflaters implemented by Android
|
||||
* since we do not want to change the inflater behavior except to count the number of inflations
|
||||
* that our app is doing for performance purposes. Looking at the `super.OnCreateView(name, attrs)`,
|
||||
* it hardcodes the prefix as "android.view." this means that a xml element such as
|
||||
* ImageButton will crash the app using android.view.ImageButton. This method only works with
|
||||
* XML tag that contains no prefix. This means that views such as androidx.recyclerview... will not
|
||||
* work with this method.
|
||||
*/
|
||||
@Suppress("EmptyCatchBlock")
|
||||
@Throws(ClassNotFoundException::class)
|
||||
override fun onCreateView(name: String?, attrs: AttributeSet?): View? {
|
||||
for (prefix in classPrefixList) {
|
||||
try {
|
||||
val view = createView(name, prefix, attrs)
|
||||
if (view != null) {
|
||||
return view
|
||||
}
|
||||
} catch (e: ClassNotFoundException) {
|
||||
// We want the super class to inflate if ever the view can't be inflated here
|
||||
}
|
||||
}
|
||||
return super.onCreateView(name, attrs)
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = PRIVATE)
|
||||
object InflationCounter {
|
||||
val inflationCount = AtomicInteger(0)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue