Unverified Commit 6b483d8b authored by Arturo Mejia's avatar Arturo Mejia Committed by GitHub
Browse files

Merge branch 'master' into 6331

parents f505bc33 a30e917d
componentsVersion: 39.0.0
componentsVersion: 40.0.0
projects:
concept-awesomebar:
path: components/concept/awesomebar
......@@ -224,6 +224,10 @@ projects:
path: components/ui/colors
description: 'The standard set of Photon colors.'
publish: true
ui-widgets:
path: components/ui/widgets
description: 'The standard set of Mozilla widgets.'
publish: true
ui-fonts:
path: components/ui/fonts
description: 'Convenience accessor for fonts used by Mozilla.'
......
......@@ -13,6 +13,6 @@ class Config(val componentsVersion: String) {
// Synchronized build configuration for all modules
const val compileSdkVersion = 29
const val minSdkVersion = 21
const val targetSdkVersion = 28
const val targetSdkVersion = 29
}
}
......@@ -27,9 +27,9 @@ 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 = "27.1.0"
const val mozilla_glean = "28.0.0"
const val material = "1.1.0"
const val nearby = "17.0.0"
......
......@@ -61,12 +61,12 @@
<!-- The document title and heading of the error page shown when a website takes too long to load. -->
<string name="mozac_browser_errorpages_net_timeout_title">연결 시간 초과</string>
<!-- The error message shown when a website took long to load. -->
<string name="mozac_browser_errorpages_net_timeout_message"><![CDATA[<p>요청하신 사이트가 연결 요청에 응하지 않아 브라우저가 회신 대기를 중단했습니다.</p>
<string name="mozac_browser_errorpages_net_timeout_message"><![CDATA[<p>요청하신 사이트가 연결 요청에 응하지 않아 브라우저가 응답 대기를 중단했습니다.</p>
<ul>
<li>서버 폭주일까요, 일시적으로 닫힌 것일까요? 나중에 다시 시도해보십시오.</li>
<li>다른 사이트도 열리지 않습니까? 컴퓨터의 네트워크 연결을 점검해보십시오.</li>
<li>컴퓨터 또는 네트워크가 방화벽 또는 프록시에 의해 보호되고 있습니까? 부정확한 설정은 웹 탐색에 지장을 줄 수 있습니다.</li>
<li>여전히 문제가 있습니까? 네트워크 관리자 또는 인터넷 서비스 제공자에게 지원을 요청하십시오.</li>
<li>서버의 사용량이 많거나, 일시적 가동 중지일 수 있습니다. 나중에 다시 시도해 보십시오.</li>
<li>다른 사이트도 열리지 않습니까? 컴퓨터의 네트워크 연결을 점검해 보십시오.</li>
<li>사용자의 컴퓨터 또는 네트워크가 방화벽 또는 프록시에 의해 보호되고 있습니까? 설정이 잘못되면 웹 탐색에 방해가 될 수 있습니다.</li>
<li>여전히 문제가 있습니까? 네트워크 관리자 또는 인터넷 서비스 제공자에게 지원을 요청하세요.</li>
</ul>]]></string>
<!-- The document title and heading of the error page shown when a website could not be reached. -->
......
......@@ -174,7 +174,12 @@ class Session(
/**
* User entered a URL or search term
*/
USER_ENTERED
USER_ENTERED,
/**
* This session was restored
*/
RESTORED
}
/**
......
......@@ -82,11 +82,14 @@ class SnapshotSerializer(
fun itemFromJSON(engine: Engine, json: JSONObject): SessionManager.Snapshot.Item {
val sessionJson = json.getJSONObject(Keys.SESSION_KEY)
val engineSessionJson = json.getJSONObject(Keys.ENGINE_SESSION_KEY)
val session = deserializeSession(sessionJson, restoreSessionIds, restoreParentIds)
val readerState = ReaderState(active = sessionJson.optBoolean(Keys.SESSION_READER_MODE_KEY, false))
val engineState = engine.createSessionState(sessionJson)
val readerState =
ReaderState(active = sessionJson.optBoolean(Keys.SESSION_READER_MODE_KEY, false))
val engineState = engine.createSessionState(engineSessionJson)
return SessionManager.Snapshot.Item(session,
return SessionManager.Snapshot.Item(
session,
engineSession = null,
engineSessionState = engineState,
readerState = readerState
......@@ -99,7 +102,6 @@ class SnapshotSerializer(
internal fun serializeSession(session: Session): JSONObject {
return JSONObject().apply {
put(Keys.SESSION_URL_KEY, session.url)
put(Keys.SESSION_SOURCE_KEY, session.source.name)
put(Keys.SESSION_UUID_KEY, session.id)
put(Keys.SESSION_PARENT_UUID_KEY, session.parentId ?: "")
put(Keys.SESSION_TITLE, session.title)
......@@ -109,17 +111,16 @@ internal fun serializeSession(session: Session): JSONObject {
@Throws(JSONException::class)
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun deserializeSession(json: JSONObject, restoreId: Boolean, restoreParentId: Boolean): Session {
val source = try {
Session.Source.valueOf(json.getString(Keys.SESSION_SOURCE_KEY))
} catch (e: IllegalArgumentException) {
Session.Source.NONE
}
internal fun deserializeSession(
json: JSONObject,
restoreId: Boolean,
restoreParentId: Boolean
): Session {
val session = Session(
json.getString(Keys.SESSION_URL_KEY),
// Currently, snapshot cannot contain private sessions.
false,
source,
Session.Source.RESTORED,
if (restoreId) {
json.getString(Keys.SESSION_UUID_KEY)
} else {
......@@ -138,7 +139,6 @@ private object Keys {
const val SELECTED_SESSION_INDEX_KEY = "selectedSessionIndex"
const val SESSION_STATE_TUPLES_KEY = "sessionStateTuples"
const val SESSION_SOURCE_KEY = "source"
const val SESSION_URL_KEY = "url"
const val SESSION_UUID_KEY = "uuid"
const val SESSION_CONTEXT_ID_KEY = "contextId"
......
......@@ -452,14 +452,20 @@ class SessionStorageTest {
json.put("url", "testUrl")
json.put("source", Source.NEW_TAB.name)
json.put("parentUuid", "")
assertEquals(Source.NEW_TAB, deserializeSession(json, restoreId = true, restoreParentId = true).source)
assertEquals(
Source.RESTORED,
deserializeSession(json, restoreId = true, restoreParentId = true).source
)
val jsonInvalid = JSONObject()
jsonInvalid.put("uuid", "testId")
jsonInvalid.put("url", "testUrl")
jsonInvalid.put("source", "invalidSource")
jsonInvalid.put("parentUuid", "")
assertEquals(Source.NONE, deserializeSession(jsonInvalid, restoreId = true, restoreParentId = true).source)
assertEquals(
Source.RESTORED,
deserializeSession(jsonInvalid, restoreId = true, restoreParentId = true).source
)
}
@Suppress("UNCHECKED_CAST")
......
......@@ -9,6 +9,8 @@ import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager.Snapshot
import mozilla.components.browser.state.state.ReaderState
import mozilla.components.concept.engine.Engine
import mozilla.components.concept.engine.EngineSession
import mozilla.components.concept.engine.EngineSessionState
import mozilla.components.support.test.any
import mozilla.components.support.test.mock
import mozilla.components.support.test.whenever
......@@ -16,6 +18,7 @@ import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
......@@ -29,7 +32,8 @@ class SnapshotSerializerTest {
"https://www.mozilla.org",
source = Session.Source.ACTION_VIEW,
id = "test-id",
contextId = "test-context-id").apply {
contextId = "test-context-id"
).apply {
title = "Hello World"
}
......@@ -37,12 +41,50 @@ class SnapshotSerializerTest {
val restoredSession = deserializeSession(json, restoreId = true, restoreParentId = false)
assertEquals("https://www.mozilla.org", restoredSession.url)
assertEquals(Session.Source.ACTION_VIEW, restoredSession.source)
assertEquals(Session.Source.RESTORED, restoredSession.source)
assertEquals("test-id", restoredSession.id)
assertEquals("test-context-id", restoredSession.contextId)
assertEquals("Hello World", restoredSession.title)
}
@Test
fun `Serialize and deserialize with engine session state`() {
val engineSessionState: EngineSessionState = mock()
val engineSessionJson = JSONObject().apply { put("state", "test") }
val engineSession: EngineSession = mock()
whenever(engineSession.saveState()).thenReturn(engineSessionState)
whenever(engineSessionState.toJSON()).thenReturn(engineSessionJson)
val engine: Engine = mock()
val restoredEngineSessionState: EngineSessionState = mock()
whenever(engine.createSessionState(engineSessionJson)).thenReturn(restoredEngineSessionState)
val originalSession = Session(
"https://www.mozilla.org",
source = Session.Source.ACTION_VIEW,
id = "test-id",
contextId = "test-context-id"
).apply {
title = "Hello World"
}
val serializer = SnapshotSerializer()
val json = serializer.itemToJSON(
Snapshot.Item(
originalSession,
engineSession = engineSession
)
)
val restoredItem = serializer.itemFromJSON(engine, json)
assertEquals("https://www.mozilla.org", restoredItem.session.url)
assertEquals(Session.Source.RESTORED, restoredItem.session.source)
assertEquals("test-id", restoredItem.session.id)
assertEquals("test-context-id", restoredItem.session.contextId)
assertEquals("Hello World", restoredItem.session.title)
assertSame(restoredEngineSessionState, restoredItem.engineSessionState)
}
@Test
fun `Serialize and deserialize session with reader state`() {
val engine: Engine = mock()
......@@ -51,16 +93,22 @@ class SnapshotSerializerTest {
"https://www.mozilla.org",
source = Session.Source.ACTION_VIEW,
id = "test-id",
contextId = "test-context-id").apply {
contextId = "test-context-id"
).apply {
title = "Hello World"
}
val serializer = SnapshotSerializer()
val json = serializer.itemToJSON(Snapshot.Item(originalSession, readerState = ReaderState(active = true)))
val json = serializer.itemToJSON(
Snapshot.Item(
originalSession,
readerState = ReaderState(active = true)
)
)
val restoredItem = serializer.itemFromJSON(engine, json)
assertEquals("https://www.mozilla.org", restoredItem.session.url)
assertEquals(Session.Source.ACTION_VIEW, restoredItem.session.source)
assertEquals(Session.Source.RESTORED, restoredItem.session.source)
assertEquals("test-id", restoredItem.session.id)
assertEquals("test-context-id", restoredItem.session.contextId)
assertEquals("Hello World", restoredItem.session.title)
......@@ -76,10 +124,14 @@ class SnapshotSerializerTest {
put("parentUuid", "")
}
val restoredSession = deserializeSession(json, restoreId = true, restoreParentId = false)
val restoredSession = deserializeSession(
json,
restoreId = true,
restoreParentId = false
)
assertEquals("https://www.mozilla.org", restoredSession.url)
assertEquals(Session.Source.ACTION_VIEW, restoredSession.source)
assertEquals(Session.Source.RESTORED, restoredSession.source)
assertEquals("test-id", restoredSession.id)
}
......@@ -102,7 +154,8 @@ class SnapshotSerializerTest {
val originalSession = Session(
"https://www.mozilla.org",
source = Session.Source.ACTION_VIEW,
id = "test-id").apply {
id = "test-id"
).apply {
title = "Hello World"
}
......@@ -110,12 +163,13 @@ class SnapshotSerializerTest {
val restoredSession = deserializeSession(json, restoreId = false, restoreParentId = false)
assertEquals("https://www.mozilla.org", restoredSession.url)
assertEquals(Session.Source.ACTION_VIEW, restoredSession.source)
assertEquals(Session.Source.RESTORED, restoredSession.source)
assertNotEquals("test-id", restoredSession.id)
assertTrue(restoredSession.id.isNotBlank())
assertEquals("Hello World", restoredSession.title)
val restoredSessionAgain = deserializeSession(json, restoreId = false, restoreParentId = false)
val restoredSessionAgain =
deserializeSession(json, restoreId = false, restoreParentId = false)
assertNotEquals("test-id", restoredSessionAgain.id)
assertNotEquals(restoredSession.id, restoredSessionAgain.id)
assertTrue(restoredSessionAgain.id.isNotBlank())
......@@ -124,9 +178,10 @@ class SnapshotSerializerTest {
@Test
fun `Deserialize session without restoring parent id`() {
val originalSession = Session(
"https://www.mozilla.org",
source = Session.Source.ACTION_VIEW,
id = "test-id").apply {
"https://www.mozilla.org",
source = Session.Source.ACTION_VIEW,
id = "test-id"
).apply {
parentId = "test-parent-id"
title = "Hello World"
}
......@@ -134,13 +189,14 @@ class SnapshotSerializerTest {
val json = serializeSession(originalSession)
val restoredSession = deserializeSession(json, restoreId = true, restoreParentId = true)
assertEquals("https://www.mozilla.org", restoredSession.url)
assertEquals(Session.Source.ACTION_VIEW, restoredSession.source)
assertEquals(Session.Source.RESTORED, restoredSession.source)
assertEquals("test-id", restoredSession.id)
assertEquals("test-parent-id", restoredSession.parentId)
assertTrue(restoredSession.id.isNotBlank())
assertEquals("Hello World", restoredSession.title)
val restoredSessionAgain = deserializeSession(json, restoreId = true, restoreParentId = false)
val restoredSessionAgain =
deserializeSession(json, restoreId = true, restoreParentId = false)
assertEquals("test-id", restoredSessionAgain.id)
assertNull(restoredSessionAgain.parentId)
}
......
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