Backed out changeset 9cda62240050 (bug 1788720) for causing linting failures. CLOSED TREE

This commit is contained in:
Marian-Vasile Laza 2022-10-27 01:49:08 +03:00
Родитель bd826e4068
Коммит a0fe811cf3
6 изменённых файлов: 16 добавлений и 116 удалений

Просмотреть файл

@ -20,18 +20,22 @@ import org.mozilla.geckoview.test.TrackingPermissionService.TrackingPermissionIn
import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import android.location.Criteria
import android.location.Location
import android.location.LocationManager
import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import android.os.SystemClock
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.filters.MediumTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.hamcrest.Matchers.*
import org.json.JSONArray
import org.junit.Assert.fail
import org.junit.Assume.assumeThat
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Ignore
import org.mozilla.geckoview.GeckoSessionSettings
@RunWith(AndroidJUnit4::class)
@ -575,7 +579,7 @@ class PermissionDelegateTest : BaseSessionTest() {
assertThat("Permission should be granted",
result as String, equalTo("granted"))
val perms = sessionRule.waitForResult(storageController.getPermissions(url, false))
val perms = sessionRule.waitForResult(storageController.getPermissions(url))
assertThat("Permissions should not be null", perms, notNullValue())
var permFound = false
@ -631,7 +635,7 @@ class PermissionDelegateTest : BaseSessionTest() {
assertThat("Permission should be granted",
result2 as String, equalTo("granted"))
val perms2 = sessionRule.waitForResult(storageController.getPermissions(url, true))
val perms2 = sessionRule.waitForResult(storageController.getPermissions(url))
assertThat("Permissions should not be null", perms, notNullValue())
permFound = false

Просмотреть файл

@ -78,12 +78,6 @@ class WebNotificationTest : BaseSessionTest() {
assertThat("Source should match", notification.source, equalTo(createTestUrl(HELLO_HTML_PATH)))
}
@GeckoSessionTestRule.Setting.List(
GeckoSessionTestRule.Setting(
key = GeckoSessionTestRule.Setting.Key.USE_PRIVATE_MODE,
value = "true"
)
)
@Test fun onShowNotification() {
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.vibrate.enabled" to true))
val notificationResult = GeckoResult<Void>()
@ -94,7 +88,6 @@ class WebNotificationTest : BaseSessionTest() {
@GeckoSessionTestRule.AssertCalled
override fun onShowNotification(notification: WebNotification) {
assertNotificationData(notification, requireInteraction)
assertThat("privateBrowsing should match", notification.privateBrowsing, equalTo(true))
notificationResult.complete(null)
}
})
@ -159,7 +152,6 @@ class WebNotificationTest : BaseSessionTest() {
val notification = sessionRule.waitForResult(notificationResult)
assertNotificationData(notification, requireInteraction)
assertThat("privateBrowsing should match", notification.privateBrowsing, equalTo(true))
// Test that we can click from a deserialized notification
val parcel = Parcel.obtain()
@ -168,61 +160,6 @@ class WebNotificationTest : BaseSessionTest() {
val deserialized = WebNotification.CREATOR.createFromParcel(parcel)
assertNotificationData(deserialized, requireInteraction)
assertThat("privateBrowsing should match", deserialized.privateBrowsing, equalTo(false))
deserialized!!.click()
assertThat("Promise should have been resolved.", promiseResult.value as Double, equalTo(1.0))
}
@GeckoSessionTestRule.Setting.List(
GeckoSessionTestRule.Setting(
key = GeckoSessionTestRule.Setting.Key.USE_PRIVATE_MODE,
value = "true"
)
)
@Test fun clickPrivateNotificationParceled() {
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.vibrate.enabled" to true))
val notificationResult = GeckoResult<WebNotification>()
val requireInteraction =
sessionRule.getPrefs("dom.webnotifications.requireinteraction.enabled")[0] as Boolean
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
@GeckoSessionTestRule.AssertCalled
override fun onShowNotification(notification: WebNotification) {
notificationResult.complete(notification)
}
})
val promiseResult = mainSession.evaluatePromiseJS("""
new Promise(resolve => {
const notification = new Notification('The Title', {
body: 'The Text',
cookie: 'Cookie',
icon: 'icon.png',
tag: 'Tag',
dir: 'ltr',
lang: 'en-US',
requireInteraction: true,
vibrate: [1,2,3,4]
});
notification.onclick = function() {
resolve(1);
}
});
""".trimIndent())
val notification = sessionRule.waitForResult(notificationResult)
assertNotificationData(notification, requireInteraction)
assertThat("privateBrowsing should match", notification.privateBrowsing, equalTo(true))
// Test that we can click from a deserialized notification
val parcel = Parcel.obtain()
notification.writeToParcel(parcel, 0)
parcel.setDataPosition(0);
val deserialized = WebNotification.CREATOR.createFromParcel(parcel)
assertNotificationData(deserialized, requireInteraction)
assertThat("privateBrowsing should match", deserialized.privateBrowsing, equalTo(true))
deserialized!!.click()
assertThat("Promise should have been resolved.", promiseResult.value as Double, equalTo(1.0))

Просмотреть файл

@ -204,9 +204,7 @@ public final class StorageController {
}
/**
* Get all currently stored permissions for a given URI and default (unset) context ID, in normal
* mode This API will be deprecated in the future
* https://bugzilla.mozilla.org/show_bug.cgi?id=1797379
* Get all currently stored permissions for a given URI and default (unset) context ID.
*
* @param uri A String representing the URI to get permissions for.
* @return A {@link GeckoResult} that will complete with a list of all currently stored {@link
@ -214,22 +212,7 @@ public final class StorageController {
*/
@AnyThread
public @NonNull GeckoResult<List<ContentPermission>> getPermissions(final @NonNull String uri) {
return getPermissions(uri, null, false);
}
/**
* Get all currently stored permissions for a given URI and default (unset) context ID.
*
* @param uri A String representing the URI to get permissions for.
* @param privateMode indicate where the {@link ContentPermission}s should be in private or normal
* mode.
* @return A {@link GeckoResult} that will complete with a list of all currently stored {@link
* ContentPermission}s for the URI.
*/
@AnyThread
public @NonNull GeckoResult<List<ContentPermission>> getPermissions(
final @NonNull String uri, boolean privateMode) {
return getPermissions(uri, null, privateMode);
return getPermissions(uri, null);
}
/**
@ -242,12 +225,10 @@ public final class StorageController {
*/
@AnyThread
public @NonNull GeckoResult<List<ContentPermission>> getPermissions(
final @NonNull String uri, final @Nullable String contextId, boolean privateMode) {
final @NonNull String uri, final @Nullable String contextId) {
final GeckoBundle msg = new GeckoBundle(2);
final int privateBrowsingId = (privateMode) ? 1 : 0;
msg.putString("uri", uri);
msg.putString("contextId", createSafeSessionContextId(contextId));
msg.putInt("privateBrowsingId", privateBrowsingId);
return EventDispatcher.getInstance()
.queryBundle("GeckoView:GetPermissionsByURI", msg)
.map(

Просмотреть файл

@ -103,9 +103,6 @@ public class WebNotification implements Parcelable {
*/
public final boolean silent;
/** indicates whether the notification came from private browsing mode or not. */
public final boolean privateBrowsing;
/**
* A vibration pattern to run with the display of the notification. A vibration pattern can be an
* array with as few as one member. The values are times in milliseconds where the even indices
@ -129,7 +126,6 @@ public class WebNotification implements Parcelable {
@NonNull final boolean requireInteraction,
@NonNull final String source,
final boolean silent,
final boolean privateBrowsing,
@NonNull final int[] vibrate) {
this.tag = tag;
this.mCookie = cookie;
@ -142,7 +138,6 @@ public class WebNotification implements Parcelable {
this.source = "".equals(source) ? null : source;
this.silent = silent;
this.vibrate = vibrate;
this.privateBrowsing = privateBrowsing;
}
/**
@ -194,7 +189,6 @@ public class WebNotification implements Parcelable {
dest.writeInt(requireInteraction ? 1 : 0);
dest.writeString(source);
dest.writeInt(silent ? 1 : 0);
dest.writeInt(privateBrowsing ? 1 : 0);
dest.writeIntArray(vibrate);
}
@ -209,7 +203,6 @@ public class WebNotification implements Parcelable {
requireInteraction = in.readInt() == 1;
source = in.readString();
silent = in.readInt() == 1;
privateBrowsing = in.readInt() == 1;
vibrate = in.createIntArray();
}

Просмотреть файл

@ -133,12 +133,7 @@ const GeckoViewStorageController = {
const uri = Services.io.newURI(aData.uri);
const principal = Services.scriptSecurityManager.createContentPrincipal(
uri,
aData.contextId
? {
geckoViewSessionContextId: aData.contextId,
privateBrowsingId: aData.privateBrowsingId,
}
: { privateBrowsingId: aData.privateBrowsingId }
aData.contextId ? { geckoViewSessionContextId: aData.contextId } : {}
);
const rawPerms = Services.perms.getAllForPrincipal(principal);
const permissions = rawPerms.map(p => {
@ -167,23 +162,17 @@ const GeckoViewStorageController = {
aData.newValue
);
} else {
const expirePolicy = aData.privateMode
? Ci.nsIPermissionManager.EXPIRE_SESSION
: Ci.nsIPermissionManager.EXPIRE_NEVER;
Services.perms.addFromPrincipal(
principal,
key,
aData.newValue,
expirePolicy
Ci.nsIPermissionManager.EXPIRE_NEVER
);
}
break;
}
case "GeckoView:SetPermissionByURI": {
const uri = Services.io.newURI(aData.uri);
const expirePolicy = aData.privateId
? Ci.nsIPermissionManager.EXPIRE_SESSION
: Ci.nsIPermissionManager.EXPIRE_NEVER;
const principal = Services.scriptSecurityManager.createContentPrincipal(
uri,
{
@ -195,7 +184,7 @@ const GeckoViewStorageController = {
principal,
aData.perm,
aData.newValue,
expirePolicy
Ci.nsIPermissionManager.EXPIRE_NEVER
);
break;
}

Просмотреть файл

@ -91,10 +91,6 @@ AndroidAlerts::ShowPersistentNotification(const nsAString& aPersistentData,
rv = aAlert->GetSilent(&silent);
NS_ENSURE_SUCCESS(rv, NS_OK);
bool privateBrowsing;
rv = aAlert->GetInPrivateBrowsing(&privateBrowsing);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsTArray<uint32_t> vibrate;
rv = aAlert->GetVibrate(vibrate);
NS_ENSURE_SUCCESS(rv, NS_OK);
@ -109,7 +105,7 @@ AndroidAlerts::ShowPersistentNotification(const nsAString& aPersistentData,
java::WebNotification::LocalRef notification = notification->New(
title, name, cookie, text, imageUrl, dir, lang, requireInteraction, spec,
silent, privateBrowsing, jni::IntArray::From(vibrate));
silent, jni::IntArray::From(vibrate));
java::GeckoRuntime::LocalRef runtime = java::GeckoRuntime::GetInstance();
if (runtime != NULL) {
runtime->NotifyOnShow(notification);