Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge #7160 #7196
Browse files Browse the repository at this point in the history
7160:  Closes #7142: Sanitize url in HttpIconLoader  r=pocmo a=Amejia481



7196: Closes #7176: Add to the configuration file for instrumentation tests components that use Room r=gabrielluong,pocmo,isabelrios a=Amejia481

Closes #7176


Co-authored-by: Arturo Mejia <[email protected]>
  • Loading branch information
MozLando and Amejia481 committed Jun 3, 2020
3 parents fc17511 + 98158c8 + b7c015a commit 8998e8c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 20 deletions.
11 changes: 9 additions & 2 deletions automation/taskcluster/androidTest/ui-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@ samples=${component//samples-}
if [[ "${component}" != samples-* ]]
then
# Case 1: tests for any component (but NOT samples, NOT real UI tests)
APK_APP="./samples/${component}/build/outputs/apk/geckoNightly/debug/samples-${component}-geckoNightly-debug.apk"
APK_TEST="./components/${component}/engine-gecko-nightly/build/outputs/apk/androidTest/debug/browser-engine-gecko-nightly-debug-androidTest.apk"
APK_APP="./samples/browser/build/outputs/apk/geckoNightly/debug/samples-browser-geckoNightly-debug.apk"
if [[ "${component}" == *"-"* ]]
then
regex='([a-z]*)-(.*)'
[[ "$component" =~ $regex ]]
APK_TEST="./components/${BASH_REMATCH[1]}/${BASH_REMATCH[2]}/build/outputs/apk/androidTest/debug/${component}-debug-androidTest.apk"
else
APK_TEST="./components/${component}/engine-gecko-nightly/build/outputs/apk/androidTest/debug/browser-engine-gecko-nightly-debug-androidTest.apk"
fi
elif [[ "${component}" == "samples-browser" ]]
then
# Case 2: tests for browser sample (geckoNightly sample only)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private fun JSONObject.toIconResource(): IconRequest.Resource? {
val maskable = optBoolean("maskable", false)

return IconRequest.Resource(
url = url,
url = url.trim(),
type = type,
sizes = sizes,
mimeType = if (mimeType.isNullOrEmpty()) null else mimeType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,21 @@ class IconMessageKtTest {
val restoredResources = json.toIconResources()
assertEquals(resources, restoredResources)
}

@Test
fun `Url must be sanitized`() {
val resources = listOf(
IconRequest.Resource(
url = "\nhttps://www.mozilla.org/icon64.png\n",
sizes = listOf(Size(64, 64)),
mimeType = "image/png",
type = IconRequest.Resource.Type.FAVICON
)
)

val json = resources.toJSON()

val restoredResource = json.toIconResources().first()
assertEquals("https://www.mozilla.org/icon64.png", restoredResource.url)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class TopSiteStorageTest {
execSQL(
"INSERT INTO " +
"top_sites " +
"(title, url, isDefault, created_at) " +
"(title, url, is_default, created_at) " +
"VALUES " +
"('Firefox','firefox.com',1,5)," +
"('Monitor','https://monitor.firefox.com/',0,5)"
Expand All @@ -154,29 +154,29 @@ class TopSiteStorageTest {
dbVersion2.query("SELECT * FROM top_sites").use { cursor ->
assertEquals(5, cursor.columnCount)

// Check isDefault for Mozilla
// Check is_default for Mozilla
cursor.moveToFirst()
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Top Articles
// Check is_default for Top Articles
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Wikipedia
// Check is_default for Wikipedia
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for YouTube
// Check is_default for YouTube
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Firefox
// Check is_default for Firefox
cursor.moveToNext()
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(1, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))

// Check isDefault for Monitor
// Check is_default for Monitor
cursor.moveToNext()
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("isDefault")))
assertEquals(0, cursor.getInt(cursor.getColumnIndexOrThrow("is_default")))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ internal abstract class TopSiteDatabase : RoomDatabase() {
internal object Migrations {
val migration_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
// Add the new isDefault column and set isDefault to 0 (false) for every entry.
// Add the new is_default column and set is_default to 0 (false) for every entry.
database.execSQL(
"ALTER TABLE top_sites ADD COLUMN isDefault INTEGER NOT NULL DEFAULT 0"
"ALTER TABLE top_sites ADD COLUMN is_default INTEGER NOT NULL DEFAULT 0"
)

// Prior to version 2, pocket top sites, wikipedia and youtube were added as default
// sites in Fenix. Look for these entries and set isDefault to 1 (true).
// sites in Fenix. Look for these entries and set is_default to 1 (true).
database.execSQL(
"UPDATE top_sites " +
"SET isDefault = 1 " +
"SET is_default = 1 " +
"WHERE url IN " +
"('https://getpocket.com/fenix-top-articles', " +
"'https://www.wikipedia.org/', " +
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Config.kt)

* **browser-icons**
* Fixed issue [#7142](https://github.com/mozilla-mobile/android-components/issues/7142)

# 44.0.0

* [Commits](https://github.com/mozilla-mobile/android-components/compare/v43.0.0...v44.0.0)
Expand Down
21 changes: 21 additions & 0 deletions taskcluster/ci/test/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,24 @@ jobs:
- ['automation/taskcluster/androidTest/ui-test.sh', 'samples-glean', 'arm', '1']
treeherder:
symbol: 'ui-samples-glean'
android-feature-pwa:
description: 'Run unit tests on device for feature pwa'
run:
post-gradlew:
- ['automation/taskcluster/androidTest/ui-test.sh', 'feature-pwa', 'arm', '1']
treeherder:
symbol: 'unit-feature-pwa'
android-feature-sitepermissions:
description: 'Run unit tests on device for feature site permissions'
run:
post-gradlew:
- ['automation/taskcluster/androidTest/ui-test.sh', 'feature-sitepermissions', 'arm', '1']
treeherder:
symbol: 'unit-sitepermissions'
android-feature-top-sites:
description: 'Run unit tests on device for feature top sites'
run:
post-gradlew:
- ['automation/taskcluster/androidTest/ui-test.sh', 'feature-top-sites', 'arm', '1']
treeherder:
symbol: 'unit-feature-top-sites'

0 comments on commit 8998e8c

Please sign in to comment.