Commit 0f3282fa authored by MozLando's avatar MozLando
Browse files

Merge #6636

6636: A-S 0.58.1 update; Support for v34 (history) and v23 (bookmarks) fennec db migrations. r=pocmo a=grigoryk

Requires the just-published A-S 0.55.1 dot release. https://github.com/mozilla/application-services/releases/tag/v0.55.1

Co-authored-by: default avatarGrisha Kruglov <gkruglov@mozilla.com>
parents 281a63fd 339b21d6
......@@ -27,7 +27,7 @@ object Versions {
const val disklrucache = "2.0.2"
const val leakcanary = "1.6.3"
const val mozilla_appservices = "0.57.0"
const val mozilla_appservices = "0.58.1"
const val mozilla_glean = "28.0.0"
......
......@@ -169,15 +169,106 @@ class PlacesBookmarksStorageTest {
}
@Test
fun `bookmarks import v38 populated`() {
// Fennec v38 schema populated with data.
fun `bookmarks import v34 populated`() = runBlocking {
val path = getTestPath("databases/history-v34.db").absolutePath
// Need to import history first before we import bookmarks.
PlacesHistoryStorage(testContext).importFromFennec(path)
bookmarks.importFromFennec(path)
with(bookmarks.getTree(BookmarkRoot.Root.id)!!) {
assertEquals(4, this.children!!.size)
val children = this.children!!.map { it.guid }
assertTrue(BookmarkRoot.Mobile.id in children)
assertTrue(BookmarkRoot.Unfiled.id in children)
assertTrue(BookmarkRoot.Toolbar.id in children)
assertTrue(BookmarkRoot.Menu.id in children)
}
with(bookmarks.getTree(BookmarkRoot.Mobile.id)!!) {
assertEquals(3, this.children!!.size)
with(this.children!![0]) {
assertEquals("Firefox: About your browser", this.title)
assertEquals("about:firefox", this.url)
assertEquals("t4ov0nhBpPAY", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![1]) {
assertEquals("Firefox: Customize with add-ons", this.title)
assertEquals("https://addons.mozilla.org/android?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("dhoCQAToruIT", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![2]) {
assertEquals("Firefox: Support", this.title)
assertEquals("https://support.mozilla.org/products/mobile?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("gIqii_3QBZWG", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
}
}
@Test
fun `bookmarks import v38 populated`() = runBlocking {
val path = getTestPath("databases/populated-v38.db").absolutePath
try {
bookmarks.importFromFennec(path)
fail("Expected v38 database to be unsupported")
} catch (e: PlacesException) {
// This is a little brittle, but the places library doesn't have a proper error type for this.
assertEquals("Database version 38 is not supported", e.message)
// Need to import history first before we import bookmarks.
PlacesHistoryStorage(testContext).importFromFennec(path)
bookmarks.importFromFennec(path)
with(bookmarks.getTree(BookmarkRoot.Root.id)!!) {
assertEquals(4, this.children!!.size)
val children = this.children!!.map { it.guid }
assertTrue(BookmarkRoot.Mobile.id in children)
assertTrue(BookmarkRoot.Unfiled.id in children)
assertTrue(BookmarkRoot.Toolbar.id in children)
assertTrue(BookmarkRoot.Menu.id in children)
}
with(bookmarks.getTree(BookmarkRoot.Mobile.id)!!) {
assertEquals(7, this.children!!.size)
with(this.children!![0]) {
assertEquals("Firefox: About your browser", this.title)
assertEquals("about:firefox", this.url)
assertEquals("9MVmaUmIEKST", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![1]) {
assertEquals("Firefox: Customize with add-ons", this.title)
assertEquals("https://addons.mozilla.org/android?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("-wR8auFiXifM", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![2]) {
assertEquals("Firefox: Support", this.title)
assertEquals("https://support.mozilla.org/products/mobile?utm_source=inproduct&utm_medium=default-bookmarks&utm_campaign=mobileandroid", this.url)
assertEquals("UUJ5Ru2TouvB", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![3]) {
assertEquals("Problem loading page", this.title)
assertEquals("file:///", this.url)
assertEquals("YWIdMNLBXzUa", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![4]) {
assertEquals("Kotaku - The Gamer's Guide", this.title)
assertEquals("http://kotaku.com/", this.url)
assertEquals("_nrbwE-uDI4w", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![5]) {
assertEquals("News, sport and opinion from the Guardian's US edition | The Guardian", this.title)
assertEquals("https://www.theguardian.com/us", this.url)
assertEquals("9pdaS9QzEwYy", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
with(this.children!![6]) {
assertEquals("Rollins Pass - Wikipedia", this.title)
assertEquals("https://en.m.wikipedia.org/wiki/Rollins_Pass#/random", this.url)
assertEquals("mEFfANXkYH6T", this.guid)
assertEquals(BookmarkNodeType.ITEM, this.type)
}
}
}
......
......@@ -709,15 +709,41 @@ class PlacesHistoryStorageTest {
}
@Test
fun `history import v38 populated`() {
fun `history import v23 populated`() {
// Fennec v38 schema populated with data.
val path = getTestPath("databases/populated-v38.db").absolutePath
val path = getTestPath("databases/bookmarks-v23.db").absolutePath
try {
history.importFromFennec(path)
fail("Expected v38 database to be unsupported")
fail("Expected v23 database to be unsupported")
} catch (e: PlacesException) {
// This is a little brittle, but the places library doesn't have a proper error type for this.
assertEquals("Database version 38 is not supported", e.message)
assertEquals("Database version 23 is not supported", e.message)
}
}
@Test
fun `history import v38 populated`() = runBlocking {
val path = getTestPath("databases/populated-v38.db").absolutePath
var visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(0, visits.size)
history.importFromFennec(path)
visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(152, visits.size)
assertEquals(listOf(false, false, true, true, false), history.reader.getVisited(listOf(
"files:///",
"https://news.ycombinator.com/",
"https://www.theguardian.com/film/2017/jul/24/stranger-things-thor-ragnarok-comic-con-2017",
"http://www.bbc.com/news/world-us-canada-40662772",
"https://mobile.reuters.com/"
)))
with(visits[0]) {
assertEquals("Apple", this.title)
assertEquals("http://www.apple.com/", this.url)
assertEquals(1472685165382, this.visitTime)
assertEquals(VisitType.REDIRECT_PERMANENT, this.visitType)
}
}
......@@ -778,6 +804,62 @@ class PlacesHistoryStorageTest {
assertEquals(VisitType.LINK, this.visitType)
}
}
@Test
fun `history import v34 populated`() = runBlocking {
val path = getTestPath("databases/history-v34.db").absolutePath
var visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(0, visits.size)
history.importFromFennec(path)
visits = history.getDetailedVisits(0, Long.MAX_VALUE)
assertEquals(6, visits.size)
assertEquals(listOf(true, true, true, true, true), history.reader.getVisited(listOf(
"https://www.newegg.com/",
"https://news.ycombinator.com/",
"https://terrytao.wordpress.com/2020/04/12/john-conway/",
"https://news.ycombinator.com/item?id=22862053",
"https://malleable.systems/"
)))
with(visits[0]) {
assertEquals("Computer Parts, PC Components, Laptop Computers, LED LCD TV, Digital Cameras and more - Newegg.com", this.title)
assertEquals("https://www.newegg.com/", this.url)
assertEquals(1586838104188, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[1]) {
assertEquals("Hacker News", this.title)
assertEquals("https://news.ycombinator.com/", this.url)
assertEquals(1586838109506, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[2]) {
assertEquals("https://terrytao.wordpress.com/2020/04/12/john-conway/", this.title)
assertEquals("https://terrytao.wordpress.com/2020/04/12/john-conway/", this.url)
assertEquals(1586838113212, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[3]) {
assertEquals("John Conway | Hacker News", this.title)
assertEquals("https://news.ycombinator.com/item?id=22862053", this.url)
assertEquals(1586838123314, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[4]) {
assertEquals("John Conway | Hacker News", this.title)
assertEquals("https://news.ycombinator.com/item?id=22862053", this.url)
assertEquals(1586838126671, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
with(visits[5]) {
assertEquals("https://malleable.systems/", this.title)
assertEquals("https://malleable.systems/", this.url)
assertEquals(1586838164613, this.visitTime)
assertEquals(VisitType.LINK, this.visitType)
}
}
}
fun getTestPath(path: String): File {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment