diff --git a/automation/taskcluster/androidTest/ui-test.sh b/automation/taskcluster/androidTest/ui-test.sh index fa2b85bb8a4..1969d7ade24 100755 --- a/automation/taskcluster/androidTest/ui-test.sh +++ b/automation/taskcluster/androidTest/ui-test.sh @@ -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) diff --git a/components/browser/icons/src/main/java/mozilla/components/browser/icons/extension/IconMessage.kt b/components/browser/icons/src/main/java/mozilla/components/browser/icons/extension/IconMessage.kt index ac7d8d2452c..7571ad60c0a 100644 --- a/components/browser/icons/src/main/java/mozilla/components/browser/icons/extension/IconMessage.kt +++ b/components/browser/icons/src/main/java/mozilla/components/browser/icons/extension/IconMessage.kt @@ -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, diff --git a/components/browser/icons/src/test/java/mozilla/components/browser/icons/extension/IconMessageKtTest.kt b/components/browser/icons/src/test/java/mozilla/components/browser/icons/extension/IconMessageKtTest.kt index df134df789b..1de33b5a727 100644 --- a/components/browser/icons/src/test/java/mozilla/components/browser/icons/extension/IconMessageKtTest.kt +++ b/components/browser/icons/src/test/java/mozilla/components/browser/icons/extension/IconMessageKtTest.kt @@ -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) + } } diff --git a/components/feature/top-sites/src/androidTest/java/mozilla/components/feature/top/sites/TopSiteStorageTest.kt b/components/feature/top-sites/src/androidTest/java/mozilla/components/feature/top/sites/TopSiteStorageTest.kt index 9611683051e..ddc2002aa80 100644 --- a/components/feature/top-sites/src/androidTest/java/mozilla/components/feature/top/sites/TopSiteStorageTest.kt +++ b/components/feature/top-sites/src/androidTest/java/mozilla/components/feature/top/sites/TopSiteStorageTest.kt @@ -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)" @@ -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"))) } } diff --git a/components/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/db/TopSiteDatabase.kt b/components/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/db/TopSiteDatabase.kt index 5288ef60033..ca5463dbe91 100644 --- a/components/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/db/TopSiteDatabase.kt +++ b/components/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/db/TopSiteDatabase.kt @@ -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/', " + diff --git a/docs/changelog.md b/docs/changelog.md index 85b26904df4..a2da53f1279 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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) diff --git a/taskcluster/ci/test/kind.yml b/taskcluster/ci/test/kind.yml index 3dedc358a0a..932ffac22ce 100644 --- a/taskcluster/ci/test/kind.yml +++ b/taskcluster/ci/test/kind.yml @@ -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' \ No newline at end of file