зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 6 changesets (bug 1676216, bug 1710668) for turning Bug 1615203 into permafail. CLOSED TREE
Backed out changeset 4784149fa5ae (bug 1676216) Backed out changeset 42527af9a64a (bug 1676216) Backed out changeset 9f187777d447 (bug 1676216) Backed out changeset 708468680122 (bug 1676216) Backed out changeset 71a4059dfe6f (bug 1710668) Backed out changeset dbfc41e9bb76 (bug 1710668)
This commit is contained in:
Родитель
f9c7e2846d
Коммит
0292ffb142
|
@ -10,26 +10,11 @@ const { GeckoViewUtils } = ChromeUtils.import(
|
|||
);
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
|
||||
const { debug, warn } = GeckoViewUtils.initLogging("GeckoViewPrompter");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"gUUIDGenerator",
|
||||
"@mozilla.org/uuid-generator;1",
|
||||
"nsIUUIDGenerator"
|
||||
);
|
||||
|
||||
class GeckoViewPrompter {
|
||||
constructor(aParent) {
|
||||
this.id = gUUIDGenerator
|
||||
.generateUUID()
|
||||
.toString()
|
||||
.slice(1, -1); // Discard surrounding braces
|
||||
|
||||
if (aParent) {
|
||||
if (aParent instanceof Window) {
|
||||
this._domWin = aParent;
|
||||
|
@ -129,10 +114,6 @@ class GeckoViewPrompter {
|
|||
});
|
||||
}
|
||||
|
||||
dismiss() {
|
||||
this._dispatcher.dispatch("GeckoView:Prompt:Dismiss", { id: this.id });
|
||||
}
|
||||
|
||||
asyncShowPrompt(aMsg, aCallback) {
|
||||
let handled = false;
|
||||
const onResponse = response => {
|
||||
|
@ -160,7 +141,6 @@ class GeckoViewPrompter {
|
|||
return;
|
||||
}
|
||||
|
||||
aMsg.id = this.id;
|
||||
this._dispatcher.dispatch("GeckoView:Prompt", aMsg, {
|
||||
onSuccess: onResponse,
|
||||
onError: error => {
|
||||
|
|
|
@ -68,12 +68,6 @@ class LoginStorageDelegate {
|
|||
GeckoViewAutocomplete.onLoginSave(selectedLogin);
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
dismiss() {
|
||||
prompt.dismiss();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
promptToChangePassword(
|
||||
|
@ -111,12 +105,6 @@ class LoginStorageDelegate {
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
dismiss() {
|
||||
prompt.dismiss();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
promptToChangePasswordWithUsernames(aBrowser, aLogins, aNewLogin) {
|
||||
|
|
|
@ -673,7 +673,6 @@ package org.mozilla.geckoview {
|
|||
method @Deprecated @DeprecationSchedule(version=93,id="login-storage") @Nullable @UiThread public Autocomplete.LoginStorageDelegate getLoginStorageDelegate();
|
||||
method @Deprecated @DeprecationSchedule(id="get-profile-dir",version=93) @Nullable @UiThread public File getProfileDir();
|
||||
method @NonNull @UiThread public ProfilerController getProfilerController();
|
||||
method @Nullable @UiThread public GeckoRuntime.ServiceWorkerDelegate getServiceWorkerDelegate();
|
||||
method @AnyThread @NonNull public GeckoRuntimeSettings getSettings();
|
||||
method @NonNull @UiThread public StorageController getStorageController();
|
||||
method @NonNull @UiThread public WebExtensionController getWebExtensionController();
|
||||
|
@ -1117,12 +1116,12 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.AlertPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected AlertPrompt(@NonNull String, @Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected AlertPrompt(@Nullable String, @Nullable String);
|
||||
field @Nullable public final String message;
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.AuthPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected AuthPrompt(@NonNull String, @Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.AuthPrompt.AuthOptions, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected AuthPrompt(@Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.AuthPrompt.AuthOptions);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull String, @NonNull String);
|
||||
field @NonNull public final GeckoSession.PromptDelegate.AuthPrompt.AuthOptions authOptions;
|
||||
|
@ -1155,27 +1154,25 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.AutocompleteRequest<T extends Autocomplete.Option<?>> extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected AutocompleteRequest(@NonNull String, @NonNull T[], GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected AutocompleteRequest(@NonNull T[]);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull Autocomplete.Option<?>);
|
||||
field @NonNull public final T[] options;
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.BasePrompt {
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse dismiss();
|
||||
method @Nullable @UiThread public GeckoSession.PromptDelegate.PromptInstanceDelegate getDelegate();
|
||||
method @UiThread public boolean isComplete();
|
||||
method @UiThread public void setDelegate(@Nullable GeckoSession.PromptDelegate.PromptInstanceDelegate);
|
||||
method @NonNull @UiThread protected GeckoSession.PromptDelegate.PromptResponse confirm();
|
||||
field @Nullable public final String title;
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.BeforeUnloadPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected BeforeUnloadPrompt(@NonNull String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected BeforeUnloadPrompt();
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@Nullable AllowOrDeny);
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.ButtonPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected ButtonPrompt(@NonNull String, @Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected ButtonPrompt(@Nullable String, @Nullable String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(int);
|
||||
field @Nullable public final String message;
|
||||
}
|
||||
|
@ -1187,7 +1184,7 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.ChoicePrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected ChoicePrompt(@NonNull String, @Nullable String, @Nullable String, int, @NonNull GeckoSession.PromptDelegate.ChoicePrompt.Choice[], @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected ChoicePrompt(@Nullable String, @Nullable String, int, @NonNull GeckoSession.PromptDelegate.ChoicePrompt.Choice[]);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull String[]);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull GeckoSession.PromptDelegate.ChoicePrompt.Choice);
|
||||
|
@ -1216,13 +1213,13 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.ColorPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected ColorPrompt(@NonNull String, @Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected ColorPrompt(@Nullable String, @Nullable String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull String);
|
||||
field @Nullable public final String defaultValue;
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.DateTimePrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected DateTimePrompt(@NonNull String, @Nullable String, int, @Nullable String, @Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected DateTimePrompt(@Nullable String, int, @Nullable String, @Nullable String, @Nullable String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull String);
|
||||
field @Nullable public final String defaultValue;
|
||||
field @Nullable public final String maxValue;
|
||||
|
@ -1240,7 +1237,7 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.FilePrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected FilePrompt(@NonNull String, @Nullable String, int, int, @Nullable String[], @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected FilePrompt(@Nullable String, int, int, @Nullable String[]);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull Context, @NonNull Uri);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull Context, @NonNull Uri[]);
|
||||
field public final int capture;
|
||||
|
@ -1263,25 +1260,21 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.PopupPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected PopupPrompt(@NonNull String, @Nullable String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected PopupPrompt(@Nullable String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull AllowOrDeny);
|
||||
field @Nullable public final String targetUri;
|
||||
}
|
||||
|
||||
public static interface GeckoSession.PromptDelegate.PromptInstanceDelegate {
|
||||
method @UiThread default public void onPromptDismiss(@NonNull GeckoSession.PromptDelegate.BasePrompt);
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.PromptResponse {
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.RepostConfirmPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected RepostConfirmPrompt(@NonNull String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected RepostConfirmPrompt();
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@Nullable AllowOrDeny);
|
||||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.SharePrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected SharePrompt(@NonNull String, @Nullable String, @Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected SharePrompt(@Nullable String, @Nullable String, @Nullable String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(int);
|
||||
field @Nullable public final String text;
|
||||
field @Nullable public final String uri;
|
||||
|
@ -1295,7 +1288,7 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public static class GeckoSession.PromptDelegate.TextPrompt extends GeckoSession.PromptDelegate.BasePrompt {
|
||||
ctor protected TextPrompt(@NonNull String, @Nullable String, @Nullable String, @Nullable String, @NonNull GeckoSession.PromptDelegate.BasePrompt.Observer);
|
||||
ctor protected TextPrompt(@Nullable String, @Nullable String, @Nullable String);
|
||||
method @NonNull @UiThread public GeckoSession.PromptDelegate.PromptResponse confirm(@NonNull String);
|
||||
field @Nullable public final String defaultValue;
|
||||
field @Nullable public final String message;
|
||||
|
@ -2063,7 +2056,6 @@ package org.mozilla.geckoview {
|
|||
}
|
||||
|
||||
public class WebPushController {
|
||||
method @Nullable @UiThread public WebPushDelegate getDelegate();
|
||||
method @UiThread public void onPushEvent(@NonNull String);
|
||||
method @UiThread public void onPushEvent(@NonNull String, @Nullable byte[]);
|
||||
method @UiThread public void onSubscriptionChanged(@NonNull String);
|
||||
|
@ -2173,9 +2165,5 @@ package org.mozilla.geckoview {
|
|||
method @NonNull public WebResponse.Builder statusCode(int);
|
||||
}
|
||||
|
||||
protected static interface GeckoSession.PromptDelegate.BasePrompt.Observer {
|
||||
method @AnyThread default public void onPromptCompleted(@NonNull GeckoSession.PromptDelegate.BasePrompt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.mozilla.geckoview.Autocomplete.StorageDelegate
|
|||
import org.mozilla.geckoview.Autocomplete.UsedField
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
@ -46,9 +47,19 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
"signon.rememberSignons" to true,
|
||||
"signon.autofillForms.http" to true))
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val fetchHandled = GeckoResult<Void>()
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -68,12 +79,22 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
|
||||
@Test
|
||||
fun fetchCreditCards() {
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val fetchHandled = GeckoResult<Void>()
|
||||
|
||||
mainSession.loadTestPath(CC_FORM_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCreditCardFetch()
|
||||
: GeckoResult<Array<CreditCard>>? {
|
||||
|
@ -100,6 +121,14 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// d. Select and return one of the options.
|
||||
// e. Ensure the form is filled accordingly.
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val name = arrayOf("Peter Parker", "John Doe")
|
||||
val number = arrayOf("1234-1234-1234-1234", "2345-2345-2345-2345")
|
||||
val guid = arrayOf("test-guid1", "test-guid2")
|
||||
|
@ -126,7 +155,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(CC_FORM_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onCreditCardFetch()
|
||||
: GeckoResult<Array<CreditCard>>? {
|
||||
|
@ -134,7 +165,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
mainSession.delegateUntilTestEnd(object : PromptDelegate {
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCreditCardSelect(
|
||||
session: GeckoSession,
|
||||
|
@ -192,19 +223,29 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
|
||||
@Test
|
||||
fun fetchAddresses() {
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val fetchHandled = GeckoResult<Void>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAddressFetch()
|
||||
: GeckoResult<Array<Address>>? {
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
fetchHandled.complete(null)
|
||||
}, acceptDelay)
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAddressFetch()
|
||||
: GeckoResult<Array<Address>>? {
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
fetchHandled.complete(null)
|
||||
}, acceptDelay)
|
||||
|
||||
return null
|
||||
}
|
||||
})
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
mainSession.loadTestPath(ADDRESS_FORM_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
@ -222,9 +263,19 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// d. Select and return one of the options.
|
||||
// e. Ensure the form is filled accordingly.
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val selectHandled = GeckoResult<Void>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onAddressFetch()
|
||||
: GeckoResult<Array<Address>>? {
|
||||
|
@ -235,7 +286,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
override fun onAddressSave(address: Address) {}
|
||||
})
|
||||
|
||||
mainSession.delegateUntilTestEnd(object : PromptDelegate {
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAddressSelect(
|
||||
session: GeckoSession,
|
||||
|
@ -390,7 +441,17 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
"signon.autofillForms.http" to true,
|
||||
"signon.userInputRequiredToCapture.enabled" to false))
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : StorageDelegate {
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
sessionRule.addExternalDelegateDuringNextWait(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -403,7 +464,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(FORMS3_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onLoginSave(login: LoginEntry) {}
|
||||
})
|
||||
|
@ -415,7 +478,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// Submit the form.
|
||||
mainSession.evaluateJS("document.querySelector('#form1').submit()")
|
||||
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -449,12 +512,22 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
"signon.autofillForms.http" to true,
|
||||
"signon.userInputRequiredToCapture.enabled" to false))
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
mainSession.loadTestPath(FORMS3_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
val saveHandled = GeckoResult<Void>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginSave(login: LoginEntry) {
|
||||
assertThat(
|
||||
|
@ -471,7 +544,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -516,12 +589,22 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
"signon.autofillForms.http" to true,
|
||||
"signon.userInputRequiredToCapture.enabled" to false))
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
mainSession.loadTestPath(FORMS3_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
val saveHandled = GeckoResult<Void>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginSave(login: LoginEntry) {
|
||||
assertThat(
|
||||
|
@ -538,7 +621,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -591,6 +674,14 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
"signon.autofillForms.http" to true,
|
||||
"signon.userInputRequiredToCapture.enabled" to false))
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val saveHandled = GeckoResult<Void>()
|
||||
val saveHandled2 = GeckoResult<Void>()
|
||||
|
||||
|
@ -600,7 +691,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
val guid = "test-guid"
|
||||
val savedLogins = mutableListOf<LoginEntry>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -644,7 +737,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -697,6 +790,14 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
"signon.autofillForms.http" to true,
|
||||
"signon.userInputRequiredToCapture.enabled" to false))
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val usedHandled = GeckoResult<Void>()
|
||||
|
||||
val user1 = "user1x"
|
||||
|
@ -713,7 +814,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
val savedLogins = mutableListOf<LoginEntry>(savedLogin)
|
||||
|
||||
if (autofillEnabled) {
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -748,7 +851,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
} else {
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -762,7 +867,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
})
|
||||
}
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -802,6 +907,14 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
"signon.autofillForms.http" to true,
|
||||
"signon.userInputRequiredToCapture.enabled" to false))
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val user1 = "user1x"
|
||||
val pass1 = "pass1x"
|
||||
val guid = "test-guid"
|
||||
|
@ -815,7 +928,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
.build()
|
||||
val savedLogins = mutableListOf<LoginEntry>(savedLogin)
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -828,7 +943,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
override fun onLoginUsed(login: LoginEntry, usedFields: Int) {}
|
||||
})
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -902,6 +1017,14 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// e. Submit the form.
|
||||
// f. Ensure that onLoginUsed is called.
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val user1 = "user1x"
|
||||
val user2 = "user2x"
|
||||
val pass1 = "pass1x"
|
||||
|
@ -913,7 +1036,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
val selectHandled = GeckoResult<Void>()
|
||||
val usedHandled = GeckoResult<Void>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -996,7 +1121,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(FORMS3_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PromptDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -1036,7 +1161,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
session2.loadTestPath(FORMS3_HTML_PATH)
|
||||
session2.waitForPageStop()
|
||||
|
||||
session2.delegateDuringNextWait(object : PromptDelegate {
|
||||
session2.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -1074,7 +1199,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// Reload for the last time.
|
||||
val session3 = sessionRule.createOpenSession()
|
||||
|
||||
session3.delegateUntilTestEnd(object : PromptDelegate {
|
||||
session3.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSelect(
|
||||
session: GeckoSession,
|
||||
|
@ -1164,6 +1289,14 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// e. Submit the form.
|
||||
// f. Ensure that onLoginUsed is not called.
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val user1 = "user1x"
|
||||
val user2 = "user2x"
|
||||
val pass1 = "pass1x"
|
||||
|
@ -1176,7 +1309,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
val saveHandled2 = GeckoResult<Void>()
|
||||
val selectHandled = GeckoResult<Void>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -1237,7 +1372,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(FORMS3_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PromptDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -1277,7 +1412,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
session2.loadTestPath(FORMS3_HTML_PATH)
|
||||
session2.waitForPageStop()
|
||||
|
||||
session2.delegateDuringNextWait(object : PromptDelegate {
|
||||
session2.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
|
@ -1315,7 +1450,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// Reload for the last time.
|
||||
val session3 = sessionRule.createOpenSession()
|
||||
|
||||
session3.delegateUntilTestEnd(object : PromptDelegate {
|
||||
session3.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoginSelect(
|
||||
session: GeckoSession,
|
||||
|
@ -1403,6 +1538,14 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
// 4. Submit the login form.
|
||||
// a. Ensure onLoginSave is called with accordingly.
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = delegate
|
||||
}
|
||||
val unregister = { _: StorageDelegate ->
|
||||
runtime.autocompleteStorageDelegate = null
|
||||
}
|
||||
|
||||
val user1 = "user1x"
|
||||
var genPass = ""
|
||||
|
||||
|
@ -1410,7 +1553,9 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
val selectHandled = GeckoResult<Void>()
|
||||
var numSelects = 0
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : StorageDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
StorageDelegate::class, register, unregister,
|
||||
object : StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String)
|
||||
: GeckoResult<Array<LoginEntry>>? {
|
||||
|
@ -1441,7 +1586,7 @@ class AutocompleteTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(FORMS4_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateUntilTestEnd(object : PromptDelegate {
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginSelect(
|
||||
session: GeckoSession,
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.mozilla.geckoview.GeckoSession
|
|||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
@ -36,7 +37,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.loadTestPath(FORMS_HTML_PATH)
|
||||
// Wait for the auto-fill nodes to populate.
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
// For the root document and the iframe document, each has a form group and
|
||||
// a group for inputs outside of forms, so the total count is 4.
|
||||
@AssertCalled(count = 4)
|
||||
|
@ -60,7 +61,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
// Submit the session.
|
||||
mainSession.evaluateJS("document.querySelector('#form1').submit()")
|
||||
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 5)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -100,7 +101,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.loadTestPath(FORMS_ID_VALUE_HTML_PATH)
|
||||
// Wait for the auto-fill nodes to populate.
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -119,7 +120,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
// Submit the session.
|
||||
mainSession.evaluateJS("document.querySelector('#form1').submit()")
|
||||
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -148,7 +149,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
// SessionAccessibility for a11y auto-fill support.
|
||||
mainSession.loadTestPath(FORMS_HTML_PATH)
|
||||
// Wait for the auto-fill nodes to populate.
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
// For the root document and the iframe document, each has a form group and
|
||||
// a group for inputs outside of forms, so the total count is 4.
|
||||
@AssertCalled(count = 4)
|
||||
|
@ -250,7 +251,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
@Test fun autofillNavigation() {
|
||||
// Wait for the accessibility nodes to populate.
|
||||
mainSession.loadTestPath(FORMS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 4)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -269,7 +270,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
|
||||
// Now wait for the nodes to clear.
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -286,7 +287,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
// Now wait for the nodes to reappear.
|
||||
mainSession.waitForPageStop()
|
||||
mainSession.goBack()
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 4)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -306,7 +307,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.evaluateJS("document.querySelector('#pass2').focus()")
|
||||
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -329,7 +330,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
equalTo(8))
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('#pass2').blur()")
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -348,7 +349,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
@Test fun autofillUserpass() {
|
||||
mainSession.loadTestPath(FORMS2_HTML_PATH)
|
||||
// Wait for the auto-fill nodes to populate.
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 3)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -391,7 +392,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
// inactive. Likewise, we should focus a node once we return.
|
||||
mainSession.loadTestPath(FORMS_HTML_PATH)
|
||||
// Wait for the auto-fill nodes to populate.
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
// For the root document and the iframe document, each has a form group and
|
||||
// a group for inputs outside of forms, so the total count is 4.
|
||||
@AssertCalled(count = 4)
|
||||
|
@ -407,7 +408,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('#pass2').focus()")
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -423,7 +424,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
|
||||
// Make sure we get NODE_BLURRED when inactive
|
||||
mainSession.setActive(false)
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -437,7 +438,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
|
||||
// Make sure we get NODE_FOCUSED when active once again
|
||||
mainSession.setActive(true)
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
@ -455,7 +456,7 @@ class AutofillDelegateTest : BaseSessionTest() {
|
|||
@WithDisplay(width = 100, height = 100)
|
||||
@Test fun autofillAutocompleteAttribute() {
|
||||
mainSession.loadTestPath(FORMS_AUTOCOMPLETE_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : Autofill.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.AutofillDelegate {
|
||||
@AssertCalled(count = 3)
|
||||
override fun onAutofill(session: GeckoSession,
|
||||
notification: Int,
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.mozilla.geckoview.test
|
|||
import androidx.test.filters.MediumTest
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.hamcrest.Matchers.*
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.ContentBlocking
|
||||
|
@ -16,6 +17,7 @@ import org.mozilla.geckoview.GeckoSession
|
|||
import org.mozilla.geckoview.GeckoSessionSettings
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import org.junit.Assume.assumeThat
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
@ -29,7 +31,7 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
|||
session1.loadTestPath(TRACKERS_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count=3)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -67,7 +69,7 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(false)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -85,7 +87,7 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
|||
session1.reload()
|
||||
|
||||
sessionRule.waitUntilCalled(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count=3)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -234,7 +236,7 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(TRACKERS_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count=3)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -261,7 +263,7 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(false)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -278,7 +280,7 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
|||
sessionRule.session.reload()
|
||||
|
||||
sessionRule.waitUntilCalled(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count=3)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -339,7 +341,7 @@ class ContentBlockingControllerTest : BaseSessionTest() {
|
|||
sessionRule.session.settings.useTrackingProtection = true
|
||||
sessionRule.session.loadTestPath(TRACKERS_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(object : ContentBlocking.Delegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentBlockingDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.BuildConfig
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.IgnoreCrash
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
@ -37,7 +37,7 @@ class ContentCrashTest : BaseSessionTest() {
|
|||
assumeThat(sessionRule.env.isIsolatedProcess, Matchers.equalTo(false))
|
||||
|
||||
mainSession.loadUri(CONTENT_CRASH_URL)
|
||||
mainSession.waitUntilCalled(ContentDelegate::class, "onCrash")
|
||||
mainSession.waitUntilCalled(Callbacks.ContentDelegate::class, "onCrash")
|
||||
|
||||
// This test is really slow so we allow double the usual timeout
|
||||
var evalResult = client.getEvalResult(env.defaultTimeoutMillis * 2)
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
package org.mozilla.geckoview.test
|
||||
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.IgnoreCrash
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import androidx.annotation.AnyThread
|
||||
import androidx.test.filters.MediumTest
|
||||
|
@ -37,7 +37,7 @@ class ContentDelegateMultipleSessionsTest : BaseSessionTest() {
|
|||
killAllContentProcesses()
|
||||
|
||||
if (isMainSessionAlreadyOpen) {
|
||||
mainSession.waitUntilCalled(object : ContentDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onKill(session: GeckoSession) {
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class ContentDelegateMultipleSessionsTest : BaseSessionTest() {
|
|||
// ...but we use GeckoResult.allOf for waiting on the aggregated results
|
||||
val allCrashesFound = GeckoResult.allOf(mainSessionCrash, newSessionCrash)
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ContentDelegate {
|
||||
fun reportCrash(session: GeckoSession) {
|
||||
if (session == mainSession) {
|
||||
mainSessionCrash.complete(null)
|
||||
|
@ -143,7 +143,7 @@ class ContentDelegateMultipleSessionsTest : BaseSessionTest() {
|
|||
|
||||
val allKillEventsReceived = GeckoResult.allOf(mainSessionKilled, newSessionKilled)
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ContentDelegate {
|
||||
override fun onKill(session: GeckoSession) {
|
||||
if (session == mainSession) {
|
||||
mainSessionKilled.complete(null)
|
||||
|
|
|
@ -7,12 +7,10 @@ package org.mozilla.geckoview.test
|
|||
import android.graphics.SurfaceTexture
|
||||
import android.net.Uri
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate.LoadRequest
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.IgnoreCrash
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import androidx.annotation.AnyThread
|
||||
import androidx.test.filters.MediumTest
|
||||
|
@ -33,7 +31,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
@Test fun titleChange() {
|
||||
sessionRule.session.loadTestPath(TITLE_CHANGE_HTML_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onTitleChange(session: GeckoSession, title: String?) {
|
||||
assertThat("Title should match", title,
|
||||
|
@ -48,7 +46,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.loadTestPath(DOWNLOAD_HTML_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(object : NavigationDelegate, ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.NavigationDelegate, Callbacks.ContentDelegate {
|
||||
|
||||
@AssertCalled(count = 2)
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
|
@ -79,7 +77,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
mainSession.loadUri(CONTENT_CRASH_URL)
|
||||
mainSession.waitUntilCalled(object : ContentDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCrash(session: GeckoSession) {
|
||||
assertThat("Session should be closed after a crash",
|
||||
|
@ -90,7 +88,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
// Recover immediately
|
||||
mainSession.open()
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
mainSession.waitUntilCalled(object: ProgressDelegate {
|
||||
mainSession.waitUntilCalled(object: Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("Page should load successfully", success, equalTo(true))
|
||||
|
@ -104,7 +102,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
// TODO: bug 1710940
|
||||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
mainSession.delegateUntilTestEnd(object : ContentDelegate {
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.ContentDelegate {
|
||||
override fun onCrash(session: GeckoSession) {
|
||||
mainSession.open()
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
|
@ -131,7 +129,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
@IgnoreCrash
|
||||
@Test fun killContent() {
|
||||
killAllContentProcesses()
|
||||
mainSession.waitUntilCalled(object : ContentDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onKill(session: GeckoSession) {
|
||||
assertThat("Session should be closed after being killed",
|
||||
|
@ -141,7 +139,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.open()
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
mainSession.waitUntilCalled(object : ProgressDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("Page should load successfully", success, equalTo(true))
|
||||
|
@ -154,7 +152,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(FULLSCREEN_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
val promise = mainSession.evaluatePromiseJS("document.querySelector('#fullscreen').requestFullscreen()")
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFullScreen(session: GeckoSession, fullScreen: Boolean) {
|
||||
assertThat("Div went fullscreen", fullScreen, equalTo(true))
|
||||
|
@ -164,7 +162,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
private fun waitForFullscreenExit() {
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFullScreen(session: GeckoSession, fullScreen: Boolean) {
|
||||
assertThat("Div left fullscreen", fullScreen, equalTo(false))
|
||||
|
@ -192,14 +190,14 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
val surface = Surface(texture)
|
||||
display.surfaceChanged(surface, 100, 100)
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstComposite(session: GeckoSession) {
|
||||
}
|
||||
})
|
||||
display.surfaceDestroyed()
|
||||
display.surfaceChanged(surface, 100, 100)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstComposite(session: GeckoSession) {
|
||||
}
|
||||
|
@ -211,7 +209,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
@WithDisplay(width = 10, height = 10)
|
||||
@Test fun firstContentfulPaint() {
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -244,7 +242,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
|
||||
@Test fun webAppManifest() {
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
mainSession.waitUntilCalled(object : ContentDelegate, ProgressDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("Page load should succeed", success, equalTo(true))
|
||||
|
@ -275,7 +273,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
|
||||
@Test fun viewportFit() {
|
||||
mainSession.loadTestPath(VIEWPORT_PATH)
|
||||
mainSession.waitUntilCalled(object : ContentDelegate, ProgressDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("Page load should succeed", success, equalTo(true))
|
||||
|
@ -288,7 +286,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
|
||||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
mainSession.waitUntilCalled(object : ContentDelegate, ProgressDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("Page load should succeed", success, equalTo(true))
|
||||
|
@ -310,7 +308,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.evaluateJS("window.close()")
|
||||
mainSession.waitUntilCalled(object : ContentDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCloseRequest(session: GeckoSession) {
|
||||
}
|
||||
|
@ -324,7 +322,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
mainSession.waitForPageStop()
|
||||
|
||||
val newSession = sessionRule.createClosedSession()
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onNewSession(session: GeckoSession, uri: String): GeckoResult<GeckoSession>? {
|
||||
return GeckoResult.fromValue(newSession)
|
||||
|
@ -333,7 +331,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.evaluateJS("const w = window.open('about:blank'); w.close()")
|
||||
|
||||
newSession.waitUntilCalled(object : ContentDelegate, ProgressDelegate {
|
||||
newSession.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCloseRequest(session: GeckoSession) {
|
||||
}
|
||||
|
@ -360,11 +358,11 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
/**
|
||||
* With no delegate set, the default behaviour is to stop hung scripts.
|
||||
*/
|
||||
@NullDelegate(ContentDelegate::class)
|
||||
@NullDelegate(GeckoSession.ContentDelegate::class)
|
||||
@Test fun stopHungProcessDefault() {
|
||||
setHangReportTestPrefs()
|
||||
mainSession.loadTestPath(HUNG_SCRIPT)
|
||||
sessionRule.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("The script did not complete.",
|
||||
|
@ -381,7 +379,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
*/
|
||||
@Test fun stopHungProcessNull() {
|
||||
setHangReportTestPrefs()
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate, ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : GeckoSession.ContentDelegate, Callbacks.ProgressDelegate {
|
||||
// default onSlowScript returns null
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
|
@ -400,7 +398,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
@Test fun stopHungProcessDoNothing() {
|
||||
setHangReportTestPrefs()
|
||||
var scriptHungReportCount = 0
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate, ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : GeckoSession.ContentDelegate, Callbacks.ProgressDelegate {
|
||||
@AssertCalled()
|
||||
override fun onSlowScript(geckoSession: GeckoSession, scriptFileName: String): GeckoResult<SlowScriptResponse> {
|
||||
scriptHungReportCount += 1;
|
||||
|
@ -423,7 +421,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
*/
|
||||
@Test fun stopHungProcess() {
|
||||
setHangReportTestPrefs()
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate, ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : GeckoSession.ContentDelegate, Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onSlowScript(geckoSession: GeckoSession, scriptFileName: String): GeckoResult<SlowScriptResponse> {
|
||||
return GeckoResult.fromValue(SlowScriptResponse.STOP)
|
||||
|
@ -444,7 +442,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
*/
|
||||
@Test fun stopHungProcessWait() {
|
||||
setHangReportTestPrefs()
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate, ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : GeckoSession.ContentDelegate, Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onSlowScript(geckoSession: GeckoSession, scriptFileName: String): GeckoResult<SlowScriptResponse> {
|
||||
return GeckoResult.fromValue(SlowScriptResponse.CONTINUE)
|
||||
|
@ -466,7 +464,7 @@ class ContentDelegateTest : BaseSessionTest() {
|
|||
@Test fun stopHungProcessWaitThenStop() {
|
||||
setHangReportTestPrefs(500)
|
||||
var scriptWaited = false
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate, ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : GeckoSession.ContentDelegate, Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2, order = [1, 2])
|
||||
override fun onSlowScript(geckoSession: GeckoSession, scriptFileName: String): GeckoResult<SlowScriptResponse> {
|
||||
return if (!scriptWaited) {
|
||||
|
|
|
@ -11,12 +11,12 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
|||
import android.util.Base64
|
||||
import java.io.ByteArrayOutputStream
|
||||
import org.hamcrest.Matchers.*
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ScrollDelegate
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
|
||||
import org.hamcrest.Matchers.closeTo
|
||||
|
@ -326,7 +326,7 @@ class DynamicToolbarTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(SHOW_DYNAMIC_TOOLBAR_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
mainSession.evaluateJS("window.scrollTo(0, " + dynamicToolbarMaxHeight + ")")
|
||||
mainSession.waitUntilCalled(object : ScrollDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ScrollDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ class DynamicToolbarTest : BaseSessionTest() {
|
|||
|
||||
mainSession.synthesizeTap(5, 25)
|
||||
|
||||
mainSession.waitUntilCalled(object : ContentDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onShowDynamicToolbar(session: GeckoSession) {
|
||||
}
|
||||
|
|
|
@ -8,15 +8,9 @@ import android.os.Handler
|
|||
import android.os.Looper
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.SessionState
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ScrollDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.HistoryDelegate
|
||||
import org.mozilla.geckoview.GeckoSessionSettings
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.*
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import org.mozilla.geckoview.test.util.UiThreadUtils
|
||||
|
||||
import androidx.test.filters.MediumTest
|
||||
|
@ -72,22 +66,32 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
@TimeoutMillis(2000)
|
||||
fun noPendingCallbacks() {
|
||||
// Make sure we don't have unexpected pending callbacks at the start of a test.
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate, HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.All {
|
||||
// There may be extraneous onSessionStateChange and onHistoryStateChange calls
|
||||
// after a test, so ignore the first received.
|
||||
@AssertCalled(count = 2)
|
||||
override fun onSessionStateChange(session: GeckoSession, state: SessionState) {
|
||||
override fun onSessionStateChange(session: GeckoSession, state: GeckoSession.SessionState) {
|
||||
}
|
||||
|
||||
@AssertCalled(count = 2)
|
||||
override fun onHistoryStateChange(session: GeckoSession, historyList: HistoryDelegate.HistoryList) {
|
||||
override fun onHistoryStateChange(session: GeckoSession, historyList: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@NullDelegate.List(NullDelegate(ContentDelegate::class),
|
||||
NullDelegate(NavigationDelegate::class))
|
||||
@NullDelegate(ScrollDelegate::class)
|
||||
@Test fun includesAllCallbacks() {
|
||||
for (ifce in GeckoSession::class.java.classes) {
|
||||
if (!ifce.isInterface || !ifce.simpleName.endsWith("Delegate")) {
|
||||
continue
|
||||
}
|
||||
assertThat("Callbacks.All should include interface " + ifce.simpleName,
|
||||
ifce.isInstance(Callbacks.Default), equalTo(true))
|
||||
}
|
||||
}
|
||||
|
||||
@NullDelegate.List(NullDelegate(GeckoSession.ContentDelegate::class),
|
||||
NullDelegate(Callbacks.NavigationDelegate::class))
|
||||
@NullDelegate(Callbacks.ScrollDelegate::class)
|
||||
@Test fun nullDelegate() {
|
||||
assertThat("Content delegate should be null",
|
||||
sessionRule.session.contentDelegate, nullValue())
|
||||
|
@ -100,7 +104,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.progressDelegate, notNullValue())
|
||||
}
|
||||
|
||||
@NullDelegate(ProgressDelegate::class)
|
||||
@NullDelegate(GeckoSession.ProgressDelegate::class)
|
||||
@ClosedSessionAtStart
|
||||
@Test fun nullDelegate_closed() {
|
||||
assertThat("Progress delegate should be null",
|
||||
|
@ -108,7 +112,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
@Test(expected = AssertionError::class)
|
||||
@NullDelegate(ProgressDelegate::class)
|
||||
@NullDelegate(GeckoSession.ProgressDelegate::class)
|
||||
@ClosedSessionAtStart
|
||||
fun nullDelegate_requireProgressOnOpen() {
|
||||
assertThat("Progress delegate should be null",
|
||||
|
@ -123,7 +127,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
|
@ -132,6 +136,13 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
assertThat("Callback count should be correct", counter, equalTo(1))
|
||||
}
|
||||
|
||||
@Test(expected = AssertionError::class)
|
||||
fun waitForPageStop_throwOnChangedCallback() {
|
||||
sessionRule.session.progressDelegate = Callbacks.Default
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
}
|
||||
|
||||
@Test fun waitForPageStops() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.session.reload()
|
||||
|
@ -139,7 +150,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
|
@ -149,7 +160,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
@Test(expected = AssertionError::class)
|
||||
@NullDelegate(ProgressDelegate::class)
|
||||
@NullDelegate(GeckoSession.ProgressDelegate::class)
|
||||
@ClosedSessionAtStart
|
||||
fun waitForPageStops_throwOnNullDelegate() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
|
@ -164,11 +175,11 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
// TODO: Bug 1673953
|
||||
assumeThat(sessionRule.env.isFission, equalTo(false))
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(ProgressDelegate::class)
|
||||
sessionRule.waitUntilCalled(GeckoSession.ProgressDelegate::class)
|
||||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
}
|
||||
|
@ -178,7 +189,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
override fun onSecurityChange(session: GeckoSession,
|
||||
securityInfo: ProgressDelegate.SecurityInformation) {
|
||||
securityInfo: GeckoSession.ProgressDelegate.SecurityInformation) {
|
||||
counter++
|
||||
}
|
||||
|
||||
|
@ -186,7 +197,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
counter++
|
||||
}
|
||||
|
||||
override fun onSessionStateChange(session: GeckoSession, state: SessionState) {
|
||||
override fun onSessionStateChange(session: GeckoSession, state: GeckoSession.SessionState) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
@ -196,12 +207,12 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
@Test fun waitUntilCalled_specificInterfaceMethod() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(ProgressDelegate::class,
|
||||
sessionRule.waitUntilCalled(GeckoSession.ProgressDelegate::class,
|
||||
"onPageStart", "onPageStop")
|
||||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
}
|
||||
|
@ -222,16 +233,26 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
fun waitUntilCalled_notThrowOnCallbackInterface() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(ProgressDelegate::class)
|
||||
sessionRule.waitUntilCalled(Callbacks.ProgressDelegate::class)
|
||||
}
|
||||
|
||||
@NullDelegate(ScrollDelegate::class)
|
||||
@Test(expected = AssertionError::class)
|
||||
@NullDelegate(GeckoSession.ScrollDelegate::class)
|
||||
fun waitUntilCalled_throwOnNullDelegateInterface() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.session.reload()
|
||||
sessionRule.session.waitUntilCalled(Callbacks.All::class)
|
||||
}
|
||||
|
||||
@NullDelegate(GeckoSession.ScrollDelegate::class)
|
||||
@Test fun waitUntilCalled_notThrowOnNonNullDelegateMethod() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.session.reload()
|
||||
sessionRule.session.waitUntilCalled(ProgressDelegate::class, "onPageStop")
|
||||
sessionRule.session.waitUntilCalled(Callbacks.All::class, "onPageStop")
|
||||
}
|
||||
|
||||
@Test fun waitUntilCalled_anyObjectMethod() {
|
||||
|
@ -241,7 +262,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
}
|
||||
|
@ -251,7 +272,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
override fun onSecurityChange(session: GeckoSession,
|
||||
securityInfo: ProgressDelegate.SecurityInformation) {
|
||||
securityInfo: GeckoSession.ProgressDelegate.SecurityInformation) {
|
||||
counter++
|
||||
}
|
||||
|
||||
|
@ -259,7 +280,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
counter++
|
||||
}
|
||||
|
||||
override fun onSessionStateChange(session: GeckoSession, state: SessionState) {
|
||||
override fun onSessionStateChange(session: GeckoSession, state: GeckoSession.SessionState) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
@ -272,7 +293,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -288,26 +309,26 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
@Test(expected = AssertionError::class)
|
||||
@NullDelegate(ScrollDelegate::class)
|
||||
@NullDelegate(GeckoSession.ScrollDelegate::class)
|
||||
fun waitUntilCalled_throwOnNullDelegateObject() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.session.reload()
|
||||
sessionRule.session.waitUntilCalled(object : ScrollDelegate {
|
||||
sessionRule.session.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@NullDelegate(ScrollDelegate::class)
|
||||
@NullDelegate(GeckoSession.ScrollDelegate::class)
|
||||
@Test fun waitUntilCalled_notThrowOnNonNullDelegateObject() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.session.reload()
|
||||
sessionRule.session.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.session.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -320,7 +341,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -341,7 +362,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2, order = [1, 2])
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
val info = sessionRule.currentCall
|
||||
|
@ -360,7 +381,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
@Test(expected = IllegalStateException::class)
|
||||
fun waitUntilCalled_passThroughExceptions() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
throw IllegalStateException()
|
||||
|
@ -371,7 +392,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
@Test fun waitUntilCalled_zeroCount() {
|
||||
// Support having @AssertCalled(count = 0) annotations for waitUntilCalled calls.
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate, ScrollDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate, Callbacks.ScrollDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -390,7 +411,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
|
@ -404,7 +425,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ScrollDelegate {})
|
||||
sessionRule.forCallbacksDuringWait(object : GeckoSession.ScrollDelegate {})
|
||||
}
|
||||
|
||||
@Test fun forCallbacksDuringWait_specificMethod() {
|
||||
|
@ -413,7 +434,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -435,7 +456,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -455,7 +476,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ScrollDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : GeckoSession.ScrollDelegate {
|
||||
@AssertCalled
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -469,7 +490,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -490,7 +511,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.reload()
|
||||
sessionRule.waitForPageStops(2)
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
}
|
||||
|
@ -505,7 +526,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
}
|
||||
|
@ -521,7 +542,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(order = [2])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
}
|
||||
|
@ -537,7 +558,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.reload()
|
||||
sessionRule.waitForPageStops(2)
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(order = [1, 3, 1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
}
|
||||
|
@ -554,7 +575,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.reload()
|
||||
sessionRule.waitForPageStops(2)
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(order = [1, 2, 1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
}
|
||||
|
@ -569,7 +590,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ScrollDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : GeckoSession.ScrollDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -581,7 +602,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -592,7 +613,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ScrollDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : GeckoSession.ScrollDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -604,7 +625,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -626,7 +647,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
var counter = 0
|
||||
|
||||
// assert should only apply to callbacks within range (loadUri, first reload].
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -645,7 +666,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
val info = sessionRule.currentCall
|
||||
|
@ -663,7 +684,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
throw IllegalStateException()
|
||||
|
@ -672,39 +693,39 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
@Test(expected = AssertionError::class)
|
||||
@NullDelegate(ScrollDelegate::class)
|
||||
@NullDelegate(GeckoSession.ScrollDelegate::class)
|
||||
fun forCallbacksDuringWait_throwOnAnyNullDelegate() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
sessionRule.session.reload()
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.session.forCallbacksDuringWait(object : NavigationDelegate, ScrollDelegate {})
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.All {})
|
||||
}
|
||||
|
||||
@Test(expected = AssertionError::class)
|
||||
@NullDelegate(ScrollDelegate::class)
|
||||
@NullDelegate(GeckoSession.ScrollDelegate::class)
|
||||
fun forCallbacksDuringWait_throwOnSpecificNullDelegate() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
sessionRule.session.reload()
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.session.forCallbacksDuringWait(object : ScrollDelegate {
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.All {
|
||||
@AssertCalled
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@NullDelegate(ScrollDelegate::class)
|
||||
@NullDelegate(GeckoSession.ScrollDelegate::class)
|
||||
@Test fun forCallbacksDuringWait_notThrowOnNonNullDelegate() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
sessionRule.session.reload()
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.All {
|
||||
@AssertCalled
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -719,7 +740,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
@Test fun delegateUntilTestEnd() {
|
||||
var counter = 0
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -738,7 +759,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
@Test fun delegateUntilTestEnd_notCalled() {
|
||||
sessionRule.delegateUntilTestEnd(object : ScrollDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : GeckoSession.ScrollDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -747,7 +768,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
@Test(expected = AssertionError::class)
|
||||
fun delegateUntilTestEnd_throwOnNotCalled() {
|
||||
sessionRule.delegateUntilTestEnd(object : ScrollDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : GeckoSession.ScrollDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -757,7 +778,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
@Test(expected = AssertionError::class)
|
||||
fun delegateUntilTestEnd_throwOnCallingNoCall() {
|
||||
sessionRule.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -769,7 +790,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
@Test(expected = AssertionError::class)
|
||||
fun delegateUntilTestEnd_throwOnWrongOrder() {
|
||||
sessionRule.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [2])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
}
|
||||
|
@ -784,7 +805,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
@Test fun delegateUntilTestEnd_currentCall() {
|
||||
sessionRule.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
val info = sessionRule.currentCall
|
||||
|
@ -805,7 +826,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.waitForPageStop()
|
||||
var counter = 0
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : ProgressDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
counter++
|
||||
|
@ -830,7 +851,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
@Test(expected = AssertionError::class)
|
||||
fun delegateDuringNextWait_throwOnNotCalled() {
|
||||
sessionRule.delegateDuringNextWait(object : ScrollDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : GeckoSession.ScrollDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -841,7 +862,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
@Test(expected = AssertionError::class)
|
||||
fun delegateDuringNextWait_throwOnNotCalledAtTestEnd() {
|
||||
sessionRule.delegateDuringNextWait(object : ScrollDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : GeckoSession.ScrollDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onScrollChanged(session: GeckoSession, scrollX: Int, scrollY: Int) {
|
||||
}
|
||||
|
@ -853,8 +874,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
var testCounter = 0
|
||||
var waitCounter = 0
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : ProgressDelegate,
|
||||
NavigationDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ProgressDelegate,
|
||||
Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [2])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
testCounter++
|
||||
|
@ -876,7 +897,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
})
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : ProgressDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
waitCounter++
|
||||
|
@ -904,7 +925,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
@Test(expected = IllegalStateException::class)
|
||||
fun delegateDuringNextWait_passThroughExceptions() {
|
||||
sessionRule.delegateDuringNextWait(object : ProgressDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
throw IllegalStateException()
|
||||
|
@ -916,9 +937,9 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
}
|
||||
|
||||
@Test(expected = AssertionError::class)
|
||||
@NullDelegate(NavigationDelegate::class)
|
||||
@NullDelegate(GeckoSession.NavigationDelegate::class)
|
||||
fun delegateDuringNextWait_throwOnNullDelegate() {
|
||||
sessionRule.session.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.session.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
}
|
||||
})
|
||||
|
@ -959,13 +980,13 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStops(2)
|
||||
|
||||
newSession.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
newSession.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
})
|
||||
|
||||
sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -993,15 +1014,15 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
fun noPendingCallbacks_withSpecificSession() {
|
||||
sessionRule.createOpenSession()
|
||||
// Make sure we don't have unexpected pending callbacks after opening a session.
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate, ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.All {
|
||||
// There may be extraneous onSessionStateChange and onHistoryStateChange calls
|
||||
// after a test, so ignore the first received.
|
||||
@AssertCalled(count = 2)
|
||||
override fun onSessionStateChange(session: GeckoSession, state: SessionState) {
|
||||
override fun onSessionStateChange(session: GeckoSession, state: GeckoSession.SessionState) {
|
||||
}
|
||||
|
||||
@AssertCalled(count = 2)
|
||||
override fun onHistoryStateChange(session: GeckoSession, historyList: HistoryDelegate.HistoryList) {
|
||||
override fun onHistoryStateChange(session: GeckoSession, historyList: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1051,19 +1072,19 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
@Test fun waitUntilCalled_interfaceWithSpecificSession() {
|
||||
val newSession = sessionRule.createOpenSession()
|
||||
newSession.loadTestPath(HELLO_HTML_PATH)
|
||||
newSession.waitUntilCalled(ProgressDelegate::class, "onPageStop")
|
||||
newSession.waitUntilCalled(Callbacks.ProgressDelegate::class, "onPageStop")
|
||||
}
|
||||
|
||||
@Test fun waitUntilCalled_interfaceWithAllSessions() {
|
||||
val newSession = sessionRule.createOpenSession()
|
||||
newSession.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(ProgressDelegate::class, "onPageStop")
|
||||
sessionRule.waitUntilCalled(Callbacks.ProgressDelegate::class, "onPageStop")
|
||||
}
|
||||
|
||||
@Test fun waitUntilCalled_callbackWithSpecificSession() {
|
||||
val newSession = sessionRule.createOpenSession()
|
||||
newSession.loadTestPath(HELLO_HTML_PATH)
|
||||
newSession.waitUntilCalled(object : ProgressDelegate {
|
||||
newSession.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -1074,7 +1095,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
val newSession = sessionRule.createOpenSession()
|
||||
newSession.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
}
|
||||
|
@ -1088,14 +1109,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
newSession.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
newSession.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
||||
sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
|
@ -1113,7 +1134,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
|
@ -1135,21 +1156,21 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
// forCallbacksDuringWait calls strictly apply to the last wait, session-specific or not.
|
||||
var counter = 0
|
||||
|
||||
sessionRule.session.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
||||
newSession.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
newSession.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
|
@ -1164,14 +1185,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
|
||||
var counter = 0
|
||||
|
||||
newSession.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
newSession.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
||||
sessionRule.session.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
sessionRule.session.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
|
@ -1187,7 +1208,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
@Test fun delegateUntilTestEnd_withAllSessions() {
|
||||
var counter = 0
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
|
@ -1205,14 +1226,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
val newSession = sessionRule.createOpenSession()
|
||||
var counter = 0
|
||||
|
||||
newSession.delegateDuringNextWait(object : ProgressDelegate {
|
||||
newSession.delegateDuringNextWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
||||
newSession.delegateUntilTestEnd(object : ProgressDelegate {
|
||||
newSession.delegateUntilTestEnd(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
|
@ -1230,14 +1251,14 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
val newSession = sessionRule.createOpenSession()
|
||||
var counter = 0
|
||||
|
||||
newSession.delegateDuringNextWait(object : ProgressDelegate {
|
||||
newSession.delegateDuringNextWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
}
|
||||
})
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : ProgressDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
counter++
|
||||
|
@ -1395,10 +1416,10 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
fun evaluateJS_canTimeout() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.session.waitForPageStop()
|
||||
sessionRule.session.delegateUntilTestEnd(object : PromptDelegate {
|
||||
override fun onAlertPrompt(session: GeckoSession, prompt: PromptDelegate.AlertPrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
sessionRule.session.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
override fun onAlertPrompt(session: GeckoSession, prompt: GeckoSession.PromptDelegate.AlertPrompt): GeckoResult<GeckoSession.PromptDelegate.PromptResponse> {
|
||||
// Return a GeckoResult that we will never complete, so it hangs.
|
||||
val res = GeckoResult<PromptDelegate.PromptResponse>()
|
||||
val res = GeckoResult<GeckoSession.PromptDelegate.PromptResponse>()
|
||||
return res
|
||||
}
|
||||
})
|
||||
|
@ -1537,9 +1558,9 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.session.waitForJS("alert(), 'foo'") as String,
|
||||
equalTo("foo"))
|
||||
|
||||
sessionRule.session.forCallbacksDuringWait(object : PromptDelegate {
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAlertPrompt(session: GeckoSession, prompt: PromptDelegate.AlertPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
override fun onAlertPrompt(session: GeckoSession, prompt: GeckoSession.PromptDelegate.AlertPrompt): GeckoResult<GeckoSession.PromptDelegate.PromptResponse>? {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
|
@ -1558,8 +1579,8 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
var count = 0
|
||||
sessionRule.session.delegateDuringNextWait(object : PromptDelegate {
|
||||
override fun onAlertPrompt(session: GeckoSession, prompt: PromptDelegate.AlertPrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
sessionRule.session.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
override fun onAlertPrompt(session: GeckoSession, prompt: GeckoSession.PromptDelegate.AlertPrompt): GeckoResult<GeckoSession.PromptDelegate.PromptResponse> {
|
||||
count++
|
||||
return GeckoResult.fromValue(prompt.dismiss())
|
||||
}
|
||||
|
@ -1675,7 +1696,7 @@ class GeckoSessionTestRuleTest : BaseSessionTest(noErrorCollector = true) {
|
|||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
mainSession.loadUri(CONTENT_CRASH_URL)
|
||||
mainSession.waitUntilCalled(object : ContentDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCrash(session: GeckoSession) = Unit
|
||||
})
|
||||
|
|
|
@ -6,7 +6,6 @@ package org.mozilla.geckoview.test
|
|||
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.HistoryDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
|
||||
|
||||
|
@ -16,6 +15,7 @@ import org.hamcrest.Matchers.*
|
|||
import org.junit.Assume.assumeThat
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import org.junit.Ignore
|
||||
import org.mozilla.geckoview.test.util.UiThreadUtils
|
||||
|
||||
|
@ -99,7 +99,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
@Test fun onHistoryStateChange() {
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have one entry", state.size,
|
||||
|
@ -113,7 +113,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.loadTestPath(HELLO2_HTML_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have two entries", state.size,
|
||||
|
@ -127,7 +127,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.goBack()
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have two entries", state.size,
|
||||
|
@ -141,7 +141,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.goForward()
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have two entries", state.size,
|
||||
|
@ -155,7 +155,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.gotoHistoryIndex(0)
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have two entries", state.size,
|
||||
|
@ -169,7 +169,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.gotoHistoryIndex(1)
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have two entries", state.size,
|
||||
|
@ -189,7 +189,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
// This is a smaller version of the above test, in the hopes to minimize race conditions
|
||||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have one entry", state.size,
|
||||
|
@ -203,7 +203,7 @@ class HistoryDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.loadTestPath(HELLO2_HTML_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.HistoryDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have two entries", state.size,
|
||||
|
|
|
@ -6,10 +6,21 @@ package org.mozilla.geckoview.test
|
|||
|
||||
import androidx.test.filters.MediumTest
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import android.util.Log
|
||||
|
||||
import org.hamcrest.Matchers.*
|
||||
import org.json.JSONObject
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.Assume.assumeThat
|
||||
import org.junit.Assume.assumeTrue
|
||||
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.gecko.util.ImageResource
|
||||
|
|
|
@ -11,10 +11,10 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.PanZoomController
|
||||
import org.mozilla.geckoview.PanZoomController.InputResultDetail
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -23,7 +23,7 @@ class InputResultDetailTest : BaseSessionTest() {
|
|||
|
||||
private fun setupDocument(documentPath: String) {
|
||||
sessionRule.session.loadTestPath(documentPath)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
|
|
@ -13,9 +13,8 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.junit.Assume.assumeThat
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.MediaDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -24,7 +23,7 @@ class MediaDelegateTest : BaseSessionTest() {
|
|||
|
||||
private fun requestRecordingPermission(allowAudio: Boolean, allowCamera: Boolean) {
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 1)
|
||||
override fun onMediaPermissionRequest(
|
||||
session: GeckoSession, uri: String,
|
||||
|
@ -56,7 +55,7 @@ class MediaDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
mainSession.delegateDuringNextWait(object : MediaDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.MediaDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 1)
|
||||
override fun onRecordingStatusChanged(session: GeckoSession,
|
||||
devices: Array<org.mozilla.geckoview.GeckoSession.MediaDelegate.RecordingDevice>) {
|
||||
|
|
|
@ -13,9 +13,8 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.junit.Assume.assumeThat
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.MediaDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -24,7 +23,7 @@ class MediaDelegateXOriginTest : BaseSessionTest() {
|
|||
|
||||
private fun requestRecordingPermission(allowAudio: Boolean, allowCamera: Boolean) {
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 1)
|
||||
override fun onMediaPermissionRequest(
|
||||
session: GeckoSession, uri: String,
|
||||
|
@ -56,7 +55,7 @@ class MediaDelegateXOriginTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
mainSession.delegateDuringNextWait(object : MediaDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.MediaDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 1)
|
||||
override fun onRecordingStatusChanged(session: GeckoSession,
|
||||
devices: Array<org.mozilla.geckoview.GeckoSession.MediaDelegate.RecordingDevice>) {
|
||||
|
@ -103,7 +102,7 @@ class MediaDelegateXOriginTest : BaseSessionTest() {
|
|||
|
||||
private fun requestRecordingPermissionNoAllow(allowAudio: Boolean, allowCamera: Boolean) {
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 0)
|
||||
override fun onMediaPermissionRequest(
|
||||
session: GeckoSession, uri: String,
|
||||
|
@ -121,7 +120,7 @@ class MediaDelegateXOriginTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
mainSession.delegateDuringNextWait(object : MediaDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.MediaDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 0)
|
||||
override fun onRecordingStatusChanged(session: GeckoSession,
|
||||
devices: Array<org.mozilla.geckoview.GeckoSession.MediaDelegate.RecordingDevice>) {}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.junit.runner.RunWith
|
|||
import org.junit.Assume.assumeThat
|
||||
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
|
@ -163,7 +164,7 @@ class MediaSessionTest : BaseSessionTest() {
|
|||
// 1.
|
||||
session1.loadTestPath(path)
|
||||
|
||||
session1.delegateUntilTestEnd(object : MediaSession.Delegate {
|
||||
session1.delegateUntilTestEnd(object : Callbacks.MediaSessionDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onActivated(
|
||||
session: GeckoSession,
|
||||
|
@ -354,7 +355,7 @@ class MediaSessionTest : BaseSessionTest() {
|
|||
// 1.
|
||||
session1.loadTestPath(path)
|
||||
|
||||
session1.delegateUntilTestEnd(object : MediaSession.Delegate {
|
||||
session1.delegateUntilTestEnd(object : Callbacks.MediaSessionDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onActivated(
|
||||
session: GeckoSession,
|
||||
|
@ -489,7 +490,7 @@ class MediaSessionTest : BaseSessionTest() {
|
|||
var mediaSession1 : MediaSession? = null
|
||||
var mediaSession2 : MediaSession? = null
|
||||
|
||||
session1.delegateUntilTestEnd(object : MediaSession.Delegate {
|
||||
session1.delegateUntilTestEnd(object : Callbacks.MediaSessionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onActivated(
|
||||
session: GeckoSession,
|
||||
|
@ -595,7 +596,7 @@ class MediaSessionTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
|
||||
session2.delegateUntilTestEnd(object : MediaSession.Delegate {
|
||||
session2.delegateUntilTestEnd(object : Callbacks.MediaSessionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onActivated(
|
||||
session: GeckoSession,
|
||||
|
@ -724,7 +725,7 @@ class MediaSessionTest : BaseSessionTest() {
|
|||
val path = VIDEO_WEBM_PATH
|
||||
val session1 = sessionRule.createOpenSession()
|
||||
|
||||
session1.delegateUntilTestEnd(object : MediaSession.Delegate {
|
||||
session1.delegateUntilTestEnd(object : Callbacks.MediaSessionDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onActivated(
|
||||
session: GeckoSession,
|
||||
|
|
|
@ -19,17 +19,11 @@ import org.junit.Ignore
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.*
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.HistoryDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.Loader
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.*
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate.LoadRequest
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.TextInputDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.*
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import org.mozilla.geckoview.test.util.UiThreadUtils
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
@ -57,7 +51,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
expectedError: Int,
|
||||
errorPageUrl: String?) {
|
||||
sessionRule.delegateDuringNextWait(
|
||||
object : ProgressDelegate, NavigationDelegate, ContentDelegate {
|
||||
object : Callbacks.ProgressDelegate, Callbacks.NavigationDelegate, Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -95,7 +89,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
if (errorPageUrl != null) {
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate, NavigationDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate, Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("URL should match", url, equalTo(testLoader.getUri()))
|
||||
|
@ -126,7 +120,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
expectedError: Int,
|
||||
errorPageUrl: String?) {
|
||||
sessionRule.delegateDuringNextWait(
|
||||
object : ProgressDelegate, NavigationDelegate, ContentDelegate {
|
||||
object : Callbacks.ProgressDelegate, Callbacks.NavigationDelegate, Callbacks.ContentDelegate {
|
||||
|
||||
@AssertCalled(false)
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
|
@ -149,10 +143,10 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
|
||||
sessionRule.session.loadUri(testUri)
|
||||
sessionRule.waitUntilCalled(NavigationDelegate::class, "onLoadError")
|
||||
sessionRule.waitUntilCalled(Callbacks.NavigationDelegate::class, "onLoadError")
|
||||
|
||||
if (errorPageUrl != null) {
|
||||
sessionRule.waitUntilCalled(object: ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object: Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onTitleChange(session: GeckoSession, title: String?) {
|
||||
assertThat("Title should not be empty", title, not(isEmptyOrNullString()))
|
||||
|
@ -209,19 +203,13 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
// TODO: bug 1710943
|
||||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
testLoadExpectError(TestLoader()
|
||||
.uri("file:///")
|
||||
.flags(GeckoSession.LOAD_FLAGS_EXTERNAL),
|
||||
testLoadExpectError(TestLoader().uri("file:///").flags(LOAD_FLAGS_EXTERNAL),
|
||||
WebRequestError.ERROR_CATEGORY_UNKNOWN,
|
||||
WebRequestError.ERROR_UNKNOWN)
|
||||
testLoadExpectError(TestLoader()
|
||||
.uri("resource://gre/")
|
||||
.flags(GeckoSession.LOAD_FLAGS_EXTERNAL),
|
||||
testLoadExpectError(TestLoader().uri("resource://gre/").flags(LOAD_FLAGS_EXTERNAL),
|
||||
WebRequestError.ERROR_CATEGORY_UNKNOWN,
|
||||
WebRequestError.ERROR_UNKNOWN)
|
||||
testLoadExpectError(TestLoader()
|
||||
.uri("about:about")
|
||||
.flags(GeckoSession.LOAD_FLAGS_EXTERNAL),
|
||||
testLoadExpectError(TestLoader().uri("about:about").flags(LOAD_FLAGS_EXTERNAL),
|
||||
WebRequestError.ERROR_CATEGORY_UNKNOWN,
|
||||
WebRequestError.ERROR_UNKNOWN)
|
||||
}
|
||||
|
@ -259,7 +247,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.waitForJS("document.addCertException(false)")
|
||||
mainSession.delegateDuringNextWait(
|
||||
object : ProgressDelegate, NavigationDelegate, ContentDelegate {
|
||||
object : Callbacks.ProgressDelegate, Callbacks.NavigationDelegate, Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URI should be " + uri, url, equalTo(uri))
|
||||
|
@ -267,7 +255,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
@AssertCalled(count = 1, order = [2])
|
||||
override fun onSecurityChange(session: GeckoSession,
|
||||
securityInfo: ProgressDelegate.SecurityInformation) {
|
||||
securityInfo: GeckoSession.ProgressDelegate.SecurityInformation) {
|
||||
assertThat("Should be exception", securityInfo.isException, equalTo(true))
|
||||
assertThat("Should not be secure", securityInfo.isSecure, equalTo(false))
|
||||
}
|
||||
|
@ -304,7 +292,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
WebRequestError.ERROR_CATEGORY_SECURITY,
|
||||
WebRequestError.ERROR_SECURITY_SSL)
|
||||
|
||||
mainSession.delegateDuringNextWait(object : ProgressDelegate, NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.ProgressDelegate, Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
|
||||
return null
|
||||
|
@ -339,7 +327,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(insecureUri)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
mainSession.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
|
||||
assertThat("categories should match", error.category, equalTo(WebRequestError.ERROR_CATEGORY_SECURITY))
|
||||
|
@ -353,7 +341,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(secureUri)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
mainSession.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
|
||||
return null
|
||||
|
@ -374,7 +362,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
privateSession.waitForPageStop()
|
||||
|
||||
var onLoadCalledCounter = 0
|
||||
privateSession.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
privateSession.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
|
||||
return null
|
||||
|
@ -401,7 +389,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
privateSession.loadUri(insecureUri)
|
||||
privateSession.waitForPageStop()
|
||||
|
||||
privateSession.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
privateSession.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
|
||||
assertThat("categories should match", error.category, equalTo(WebRequestError.ERROR_CATEGORY_SECURITY))
|
||||
|
@ -413,7 +401,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(secureUri)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
mainSession.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
|
||||
return null
|
||||
|
@ -444,7 +432,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(IFRAME_UNKNOWN_PROTOCOL)
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest) : GeckoResult<AllowOrDeny>? {
|
||||
assertThat("URI should not be null", request.uri, notNullValue())
|
||||
|
@ -471,7 +459,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(TRACKERS_PATH)
|
||||
|
||||
sessionRule.waitUntilCalled(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@AssertCalled(count = 3)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -493,7 +481,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : ContentBlocking.Delegate {
|
||||
object : Callbacks.ContentBlockingDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onContentBlocked(session: GeckoSession,
|
||||
event: ContentBlocking.BlockEvent) {
|
||||
|
@ -528,7 +516,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadUri(uri)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 2, order = [1, 2])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -543,7 +531,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
equalTo(forEachCall(true, false)))
|
||||
assertThat("Target should not be null", request.target, notNullValue())
|
||||
assertThat("Target should match", request.target,
|
||||
equalTo(NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
assertThat("Redirect flag is set", request.isRedirect,
|
||||
equalTo(forEachCall(false, true)))
|
||||
return null
|
||||
|
@ -565,7 +553,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
// We shouldn't be firing onLoadRequest for iframes, including redirects.
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -611,7 +599,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
sessionRule.delegateDuringNextWait(
|
||||
object : NavigationDelegate {
|
||||
object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 2, order = [1, 2])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -626,7 +614,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
equalTo(forEachCall(true, false)))
|
||||
assertThat("Target should not be null", request.target, notNullValue())
|
||||
assertThat("Target should match", request.target,
|
||||
equalTo(NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
assertThat("Redirect flag is set", request.isRedirect,
|
||||
equalTo(forEachCall(false, true)))
|
||||
|
||||
|
@ -638,7 +626,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : ProgressDelegate {
|
||||
object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URL should match", url, equalTo(uri))
|
||||
|
@ -660,7 +648,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadUri(uri)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 2, order = [1, 2])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -689,7 +677,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : NavigationDelegate {
|
||||
object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?,
|
||||
error: WebRequestError): GeckoResult<String>? {
|
||||
|
@ -721,7 +709,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : NavigationDelegate {
|
||||
object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?,
|
||||
error: WebRequestError): GeckoResult<String>? {
|
||||
|
@ -752,7 +740,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : NavigationDelegate {
|
||||
object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?,
|
||||
error: WebRequestError): GeckoResult<String>? {
|
||||
|
@ -779,7 +767,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : NavigationDelegate {
|
||||
object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?,
|
||||
error: WebRequestError): GeckoResult<String>? {
|
||||
|
@ -810,7 +798,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(
|
||||
object : NavigationDelegate {
|
||||
object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoadError(session: GeckoSession, uri: String?,
|
||||
error: WebRequestError): GeckoResult<String>? {
|
||||
|
@ -941,7 +929,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assertThat("User agent should now be reported as VR",
|
||||
getUserAgent(), containsString(vrSubStr))
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
sessionRule.session.settings.userAgentOverride = overrideUserAgent
|
||||
return null
|
||||
|
@ -954,7 +942,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assertThat("User agent should be reported as override after being set in onLoadRequest",
|
||||
getUserAgent(), equalTo(overrideUserAgent))
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
sessionRule.session.settings.userAgentOverride = null
|
||||
return null
|
||||
|
@ -1012,7 +1000,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH")
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -1026,7 +1014,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
equalTo(true))
|
||||
assertThat("Target should not be null", request.target, notNullValue())
|
||||
assertThat("Target should match", request.target,
|
||||
equalTo(NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
assertThat("Redirect flag is not set", request.isRedirect, equalTo(false))
|
||||
assertThat("Should not have a user gesture", request.hasUserGesture, equalTo(false))
|
||||
return null
|
||||
|
@ -1066,7 +1054,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadUri(dataUrl)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("URL should match the provided data URL", url, equalTo(dataUrl))
|
||||
|
@ -1079,7 +1067,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
}
|
||||
|
||||
@NullDelegate(NavigationDelegate::class)
|
||||
@NullDelegate(GeckoSession.NavigationDelegate::class)
|
||||
@Test fun load_withoutNavigationDelegate() {
|
||||
// TODO: bug 1710943
|
||||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
@ -1092,14 +1080,14 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
}
|
||||
|
||||
@NullDelegate(NavigationDelegate::class)
|
||||
@NullDelegate(GeckoSession.NavigationDelegate::class)
|
||||
@Test fun load_canUnsetNavigationDelegate() {
|
||||
// TODO: bug 1710943
|
||||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
// Test that if we unset the navigation delegate during a load, the load still proceeds.
|
||||
var onLocationCount = 0
|
||||
sessionRule.session.navigationDelegate = object : NavigationDelegate {
|
||||
sessionRule.session.navigationDelegate = object : Callbacks.NavigationDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
onLocationCount++
|
||||
}
|
||||
|
@ -1127,7 +1115,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.load(Loader().data(dataString, mimeType))
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate, ContentDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate, Callbacks.ContentDelegate {
|
||||
@AssertCalled
|
||||
override fun onTitleChange(session: GeckoSession, title: String?) {
|
||||
assertThat("Title should match", title, equalTo("TheTitle"))
|
||||
|
@ -1150,7 +1138,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.load(Loader().data("Hello, World!", null))
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("URL should be a data URL", url, startsWith("data:"))
|
||||
|
@ -1173,7 +1161,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.load(Loader().data(bytes, "text/html"))
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate, ContentDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate, Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onTitleChange(session: GeckoSession, title: String?) {
|
||||
assertThat("Title should match", title, equalTo("Hello, world!"))
|
||||
|
@ -1209,7 +1197,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.load(Loader().data(bytes, mimeType))
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate, ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("URL should match", url, equalTo(createDataUri(bytes, mimeType)))
|
||||
|
@ -1241,7 +1229,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.reload()
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -1250,7 +1238,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assertThat("Trigger URL should be null", request.triggerUri,
|
||||
nullValue())
|
||||
assertThat("Target should match", request.target,
|
||||
equalTo(NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
assertThat("Load should not be direct", request.isDirectNavigation,
|
||||
equalTo(false))
|
||||
return null
|
||||
|
@ -1288,9 +1276,9 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO2_HTML_PATH")
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<PermissionDelegate.ContentPermission>) {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("URL should match", url, endsWith(HELLO2_HTML_PATH))
|
||||
}
|
||||
})
|
||||
|
@ -1298,7 +1286,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.goBack()
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -1309,7 +1297,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@AssertCalled(count = 1, order = [2])
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<PermissionDelegate.ContentPermission>) {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("URL should match", url, endsWith(HELLO_HTML_PATH))
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1320,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.goForward()
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -1343,7 +1331,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@AssertCalled(count = 1, order = [2])
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<PermissionDelegate.ContentPermission>) {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("URL should match", url, endsWith(HELLO2_HTML_PATH))
|
||||
}
|
||||
|
||||
|
@ -1368,7 +1356,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
// TODO: bug 1710943
|
||||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -1385,7 +1373,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(HELLO2_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URL should match", url, endsWith(HELLO2_HTML_PATH))
|
||||
|
@ -1410,7 +1398,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.evaluateJS("window.open('newSession_child.html', '_blank')")
|
||||
|
||||
sessionRule.session.waitUntilCalled(object : NavigationDelegate {
|
||||
sessionRule.session.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -1419,7 +1407,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assertThat("Trigger URL should match", request.triggerUri,
|
||||
endsWith(NEW_SESSION_HTML_PATH))
|
||||
assertThat("Target should be correct", request.target,
|
||||
equalTo(NavigationDelegate.TARGET_WINDOW_NEW))
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_NEW))
|
||||
assertThat("Load should not be direct", request.isDirectNavigation,
|
||||
equalTo(false))
|
||||
return null
|
||||
|
@ -1456,7 +1444,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.evaluateJS("document.querySelector('#targetBlankLink').click()")
|
||||
|
||||
sessionRule.session.waitUntilCalled(object : NavigationDelegate {
|
||||
sessionRule.session.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
// We get two onLoadRequest calls for the link click,
|
||||
// one when loading the URL and one when opening a new window.
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
|
@ -1467,7 +1455,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assertThat("Trigger URL should be null", request.triggerUri,
|
||||
endsWith(NEW_SESSION_HTML_PATH))
|
||||
assertThat("Target should be correct", request.target,
|
||||
equalTo(NavigationDelegate.TARGET_WINDOW_NEW))
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_NEW))
|
||||
return null
|
||||
}
|
||||
|
||||
|
@ -1482,7 +1470,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
private fun delegateNewSession(settings: GeckoSessionSettings = mainSession.settings): GeckoSession {
|
||||
val newSession = sessionRule.createClosedSession(settings)
|
||||
|
||||
sessionRule.session.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.session.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onNewSession(session: GeckoSession, uri: String): GeckoResult<GeckoSession> {
|
||||
return GeckoResult.fromValue(newSession)
|
||||
|
@ -1509,7 +1497,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
// NEW_SESSION_CHILD_HTML_PATH
|
||||
newSession.waitForPageStop()
|
||||
|
||||
newSession.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
newSession.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URL should match", url, endsWith(NEW_SESSION_CHILD_HTML_PATH))
|
||||
|
@ -1570,7 +1558,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH)
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.session.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.session.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
GeckoResult<AllowOrDeny>? {
|
||||
|
@ -1589,7 +1577,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForPageStop()
|
||||
|
||||
// Assert that onNewSession was not called for the link click.
|
||||
sessionRule.session.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.session.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -1618,7 +1606,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.evaluateJS("""
|
||||
document.querySelector('input[type=text]').focus()
|
||||
""")
|
||||
sessionRule.session.waitUntilCalled(TextInputDelegate::class,
|
||||
sessionRule.session.waitUntilCalled(GeckoSession.TextInputDelegate::class,
|
||||
"restartInput")
|
||||
|
||||
val time = SystemClock.uptimeMillis()
|
||||
|
@ -1628,7 +1616,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
KeyEvent.changeAction(keyEvent,
|
||||
KeyEvent.ACTION_UP))
|
||||
|
||||
sessionRule.session.waitUntilCalled(object : NavigationDelegate {
|
||||
sessionRule.session.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest):
|
||||
GeckoResult<AllowOrDeny>? {
|
||||
|
@ -1637,7 +1625,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assertThat("Trigger URL should match", request.triggerUri,
|
||||
endsWith("form_blank.html"))
|
||||
assertThat("Target should be correct", request.target,
|
||||
equalTo(NavigationDelegate.TARGET_WINDOW_NEW))
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_NEW))
|
||||
return null
|
||||
}
|
||||
|
||||
|
@ -1705,7 +1693,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
.uri(uri)
|
||||
.referrer(sessionRule.session)
|
||||
.flags(GeckoSession.LOAD_FLAGS_NONE))
|
||||
newSession.waitUntilCalled(object : NavigationDelegate {
|
||||
newSession.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError): GeckoResult<String>? {
|
||||
return null
|
||||
|
@ -1766,22 +1754,22 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
testLoaderEquals(
|
||||
Loader().uri("http://test-uri-equals.com")
|
||||
.flags(GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(GeckoSession.HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.flags(LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.referrer("test-referrer"),
|
||||
Loader().uri("http://test-uri-equals.com")
|
||||
.flags(GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(GeckoSession.HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.flags(LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.referrer("test-referrer"),
|
||||
true)
|
||||
testLoaderEquals(
|
||||
Loader().uri("http://test-uri-equals.com")
|
||||
.flags(GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(GeckoSession.HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.flags(LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.referrer(sessionRule.session),
|
||||
Loader().uri("http://test-uri-equals.com")
|
||||
.flags(GeckoSession.LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(GeckoSession.HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.flags(LOAD_FLAGS_BYPASS_CLASSIFIER)
|
||||
.headerFilter(HEADER_FILTER_UNRESTRICTED_UNSAFE)
|
||||
.referrer("test-referrer"),
|
||||
false)
|
||||
|
||||
|
@ -1967,7 +1955,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(NEW_SESSION_HTML_PATH)
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.session.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.session.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onNewSession(session: GeckoSession, uri: String): GeckoResult<GeckoSession> {
|
||||
return GeckoResult.fromValue(sessionRule.createOpenSession())
|
||||
|
@ -1976,7 +1964,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.evaluateJS("document.querySelector('#targetBlankLink').click()")
|
||||
|
||||
sessionRule.session.waitUntilCalled(NavigationDelegate::class,
|
||||
sessionRule.session.waitUntilCalled(GeckoSession.NavigationDelegate::class,
|
||||
"onNewSession")
|
||||
UiThreadUtils.loopUntilIdle(sessionRule.env.defaultTimeoutMillis)
|
||||
}
|
||||
|
@ -1994,7 +1982,11 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
val controller = sessionRule.runtime.webExtensionController
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : WebExtensionController.PromptDelegate {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
WebExtensionController.PromptDelegate::class,
|
||||
controller::setPromptDelegate,
|
||||
{ controller.promptDelegate = null },
|
||||
object : WebExtensionController.PromptDelegate {
|
||||
@AssertCalled
|
||||
override fun onInstallPrompt(extension: WebExtension): GeckoResult<AllowOrDeny> {
|
||||
return GeckoResult.allow()
|
||||
|
@ -2026,7 +2018,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
settings.aboutConfigEnabled = true
|
||||
|
||||
var currentUrl: String? = null
|
||||
mainSession.delegateUntilTestEnd(object: NavigationDelegate {
|
||||
mainSession.delegateUntilTestEnd(object: GeckoSession.NavigationDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
currentUrl = url
|
||||
}
|
||||
|
@ -2097,7 +2089,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.evaluateJS("location.hash = 'test1';")
|
||||
|
||||
sessionRule.session.waitUntilCalled(object : NavigationDelegate {
|
||||
sessionRule.session.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -2108,14 +2100,14 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<PermissionDelegate.ContentPermission>) {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("URI should match", url, endsWith("#test1"))
|
||||
}
|
||||
})
|
||||
|
||||
sessionRule.session.evaluateJS("location.hash = 'test2';")
|
||||
|
||||
sessionRule.session.waitUntilCalled(object : NavigationDelegate {
|
||||
sessionRule.session.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onLoadRequest(session: GeckoSession,
|
||||
request: LoadRequest):
|
||||
|
@ -2124,7 +2116,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<PermissionDelegate.ContentPermission>) {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("URI should match", url, endsWith("#test2"))
|
||||
}
|
||||
})
|
||||
|
@ -2138,7 +2130,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO_HTML_PATH")
|
||||
sessionRule.waitUntilCalled(object : NavigationDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCanGoBack(session: GeckoSession, canGoBack: Boolean) {
|
||||
assertThat("Session should not be null", session, notNullValue())
|
||||
|
@ -2152,7 +2144,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
sessionRule.session.loadUri("$TEST_ENDPOINT$HELLO2_HTML_PATH")
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate, NavigationDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onCanGoBack(session: GeckoSession, canGoBack: Boolean) {
|
||||
assertThat("Session should not be null", session, notNullValue())
|
||||
|
@ -2164,14 +2156,14 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
assertThat("Cannot go forward", canGoForward, equalTo(false))
|
||||
}
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: HistoryDelegate.HistoryList) {
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have two entries", state.size, equalTo(2))
|
||||
}
|
||||
})
|
||||
sessionRule.session.purgeHistory()
|
||||
sessionRule.waitUntilCalled(object : HistoryDelegate, NavigationDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.All {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: HistoryDelegate.HistoryList) {
|
||||
override fun onHistoryStateChange(session: GeckoSession, state: GeckoSession.HistoryDelegate.HistoryList) {
|
||||
assertThat("History should have one entry", state.size, equalTo(1))
|
||||
}
|
||||
@AssertCalled(count = 1)
|
||||
|
@ -2198,7 +2190,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.synthesizeTap(50, 50)
|
||||
|
||||
sessionRule.waitUntilCalled(object : NavigationDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
assertThat("Should have a user gesture", request.hasUserGesture, equalTo(true))
|
||||
|
@ -2216,7 +2208,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
// TODO: bug 1710943
|
||||
assumeThat(sessionRule.env.isIsolatedProcess, equalTo(false))
|
||||
|
||||
sessionRule.session.delegateDuringNextWait(object : NavigationDelegate {
|
||||
sessionRule.session.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
assertThat("URLs should match", request.uri, endsWith(forEachCall(HELLO_HTML_PATH, HELLO2_HTML_PATH)))
|
||||
|
@ -2235,7 +2227,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
val expectedUri = createDataUri(dataBytes, "*/*")
|
||||
val loader = Loader().data(dataBytes, "*/*")
|
||||
|
||||
sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate {
|
||||
sessionRule.session.delegateUntilTestEnd(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
assertThat("URLs should match", request.uri, equalTo(expectedUri))
|
||||
|
@ -2255,7 +2247,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
|
||||
sessionRule.session.load(loader)
|
||||
sessionRule.waitUntilCalled(NavigationDelegate::class, "onLoadError")
|
||||
sessionRule.waitUntilCalled(Callbacks.NavigationDelegate::class, "onLoadError")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2269,7 +2261,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(DATA_URI_PATH)
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate {
|
||||
sessionRule.session.delegateUntilTestEnd(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(false)
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
return GeckoResult.deny()
|
||||
|
@ -2283,7 +2275,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
|
||||
@Test
|
||||
fun loadShortDataUriToplevelIndirect() {
|
||||
sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate {
|
||||
sessionRule.session.delegateUntilTestEnd(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
return GeckoResult.allow()
|
||||
|
@ -2334,7 +2326,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
|||
fun loadLongDataUriNonToplevel() {
|
||||
val dataUri = createLargeHighEntropyImageDataUri()
|
||||
|
||||
sessionRule.session.delegateUntilTestEnd(object : NavigationDelegate {
|
||||
sessionRule.session.delegateUntilTestEnd(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
|
||||
return GeckoResult.allow()
|
||||
|
|
|
@ -9,13 +9,10 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mozilla.gecko.util.ThreadUtils
|
||||
import org.mozilla.geckoview.*
|
||||
import org.mozilla.geckoview.GeckoRuntime.ServiceWorkerDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.NullDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.TimeoutMillis
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import org.mozilla.geckoview.test.util.UiThreadUtils
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
|
@ -27,10 +24,10 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.requireuserinteraction" to false))
|
||||
|
||||
// Grant "desktop notification" permission
|
||||
mainSession.delegateUntilTestEnd(object : PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, perm: PermissionDelegate.ContentPermission): GeckoResult<Int>? {
|
||||
assertThat("Should grant DESKTOP_NOTIFICATIONS permission", perm.permission, equalTo(PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION))
|
||||
return GeckoResult.fromValue(PermissionDelegate.ContentPermission.VALUE_ALLOW);
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission): GeckoResult<Int>? {
|
||||
assertThat("Should grant DESKTOP_NOTIFICATIONS permission", perm.permission, equalTo(GeckoSession.PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION))
|
||||
return GeckoResult.fromValue(GeckoSession.PermissionDelegate.ContentPermission.VALUE_ALLOW);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -42,10 +39,14 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
assertThat("Permission should be granted",
|
||||
result as String, equalTo("granted"))
|
||||
|
||||
val runtime = sessionRule.runtime
|
||||
val notificationResult = GeckoResult<Void>()
|
||||
val register = { delegate: WebNotificationDelegate -> runtime.webNotificationDelegate = delegate}
|
||||
val unregister = { _: WebNotificationDelegate -> runtime.webNotificationDelegate = null }
|
||||
var notificationShown: WebNotification? = null
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(WebNotificationDelegate::class, register,
|
||||
unregister, object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
notificationShown = notification
|
||||
|
@ -58,9 +59,8 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@Test
|
||||
@NullDelegate(ServiceWorkerDelegate::class)
|
||||
fun openWindowNullDelegate() {
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate, NavigationDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ContentDelegate, Callbacks.NavigationDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
// we should not open the target url
|
||||
assertThat("URL should notmatch", url, not(createTestUrl(OPEN_WINDOW_TARGET_PATH)))
|
||||
|
@ -72,25 +72,26 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
|
||||
@Test
|
||||
fun openWindowNullResult() {
|
||||
sessionRule.delegateUntilTestEnd(object : ContentDelegate, NavigationDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
// we should not open the target url
|
||||
assertThat("URL should notmatch", url, not(createTestUrl(OPEN_WINDOW_TARGET_PATH)))
|
||||
}
|
||||
})
|
||||
openPageClickNotification()
|
||||
sessionRule.waitUntilCalled(object : ServiceWorkerDelegate {
|
||||
sessionRule.runtime.setServiceWorkerDelegate(object : GeckoRuntime.ServiceWorkerDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onOpenWindow(url: String): GeckoResult<GeckoSession> {
|
||||
ThreadUtils.assertOnUiThread()
|
||||
return GeckoResult.fromValue(null)
|
||||
}
|
||||
})
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.ContentDelegate, Callbacks.NavigationDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
// we should not open the target url
|
||||
assertThat("URL should notmatch", url, not(createTestUrl(OPEN_WINDOW_TARGET_PATH)))
|
||||
}
|
||||
})
|
||||
openPageClickNotification()
|
||||
UiThreadUtils.loopUntilIdle(sessionRule.env.defaultTimeoutMillis)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun openWindowSameSession() {
|
||||
sessionRule.delegateUntilTestEnd(object : ServiceWorkerDelegate {
|
||||
sessionRule.runtime.setServiceWorkerDelegate(object : GeckoRuntime.ServiceWorkerDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onOpenWindow(url: String): GeckoResult<GeckoSession> {
|
||||
ThreadUtils.assertOnUiThread()
|
||||
|
@ -98,7 +99,7 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
openPageClickNotification()
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate, NavigationDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate, Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("Should be on the main session", session, equalTo(mainSession))
|
||||
|
@ -116,7 +117,7 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
@Test
|
||||
fun openWindowNewSession() {
|
||||
var targetSession: GeckoSession? = null
|
||||
sessionRule.delegateUntilTestEnd(object : ServiceWorkerDelegate {
|
||||
sessionRule.runtime.setServiceWorkerDelegate(object : GeckoRuntime.ServiceWorkerDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onOpenWindow(url: String): GeckoResult<GeckoSession> {
|
||||
ThreadUtils.assertOnUiThread()
|
||||
|
@ -125,7 +126,7 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
openPageClickNotification()
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate, NavigationDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate, Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("Should be on the target session", session, equalTo(targetSession))
|
||||
|
@ -139,4 +140,4 @@ class OpenWindowTest : BaseSessionTest() {
|
|||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,11 @@ import org.hamcrest.Matchers.*
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.junit.Assume.assumeTrue
|
||||
import org.mozilla.geckoview.PanZoomController
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
|
|
@ -6,10 +6,9 @@ package org.mozilla.geckoview.test
|
|||
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.RejectedPromiseException
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
|
@ -76,7 +75,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
assertThat("Device list should contain microphone device",
|
||||
hasAudio, equalTo(true))
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onMediaPermissionRequest(
|
||||
session: GeckoSession, uri: String,
|
||||
|
@ -124,7 +123,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
assertThat("Stream should be active and id should not be empty.", isActive, equalTo(true));
|
||||
|
||||
// Now test rejecting the request.
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onMediaPermissionRequest(
|
||||
session: GeckoSession, uri: String,
|
||||
|
@ -159,7 +158,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
// Ensure the content permission is asked first, before the Android permission.
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onContentPermissionRequest(
|
||||
|
@ -208,7 +207,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
|
||||
assertThat("Geolocation permission should be set to allow", permFound, equalTo(true))
|
||||
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2 : Boolean = false
|
||||
|
@ -230,7 +229,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -266,7 +265,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
|
||||
assertThat("Geolocation permission should be set to allow", permFound, equalTo(true))
|
||||
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2 : Boolean = false
|
||||
|
@ -289,7 +288,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -319,7 +318,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
|
||||
assertThat("Notification permission should be set to allow", permFound, equalTo(true))
|
||||
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2 : Boolean = false
|
||||
|
@ -347,7 +346,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -374,7 +373,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
|
||||
assertThat("Notification permission should be set to allow", permFound, equalTo(true))
|
||||
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2 : Boolean = false
|
||||
|
@ -399,7 +398,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.loadTestPath(AUTOPLAY_PATH)
|
||||
|
||||
mainSession.waitUntilCalled(object : PermissionDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onContentPermissionRequest(session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
GeckoResult<Int>? {
|
||||
|
@ -417,7 +416,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -448,7 +447,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
|
||||
assertThat("Notification permission should be set to allow", permFound, equalTo(true))
|
||||
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2: Boolean = false
|
||||
|
@ -472,7 +471,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
session2.loadUri(url)
|
||||
session2.waitForPageStop()
|
||||
|
||||
session2.delegateDuringNextWait(object : PermissionDelegate {
|
||||
session2.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -504,7 +503,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
|
||||
assertThat("Notification permission should be set to allow", permFound, equalTo(true))
|
||||
|
||||
session2.delegateDuringNextWait(object : NavigationDelegate {
|
||||
session2.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2: Boolean = false
|
||||
|
@ -528,7 +527,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -559,7 +558,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
sessionRule.runtime.storageController.setPermission(notificationPerm!!,
|
||||
GeckoSession.PermissionDelegate.ContentPermission.VALUE_ALLOW)
|
||||
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2 : Boolean = false
|
||||
|
@ -587,7 +586,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -622,7 +621,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
sessionRule.runtime.storageController.setPermission(notificationPerm!!,
|
||||
GeckoSession.PermissionDelegate.ContentPermission.VALUE_DENY)
|
||||
|
||||
mainSession.delegateDuringNextWait(object : NavigationDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms: MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
var permFound2 : Boolean = false
|
||||
|
@ -650,7 +649,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -685,7 +684,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
sessionRule.runtime.storageController.setPermission(notificationPerm!!,
|
||||
GeckoSession.PermissionDelegate.ContentPermission.VALUE_PROMPT)
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -706,7 +705,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadUri(url)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onContentPermissionRequest(
|
||||
session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
|
@ -756,7 +755,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
// mainSession.waitForPageStop()
|
||||
|
||||
// // Persistent storage can be rejected
|
||||
// mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
// mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
// @AssertCalled(count = 1)
|
||||
// override fun onContentPermissionRequest(
|
||||
// session: GeckoSession, uri: String?, type: Int,
|
||||
|
@ -771,7 +770,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
// success as Boolean, equalTo(false))
|
||||
|
||||
// // Persistent storage can be granted
|
||||
// mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
// mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
// // Ensure the content permission is asked first, before the Android permission.
|
||||
// @AssertCalled(count = 1, order = [1])
|
||||
// override fun onContentPermissionRequest(
|
||||
|
@ -791,7 +790,7 @@ class PermissionDelegateTest : BaseSessionTest() {
|
|||
// equalTo(true))
|
||||
|
||||
// // after permission granted further requests will always return true, regardless of response
|
||||
// mainSession.delegateDuringNextWait(object : PermissionDelegate {
|
||||
// mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
|
||||
// @AssertCalled(count = 1)
|
||||
// override fun onContentPermissionRequest(
|
||||
// session: GeckoSession, uri: String?, type: Int,
|
||||
|
|
|
@ -13,9 +13,8 @@ import org.junit.Ignore
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.*
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -28,8 +27,8 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
var counter = 0
|
||||
var lastProgress = -1
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate,
|
||||
NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate,
|
||||
Callbacks.NavigationDelegate {
|
||||
@AssertCalled
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("LocationChange is called", url, endsWith(path))
|
||||
|
@ -71,7 +70,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("Session should not be null", session, notNullValue())
|
||||
|
@ -102,7 +101,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStops(2)
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 2, order = [1, 3])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URL should match", url,
|
||||
|
@ -126,7 +125,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.reload()
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URL should match", url, endsWith(HELLO_HTML_PATH))
|
||||
|
@ -153,7 +152,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.goBack()
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URL should match", url, endsWith(HELLO_HTML_PATH))
|
||||
|
@ -173,7 +172,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.goForward()
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("URL should match", url, endsWith(HELLO2_HTML_PATH))
|
||||
|
@ -197,7 +196,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadUri("https://example.com")
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSecurityChange(session: GeckoSession,
|
||||
securityInfo: GeckoSession.ProgressDelegate.SecurityInformation) {
|
||||
|
@ -237,7 +236,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadUri("https://mozilla-modern.badssl.com")
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSecurityChange(session: GeckoSession,
|
||||
securityInfo: GeckoSession.ProgressDelegate.SecurityInformation) {
|
||||
|
@ -278,7 +277,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
"https://expired.badssl.com")
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : ProgressDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("Load should fail", success, equalTo(false))
|
||||
|
@ -328,7 +327,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
waitForVerticalScroll(100.0, sessionRule.env.defaultTimeoutMillis.toDouble())
|
||||
|
||||
var savedState : GeckoSession.SessionState? = null
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count=1)
|
||||
override fun onSessionStateChange(session: GeckoSession, state: GeckoSession.SessionState) {
|
||||
savedState = state
|
||||
|
@ -358,7 +357,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
session.restoreState(savedState)
|
||||
session.waitForPageStop()
|
||||
|
||||
session.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
session.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("URI should match", url, equalTo(startUri))
|
||||
|
@ -377,7 +376,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
|
||||
session.goBack()
|
||||
|
||||
session.waitUntilCalled(object: NavigationDelegate {
|
||||
session.waitUntilCalled(object: Callbacks.NavigationDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?, perms : MutableList<GeckoSession.PermissionDelegate.ContentPermission>) {
|
||||
assertThat("History should be preserved", url, equalTo(helloUri))
|
||||
}
|
||||
|
@ -397,7 +396,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
mainSession.restoreState(savedState)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.forCallbacksDuringWait(object : NavigationDelegate {
|
||||
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("URI should match", url, equalTo(startUri))
|
||||
|
@ -425,7 +424,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
|
||||
var oldState : GeckoSession.SessionState? = null
|
||||
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSessionStateChange(session: GeckoSession, sessionState: GeckoSession.SessionState) {
|
||||
oldState = sessionState
|
||||
|
@ -436,7 +435,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
|
||||
mainSession.setActive(false)
|
||||
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSessionStateChange(session: GeckoSession, sessionState: GeckoSession.SessionState) {
|
||||
assertThat("Old session state and new should match", sessionState, equalTo(oldState))
|
||||
|
@ -457,7 +456,7 @@ class ProgressDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSessionStateChange(session: GeckoSession, sessionState: GeckoSession.SessionState) {
|
||||
}
|
||||
|
|
|
@ -3,14 +3,11 @@ package org.mozilla.geckoview.test
|
|||
import org.mozilla.geckoview.AllowOrDeny
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate.LoadRequest
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.AuthPrompt
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.PromptResponse
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import androidx.test.filters.MediumTest
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
@ -19,7 +16,6 @@ import org.junit.Assert
|
|||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.Autocomplete
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -28,7 +24,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
// Ensure popup blocking is enabled for this test.
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to true))
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate, NavigationDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate, Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPopupPrompt(session: GeckoSession, prompt: PromptDelegate.PopupPrompt)
|
||||
: GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
|
@ -56,14 +52,14 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
|
||||
sessionRule.session.loadTestPath(POPUP_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(NavigationDelegate::class, "onNewSession")
|
||||
sessionRule.waitUntilCalled(Callbacks.NavigationDelegate::class, "onNewSession")
|
||||
}
|
||||
|
||||
@Test fun popupTestBlock() {
|
||||
// Ensure popup blocking is enabled for this test.
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to true))
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate, NavigationDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate, Callbacks.NavigationDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onPopupPrompt(session: GeckoSession, prompt: PromptDelegate.PopupPrompt)
|
||||
: GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
|
@ -97,7 +93,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
@Test fun alertTest() {
|
||||
sessionRule.session.evaluateJS("alert('Alert!');")
|
||||
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onAlertPrompt(session: GeckoSession, prompt: PromptDelegate.AlertPrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
assertThat("Message should match", "Alert!", equalTo(prompt.message))
|
||||
|
@ -106,90 +102,8 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
}
|
||||
|
||||
// This test checks that saved logins are returned to the app when calling onAuthPrompt
|
||||
@Test fun loginStorageHttpAuthWithPassword() {
|
||||
mainSession.loadTestPath("/basic-auth/foo/bar")
|
||||
sessionRule.delegateDuringNextWait(object : Autocomplete.StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String): GeckoResult<Array<Autocomplete.LoginEntry>>? {
|
||||
return GeckoResult.fromValue(arrayOf(
|
||||
Autocomplete.LoginEntry.Builder()
|
||||
.origin(GeckoSessionTestRule.TEST_ENDPOINT)
|
||||
.formActionOrigin(GeckoSessionTestRule.TEST_ENDPOINT)
|
||||
.httpRealm("Fake Realm")
|
||||
.username("test-username")
|
||||
.password("test-password")
|
||||
.formActionOrigin(null)
|
||||
.guid("test-guid")
|
||||
.build()
|
||||
));
|
||||
}
|
||||
})
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate, Autocomplete.StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onAuthPrompt(session: GeckoSession, prompt: AuthPrompt): GeckoResult<PromptResponse>? {
|
||||
assertThat("Saved login should appear here",
|
||||
prompt.authOptions.username, equalTo("test-username"))
|
||||
assertThat("Saved login should appear here",
|
||||
prompt.authOptions.password, equalTo("test-password"))
|
||||
return null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// This test checks that we store login information submitted through HTTP basic auth
|
||||
// This also tests that the login save prompt gets automatically dismissed if
|
||||
// the login information is incorrect.
|
||||
@Test fun loginStorageHttpAuth() {
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf(
|
||||
"signon.rememberSignons" to true))
|
||||
val result = GeckoResult<PromptDelegate.BasePrompt>()
|
||||
val promptInstanceDelegate = object : PromptDelegate.PromptInstanceDelegate {
|
||||
var prompt: PromptDelegate.BasePrompt? = null
|
||||
override fun onPromptDismiss(prompt: PromptDelegate.BasePrompt) {
|
||||
result.complete(prompt)
|
||||
}
|
||||
}
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate, Autocomplete.StorageDelegate {
|
||||
@AssertCalled
|
||||
override fun onAuthPrompt(session: GeckoSession, prompt: AuthPrompt): GeckoResult<PromptResponse>? {
|
||||
return GeckoResult.fromValue(prompt.confirm("foo", "bar"));
|
||||
}
|
||||
|
||||
@AssertCalled
|
||||
override fun onLoginFetch(domain: String): GeckoResult<Array<Autocomplete.LoginEntry>>? {
|
||||
return GeckoResult.fromValue(arrayOf());
|
||||
}
|
||||
|
||||
@AssertCalled
|
||||
override fun onLoginSave(
|
||||
session: GeckoSession,
|
||||
request: PromptDelegate.AutocompleteRequest<Autocomplete.LoginSaveOption>
|
||||
): GeckoResult<PromptResponse>? {
|
||||
val authInfo = request.options[0].value
|
||||
assertThat("auth matches", authInfo.formActionOrigin, isEmptyOrNullString())
|
||||
assertThat("auth matches", authInfo.httpRealm, equalTo("Fake Realm"))
|
||||
assertThat("auth matches", authInfo.origin, equalTo(GeckoSessionTestRule.TEST_ENDPOINT))
|
||||
assertThat("auth matches", authInfo.username, equalTo("foo"))
|
||||
assertThat("auth matches", authInfo.password, equalTo("bar"))
|
||||
promptInstanceDelegate.prompt = request
|
||||
request.setDelegate(promptInstanceDelegate)
|
||||
return GeckoResult()
|
||||
}
|
||||
})
|
||||
|
||||
mainSession.loadTestPath("/basic-auth/foo/bar")
|
||||
|
||||
// The server we try to hit will always reject the login so we should
|
||||
// get a request to reauth which should dismiss the prompt
|
||||
val actualPrompt = sessionRule.waitForResult(result)
|
||||
|
||||
assertThat("Prompt object should match", actualPrompt, equalTo(promptInstanceDelegate.prompt))
|
||||
}
|
||||
|
||||
@Test fun dismissAuthTest() {
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onAuthPrompt(session: GeckoSession, prompt: PromptDelegate.AuthPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
//TODO: Figure out some better testing here.
|
||||
|
@ -208,7 +122,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.waitForPageStop()
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onButtonPrompt(session: GeckoSession, prompt: PromptDelegate.ButtonPrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
assertThat("Message should match", "Confirm?", equalTo(prompt.message))
|
||||
|
@ -220,7 +134,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.waitForJS("confirm('Confirm?')") as Boolean,
|
||||
equalTo(true))
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onButtonPrompt(session: GeckoSession, prompt: PromptDelegate.ButtonPrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
assertThat("Message should match", "Confirm?", equalTo(prompt.message))
|
||||
|
@ -247,7 +161,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
val result = GeckoResult<Void>()
|
||||
sessionRule.delegateUntilTestEnd(object: ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object: Callbacks.ProgressDelegate {
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("Only HELLO_HTML_PATH should load", url, endsWith(HELLO_HTML_PATH))
|
||||
result.complete(null)
|
||||
|
@ -257,7 +171,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
val promptResult = GeckoResult<PromptDelegate.PromptResponse>()
|
||||
val promptResult2 = GeckoResult<PromptDelegate.PromptResponse>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onRepostConfirmPrompt(session: GeckoSession, prompt: PromptDelegate.RepostConfirmPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
// We have to return something here because otherwise the delegate will be invoked
|
||||
|
@ -269,7 +183,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
// This should trigger a confirm resubmit prompt
|
||||
sessionRule.session.reload();
|
||||
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onRepostConfirmPrompt(session: GeckoSession, prompt: PromptDelegate.RepostConfirmPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
promptResult.complete(prompt.confirm(AllowOrDeny.DENY))
|
||||
|
@ -281,7 +195,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
// Trigger it again, this time the load should go through
|
||||
sessionRule.session.reload();
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onRepostConfirmPrompt(session: GeckoSession, prompt: PromptDelegate.RepostConfirmPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
promptResult2.complete(prompt.confirm(AllowOrDeny.ALLOW))
|
||||
|
@ -302,7 +216,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
val result = GeckoResult<Void>()
|
||||
sessionRule.delegateUntilTestEnd(object: ProgressDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object: Callbacks.ProgressDelegate {
|
||||
override fun onPageStart(session: GeckoSession, url: String) {
|
||||
assertThat("Only HELLO2_HTML_PATH should load", url, endsWith(HELLO2_HTML_PATH))
|
||||
result.complete(null)
|
||||
|
@ -312,7 +226,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
val promptResult = GeckoResult<PromptDelegate.PromptResponse>()
|
||||
val promptResult2 = GeckoResult<PromptDelegate.PromptResponse>()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 2)
|
||||
override fun onBeforeUnloadPrompt(session: GeckoSession, prompt: PromptDelegate.BeforeUnloadPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
// We have to return something here because otherwise the delegate will be invoked
|
||||
|
@ -324,7 +238,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
// This will try to load "hello.html" but will be denied, if the request
|
||||
// goes through anyway the onLoadRequest delegate above will throw an exception
|
||||
sessionRule.session.evaluateJS("document.querySelector('#navigateAway').click()")
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onBeforeUnloadPrompt(session: GeckoSession, prompt: PromptDelegate.BeforeUnloadPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
promptResult.complete(prompt.confirm(AllowOrDeny.DENY))
|
||||
|
@ -337,7 +251,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
// This request will go through and end the test. Doing the negative case first will
|
||||
// ensure that if either of this tests fail the test will fail.
|
||||
sessionRule.session.evaluateJS("document.querySelector('#navigateAway2').click()")
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onBeforeUnloadPrompt(session: GeckoSession, prompt: PromptDelegate.BeforeUnloadPrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
promptResult2.complete(prompt.confirm(AllowOrDeny.ALLOW))
|
||||
|
@ -353,7 +267,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(HELLO_HTML_PATH)
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(object : PromptDelegate {
|
||||
sessionRule.delegateUntilTestEnd(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onTextPrompt(session: GeckoSession, prompt: PromptDelegate.TextPrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
assertThat("Message should match", "Prompt:", equalTo(prompt.message))
|
||||
|
@ -376,7 +290,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.evaluateJS("document.getElementById('selectexample').click();")
|
||||
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onChoicePrompt(session: GeckoSession, prompt: PromptDelegate.ChoicePrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
return GeckoResult.fromValue(prompt.dismiss())
|
||||
|
@ -390,7 +304,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
sessionRule.session.loadTestPath(PROMPT_HTML_PATH)
|
||||
sessionRule.session.waitForPageStop()
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onColorPrompt(session: GeckoSession, prompt: PromptDelegate.ColorPrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
assertThat("Value should match", "#ffffff", equalTo(prompt.defaultValue))
|
||||
|
@ -427,7 +341,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.evaluateJS("document.getElementById('dateexample').click();")
|
||||
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onDateTimePrompt(session: GeckoSession, prompt: PromptDelegate.DateTimePrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
return GeckoResult.fromValue(prompt.dismiss())
|
||||
|
@ -443,7 +357,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
sessionRule.session.evaluateJS("document.getElementById('fileexample').click();")
|
||||
|
||||
sessionRule.waitUntilCalled(object : PromptDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFilePrompt(session: GeckoSession, prompt: PromptDelegate.FilePrompt): GeckoResult<PromptDelegate.PromptResponse> {
|
||||
assertThat("Length of mimeTypes should match", 2, equalTo(prompt.mimeTypes!!.size))
|
||||
|
@ -462,7 +376,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
val shareText = "Example share text"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
assertThat("Text field is not null", prompt.text, notNullValue())
|
||||
|
@ -487,7 +401,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
val shareUrl = "https://example.com/"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
assertThat("Text field is null", prompt.text, nullValue())
|
||||
|
@ -512,7 +426,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
val shareTitle = "Title!"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
assertThat("Text field is null", prompt.text, nullValue())
|
||||
|
@ -537,7 +451,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
val shareUrl = "https://www.example.com"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
return GeckoResult.fromValue(prompt.confirm(PromptDelegate.SharePrompt.Result.FAILURE))
|
||||
|
@ -560,7 +474,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
val shareUrl = "https://www.example.com"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
return GeckoResult.fromValue(prompt.confirm(PromptDelegate.SharePrompt.Result.ABORT))
|
||||
|
@ -583,7 +497,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
val shareUrl = "https://www.example.com"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
return GeckoResult.fromValue(prompt.dismiss())
|
||||
|
@ -604,7 +518,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
mainSession.loadTestPath(HELLO_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
return GeckoResult.fromValue(prompt.dismiss())
|
||||
|
@ -628,7 +542,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
// Invalid port should cause URL parser to fail.
|
||||
val shareUrl = "http://www.example.com:123456"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
return GeckoResult.fromValue(prompt.dismiss())
|
||||
|
@ -651,7 +565,7 @@ class PromptDelegateTest : BaseSessionTest() {
|
|||
|
||||
val shareUrl = "https://www.example.com"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : PromptDelegate {
|
||||
sessionRule.delegateDuringNextWait(object : Callbacks.PromptDelegate {
|
||||
@AssertCalled(count = 0)
|
||||
override fun onSharePrompt(session: GeckoSession, prompt: PromptDelegate.SharePrompt): GeckoResult<PromptDelegate.PromptResponse>? {
|
||||
return GeckoResult.fromValue(prompt.dismiss())
|
||||
|
|
|
@ -8,17 +8,19 @@ import android.provider.Settings
|
|||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.filters.MediumTest
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import android.util.Log
|
||||
import org.hamcrest.Matchers.*
|
||||
import org.junit.Assume.assumeThat
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import kotlin.math.roundToInt
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.WebRequestError
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -156,7 +158,7 @@ class RuntimeSettingsTest : BaseSessionTest() {
|
|||
settings.aboutConfigEnabled, equalTo(false))
|
||||
|
||||
mainSession.loadUri("about:config")
|
||||
mainSession.waitUntilCalled(object : NavigationDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.NavigationDelegate {
|
||||
@AssertCalled
|
||||
override fun onLoadError(session: GeckoSession, uri: String?, error: WebRequestError):
|
||||
GeckoResult<String>? {
|
||||
|
@ -167,7 +169,7 @@ class RuntimeSettingsTest : BaseSessionTest() {
|
|||
|
||||
settings.aboutConfigEnabled = true
|
||||
|
||||
mainSession.delegateDuringNextWait(object : ProgressDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled
|
||||
override fun onPageStop(session: GeckoSession, success: Boolean) {
|
||||
assertThat("about:config load should succeed", success, equalTo(true))
|
||||
|
|
|
@ -19,10 +19,9 @@ import org.mozilla.geckoview.GeckoResult
|
|||
import org.mozilla.geckoview.GeckoResult.OnExceptionListener
|
||||
import org.mozilla.geckoview.GeckoResult.fromException
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.max
|
||||
import android.graphics.BitmapFactory
|
||||
|
@ -30,6 +29,8 @@ import android.graphics.Bitmap
|
|||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assume.assumeThat
|
||||
import java.lang.IllegalStateException
|
||||
import java.lang.NullPointerException
|
||||
|
||||
|
||||
private const val SCREEN_HEIGHT = 800
|
||||
private const val SCREEN_WIDTH = 800
|
||||
|
@ -95,7 +96,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -208,7 +209,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -217,7 +218,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
sessionRule.session.setActive(false)
|
||||
|
||||
// Deactivating the session should trigger a flush state change
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onSessionStateChange(session: GeckoSession,
|
||||
sessionState: GeckoSession.SessionState) {}
|
||||
|
@ -234,7 +235,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -251,7 +252,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -268,7 +269,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -285,7 +286,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -302,7 +303,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -324,7 +325,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -341,7 +342,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
val screenshotFile = getComparisonScreenshot(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)
|
||||
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -360,7 +361,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
fun screenshotQuarters() {
|
||||
val res = InstrumentationRegistry.getInstrumentation().targetContext.resources
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -383,7 +384,7 @@ class ScreenshotTest : BaseSessionTest() {
|
|||
fun screenshotQuartersScaled() {
|
||||
val res = InstrumentationRegistry.getInstrumentation().targetContext.resources
|
||||
sessionRule.session.loadTestPath(COLORS_HTML_PATH)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
package org.mozilla.geckoview.test
|
||||
|
||||
import org.mozilla.geckoview.GeckoSession.SelectionActionDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.SelectionActionDelegate.*
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.NullDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
|
@ -172,7 +172,7 @@ class SelectionActionDelegateTest : BaseSessionTest() {
|
|||
@NullDelegate(GeckoSession.SelectionActionDelegate::class)
|
||||
@Test fun clearDelegate() {
|
||||
var counter = 0
|
||||
mainSession.selectionActionDelegate = object : SelectionActionDelegate {
|
||||
mainSession.selectionActionDelegate = object : Callbacks.SelectionActionDelegate {
|
||||
override fun onHideAction(session: GeckoSession, reason: Int) {
|
||||
counter++
|
||||
}
|
||||
|
@ -224,14 +224,14 @@ class SelectionActionDelegateTest : BaseSessionTest() {
|
|||
"geckoview.selection_action.show_on_focus" to true,
|
||||
"layout.accessiblecaret.script_change_update_mode" to 2))
|
||||
|
||||
mainSession.delegateDuringNextWait(object : SelectionActionDelegate {
|
||||
mainSession.delegateDuringNextWait(object : Callbacks.SelectionActionDelegate {
|
||||
override fun onShowActionRequest(session: GeckoSession, selection: GeckoSession.SelectionActionDelegate.Selection) {
|
||||
respondingWith(selection)
|
||||
}
|
||||
})
|
||||
|
||||
content.select()
|
||||
mainSession.waitUntilCalled(object : SelectionActionDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.SelectionActionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onShowActionRequest(session: GeckoSession, selection: Selection) {
|
||||
assertThat("Initial content should match",
|
||||
|
@ -266,7 +266,7 @@ class SelectionActionDelegateTest : BaseSessionTest() {
|
|||
|
||||
var clientRect = RectF()
|
||||
content.select()
|
||||
mainSession.waitUntilCalled(object : SelectionActionDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.SelectionActionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onShowActionRequest(session: GeckoSession, selection: Selection) {
|
||||
clientRect = selection.clientRect!!
|
||||
|
@ -436,7 +436,7 @@ class SelectionActionDelegateTest : BaseSessionTest() {
|
|||
|
||||
private fun hasShowActionRequest(expectedFlags: Int,
|
||||
expectedActions: Array<out String>) = { it: SelectedContent ->
|
||||
mainSession.forCallbacksDuringWait(object : SelectionActionDelegate {
|
||||
mainSession.forCallbacksDuringWait(object : Callbacks.SelectionActionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onShowActionRequest(session: GeckoSession, selection: GeckoSession.SelectionActionDelegate.Selection) {
|
||||
assertThat("Selection text should be valid",
|
||||
|
@ -462,7 +462,7 @@ class SelectionActionDelegateTest : BaseSessionTest() {
|
|||
private fun changesSelectionTo(text: String) = changesSelectionTo(equalTo(text))
|
||||
|
||||
private fun changesSelectionTo(matcher: Matcher<String>) = { _: SelectedContent ->
|
||||
sessionRule.waitUntilCalled(object : SelectionActionDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.SelectionActionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onShowActionRequest(session: GeckoSession, selection: Selection) {
|
||||
assertThat("New selection text should match", selection.text, matcher)
|
||||
|
@ -471,7 +471,7 @@ class SelectionActionDelegateTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
private fun clearsSelection() = { _: SelectedContent ->
|
||||
sessionRule.waitUntilCalled(object : SelectionActionDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.SelectionActionDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onHideAction(session: GeckoSession, reason: Int) {
|
||||
assertThat("Hide reason should be correct",
|
||||
|
|
|
@ -8,9 +8,9 @@ import android.os.SystemClock
|
|||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.TextInputDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.WithDisplay
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
import androidx.test.filters.MediumTest
|
||||
import android.os.Handler;
|
||||
|
@ -29,6 +29,9 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import org.junit.runners.Parameterized.Parameter
|
||||
import org.mozilla.geckoview.test.util.UiThreadUtils
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
@MediumTest
|
||||
@RunWith(Parameterized::class)
|
||||
|
@ -196,7 +199,7 @@ class TextInputDelegateTest : BaseSessionTest() {
|
|||
mainSession.waitForPageStop()
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('$id').focus()")
|
||||
mainSession.waitUntilCalled(object : TextInputDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.TextInputDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun restartInput(session: GeckoSession, reason: Int) {
|
||||
assertThat("Reason should be correct",
|
||||
|
@ -205,7 +208,7 @@ class TextInputDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('$id').blur()")
|
||||
mainSession.waitUntilCalled(object : TextInputDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.TextInputDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun restartInput(session: GeckoSession, reason: Int) {
|
||||
assertThat("Reason should be correct",
|
||||
|
@ -240,7 +243,7 @@ class TextInputDelegateTest : BaseSessionTest() {
|
|||
mainSession.pressKey(KeyEvent.KEYCODE_CTRL_LEFT)
|
||||
mainSession.evaluateJS("document.querySelector('$id').focus()")
|
||||
|
||||
mainSession.waitUntilCalled(object : TextInputDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.TextInputDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun restartInput(session: GeckoSession, reason: Int) {
|
||||
assertThat("Reason should be correct",
|
||||
|
@ -249,10 +252,12 @@ class TextInputDelegateTest : BaseSessionTest() {
|
|||
|
||||
@AssertCalled(count = 1, order = [2])
|
||||
override fun showSoftInput(session: GeckoSession) {
|
||||
super.showSoftInput(session)
|
||||
}
|
||||
|
||||
@AssertCalled(count = 0)
|
||||
override fun hideSoftInput(session: GeckoSession) {
|
||||
super.hideSoftInput(session)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -274,7 +279,7 @@ class TextInputDelegateTest : BaseSessionTest() {
|
|||
// but only one showSoftInput call and no hideSoftInput call.
|
||||
mainSession.evaluateJS("document.querySelector('$id').blur(); document.querySelector('$id').focus()")
|
||||
|
||||
mainSession.waitUntilCalled(object : TextInputDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.TextInputDelegate {
|
||||
@AssertCalled(count = 2, order = [1])
|
||||
override fun restartInput(session: GeckoSession, reason: Int) {
|
||||
assertThat("Reason should be correct", reason, equalTo(forEachCall(
|
||||
|
@ -303,7 +308,7 @@ class TextInputDelegateTest : BaseSessionTest() {
|
|||
mainSession.pressKey(KeyEvent.KEYCODE_CTRL_LEFT)
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('$id').focus()")
|
||||
mainSession.waitUntilCalled(object : TextInputDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.TextInputDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun restartInput(session: GeckoSession, reason: Int) {
|
||||
}
|
||||
|
@ -318,7 +323,7 @@ class TextInputDelegateTest : BaseSessionTest() {
|
|||
})
|
||||
|
||||
mainSession.evaluateJS("document.querySelector('$id').blur()")
|
||||
mainSession.waitUntilCalled(object : TextInputDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.TextInputDelegate {
|
||||
@AssertCalled(count = 1, order = [1])
|
||||
override fun restartInput(session: GeckoSession, reason: Int) {
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ import android.graphics.Bitmap
|
|||
import org.hamcrest.Matchers
|
||||
import org.hamcrest.Matchers.equalTo
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
|
||||
private const val SCREEN_HEIGHT = 800
|
||||
|
@ -67,7 +67,7 @@ class VerticalClippingTest : BaseSessionTest() {
|
|||
assumeThat(sessionRule.env.isWebrender, equalTo(false))
|
||||
sessionRule.display?.setVerticalClipping(45)
|
||||
sessionRule.session.loadTestPath(FIXED_BOTTOM)
|
||||
sessionRule.waitUntilCalled(object : ContentDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ContentDelegate {
|
||||
@AssertCalled(count = 1)
|
||||
override fun onFirstContentfulPaint(session: GeckoSession) {
|
||||
}
|
||||
|
@ -78,4 +78,4 @@ class VerticalClippingTest : BaseSessionTest() {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -14,9 +14,8 @@ import org.junit.Assume.assumeThat
|
|||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.gecko.EventDispatcher
|
||||
import org.mozilla.geckoview.*
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate
|
||||
import org.mozilla.geckoview.WebExtension.*
|
||||
import org.mozilla.geckoview.WebExtension.BrowsingDataDelegate.Type.*
|
||||
import org.mozilla.geckoview.WebExtensionController.EnableSource
|
||||
|
@ -24,6 +23,7 @@ import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
|||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.Setting
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.RejectedPromiseException
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import org.mozilla.geckoview.test.util.RuntimeCreator
|
||||
import org.mozilla.geckoview.test.util.UiThreadUtils
|
||||
import java.nio.charset.Charset
|
||||
|
@ -64,6 +64,12 @@ class WebExtensionTest : BaseSessionTest() {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
WebExtensionController.PromptDelegate::class,
|
||||
controller::setPromptDelegate,
|
||||
{ controller.promptDelegate = null },
|
||||
object : WebExtensionController.PromptDelegate {}
|
||||
)
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("extensions.isembedded" to true))
|
||||
sessionRule.runtime.webExtensionController.setTabActive(mainSession, true)
|
||||
}
|
||||
|
@ -509,11 +515,16 @@ class WebExtensionTest : BaseSessionTest() {
|
|||
|
||||
@Test
|
||||
fun createNotification() {
|
||||
sessionRule.delegateUntilTestEnd(object : WebNotificationDelegate {
|
||||
@AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
}
|
||||
})
|
||||
sessionRule.addExternalDelegateUntilTestEnd(
|
||||
WebNotificationDelegate::class,
|
||||
{ delegate ->
|
||||
sessionRule.runtime.webNotificationDelegate = delegate },
|
||||
{ sessionRule.runtime.webNotificationDelegate = null },
|
||||
object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
}
|
||||
})
|
||||
|
||||
val extension = sessionRule.waitForResult(
|
||||
controller.installBuiltIn("resource://android/assets/web_extensions/notification-test/"))
|
||||
|
@ -1180,7 +1191,7 @@ class WebExtensionTest : BaseSessionTest() {
|
|||
sessionRule.waitForPageStop()
|
||||
|
||||
var savedState : GeckoSession.SessionState? = null
|
||||
sessionRule.waitUntilCalled(object : ProgressDelegate {
|
||||
sessionRule.waitUntilCalled(object : Callbacks.ProgressDelegate {
|
||||
@AssertCalled(count=1)
|
||||
override fun onSessionStateChange(session: GeckoSession, state: GeckoSession.SessionState) {
|
||||
savedState = state
|
||||
|
@ -1624,7 +1635,7 @@ class WebExtensionTest : BaseSessionTest() {
|
|||
|
||||
mainSession.loadUri("http://example.com")
|
||||
|
||||
mainSession.waitUntilCalled(object : NavigationDelegate, ProgressDelegate {
|
||||
mainSession.waitUntilCalled(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled(count = 1)
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
assertThat("Url should load example.com first",
|
||||
|
@ -1642,7 +1653,7 @@ class WebExtensionTest : BaseSessionTest() {
|
|||
var page: String? = null
|
||||
val pageStop = GeckoResult<Boolean>()
|
||||
|
||||
mainSession.delegateUntilTestEnd(object : NavigationDelegate, ProgressDelegate {
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.NavigationDelegate, Callbacks.ProgressDelegate {
|
||||
override fun onLocationChange(session: GeckoSession, url: String?) {
|
||||
page = url
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate
|
||||
import org.mozilla.geckoview.WebNotification
|
||||
import org.mozilla.geckoview.WebNotificationDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
|
@ -24,11 +24,11 @@ class WebNotificationTest : BaseSessionTest() {
|
|||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.requireuserinteraction" to false))
|
||||
|
||||
// Grant "desktop notification" permission
|
||||
mainSession.delegateUntilTestEnd(object : PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, perm: PermissionDelegate.ContentPermission):
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
GeckoResult<Int>? {
|
||||
assertThat("Should grant DESKTOP_NOTIFICATIONS permission", perm.permission, equalTo(PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION))
|
||||
return GeckoResult.fromValue(PermissionDelegate.ContentPermission.VALUE_ALLOW)
|
||||
assertThat("Should grant DESKTOP_NOTIFICATIONS permission", perm.permission, equalTo(GeckoSession.PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION))
|
||||
return GeckoResult.fromValue(GeckoSession.PermissionDelegate.ContentPermission.VALUE_ALLOW)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -39,9 +39,13 @@ class WebNotificationTest : BaseSessionTest() {
|
|||
|
||||
@Test fun onSilentNotification() {
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.silent.enabled" to true))
|
||||
val runtime = sessionRule.runtime
|
||||
val notificationResult = GeckoResult<Void>()
|
||||
val register = { delegate: WebNotificationDelegate -> runtime.webNotificationDelegate = delegate}
|
||||
val unregister = { _: WebNotificationDelegate -> runtime.webNotificationDelegate = null }
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(WebNotificationDelegate::class, register,
|
||||
unregister, object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
assertThat("Title should match", notification.title, equalTo("The Title"))
|
||||
|
@ -61,11 +65,15 @@ class WebNotificationTest : BaseSessionTest() {
|
|||
|
||||
@Test fun onShowNotification() {
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.vibrate.enabled" to true))
|
||||
val runtime = sessionRule.runtime
|
||||
val notificationResult = GeckoResult<Void>()
|
||||
val register = { delegate: WebNotificationDelegate -> runtime.webNotificationDelegate = delegate}
|
||||
val unregister = { _: WebNotificationDelegate -> runtime.webNotificationDelegate = null }
|
||||
val requireInteraction =
|
||||
sessionRule.getPrefs("dom.webnotifications.requireinteraction.enabled")[0] as Boolean
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(WebNotificationDelegate::class, register,
|
||||
unregister, object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
assertThat("Title should match", notification.title, equalTo("The Title"))
|
||||
|
@ -93,9 +101,13 @@ class WebNotificationTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@Test fun onCloseNotification() {
|
||||
val runtime = sessionRule.runtime
|
||||
val closeCalled = GeckoResult<Void>()
|
||||
val register = { delegate: WebNotificationDelegate -> runtime.webNotificationDelegate = delegate}
|
||||
val unregister = { _: WebNotificationDelegate -> runtime.webNotificationDelegate = null }
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(WebNotificationDelegate::class, register,
|
||||
unregister, object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onCloseNotification(notification: WebNotification) {
|
||||
closeCalled.complete(null)
|
||||
|
@ -111,10 +123,14 @@ class WebNotificationTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@Test fun clickNotification() {
|
||||
val runtime = sessionRule.runtime
|
||||
val notificationResult = GeckoResult<Void>()
|
||||
val register = { delegate: WebNotificationDelegate -> runtime.webNotificationDelegate = delegate}
|
||||
val unregister = { _: WebNotificationDelegate -> runtime.webNotificationDelegate = null }
|
||||
var notificationShown: WebNotification? = null
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(WebNotificationDelegate::class, register,
|
||||
unregister, object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
notificationShown = notification
|
||||
|
@ -138,10 +154,14 @@ class WebNotificationTest : BaseSessionTest() {
|
|||
}
|
||||
|
||||
@Test fun dismissNotification() {
|
||||
val runtime = sessionRule.runtime
|
||||
val notificationResult = GeckoResult<Void>()
|
||||
val register = { delegate: WebNotificationDelegate -> runtime.webNotificationDelegate = delegate}
|
||||
val unregister = { _: WebNotificationDelegate -> runtime.webNotificationDelegate = null }
|
||||
var notificationShown: WebNotification? = null
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(WebNotificationDelegate::class, register,
|
||||
unregister, object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
notificationShown = notification
|
||||
|
|
|
@ -16,9 +16,9 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.geckoview.*
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.RejectedPromiseException
|
||||
import org.mozilla.geckoview.test.util.Callbacks
|
||||
import java.security.KeyPair
|
||||
import java.security.KeyPairGenerator
|
||||
import java.security.SecureRandom
|
||||
|
@ -59,7 +59,7 @@ class WebPushTest : BaseSessionTest() {
|
|||
fun setup() {
|
||||
sessionRule.setPrefsUntilTestEnd(mapOf("dom.webnotifications.requireuserinteraction" to false))
|
||||
// Grant "desktop notification" permission
|
||||
mainSession.delegateUntilTestEnd(object : PermissionDelegate {
|
||||
mainSession.delegateUntilTestEnd(object : Callbacks.PermissionDelegate {
|
||||
override fun onContentPermissionRequest(session: GeckoSession, perm: GeckoSession.PermissionDelegate.ContentPermission):
|
||||
GeckoResult<Int>? {
|
||||
assertThat("Should grant DESKTOP_NOTIFICATIONS permission", perm.permission, equalTo(GeckoSession.PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION))
|
||||
|
@ -69,7 +69,10 @@ class WebPushTest : BaseSessionTest() {
|
|||
|
||||
delegate = TestPushDelegate()
|
||||
|
||||
sessionRule.delegateUntilTestEnd(delegate!!)
|
||||
sessionRule.addExternalDelegateUntilTestEnd(WebPushDelegate::class,
|
||||
{ d -> sessionRule.runtime.webPushController.setDelegate(d) },
|
||||
{ sessionRule.runtime.webPushController.setDelegate(null) }, delegate!!)
|
||||
|
||||
|
||||
mainSession.loadTestPath(PUSH_HTML_PATH)
|
||||
mainSession.waitForPageStop()
|
||||
|
@ -164,10 +167,15 @@ class WebPushTest : BaseSessionTest() {
|
|||
|
||||
private fun sendNotification() {
|
||||
val notificationResult = GeckoResult<Void>()
|
||||
val runtime = sessionRule.runtime
|
||||
val register = { delegate: WebNotificationDelegate -> runtime.webNotificationDelegate = delegate}
|
||||
val unregister = { _: WebNotificationDelegate -> runtime.webNotificationDelegate = null }
|
||||
|
||||
val expectedTitle = "The title"
|
||||
val expectedBody = "The body"
|
||||
|
||||
sessionRule.delegateDuringNextWait(object : WebNotificationDelegate {
|
||||
sessionRule.addExternalDelegateDuringNextWait(WebNotificationDelegate::class, register,
|
||||
unregister, object : WebNotificationDelegate {
|
||||
@GeckoSessionTestRule.AssertCalled
|
||||
override fun onShowNotification(notification: WebNotification) {
|
||||
assertThat("Title should match", notification.title, equalTo(expectedTitle))
|
||||
|
|
|
@ -7,37 +7,23 @@ import org.json.JSONArray;
|
|||
import org.json.JSONException;
|
||||
import org.json.JSONTokener;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
import org.mozilla.geckoview.Autocomplete;
|
||||
import org.mozilla.geckoview.Autofill;
|
||||
import org.mozilla.geckoview.ContentBlocking;
|
||||
import org.mozilla.geckoview.GeckoDisplay;
|
||||
import org.mozilla.geckoview.GeckoResult;
|
||||
import org.mozilla.geckoview.GeckoRuntime;
|
||||
import org.mozilla.geckoview.GeckoRuntime.ActivityDelegate;
|
||||
import org.mozilla.geckoview.GeckoRuntime.ServiceWorkerDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession;
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.HistoryDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.MediaDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.PermissionDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.ProgressDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.ScrollDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.SelectionActionDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.TextInputDelegate;
|
||||
import org.mozilla.geckoview.GeckoSessionSettings;
|
||||
import org.mozilla.geckoview.MediaSession;
|
||||
import org.mozilla.geckoview.RuntimeTelemetry;
|
||||
import org.mozilla.geckoview.SessionTextInput;
|
||||
import org.mozilla.geckoview.WebExtension;
|
||||
import org.mozilla.geckoview.WebExtensionController;
|
||||
import org.mozilla.geckoview.WebNotificationDelegate;
|
||||
import org.mozilla.geckoview.WebPushDelegate;
|
||||
import org.mozilla.geckoview.test.util.TestServer;
|
||||
import org.mozilla.geckoview.test.util.RuntimeCreator;
|
||||
import org.mozilla.geckoview.test.util.Environment;
|
||||
import org.mozilla.geckoview.test.util.UiThreadUtils;
|
||||
import org.mozilla.geckoview.test.util.Callbacks;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -53,8 +39,6 @@ import org.junit.runner.Description;
|
|||
import org.junit.runners.model.Statement;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.os.SystemClock;
|
||||
|
@ -745,71 +729,29 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
}
|
||||
}
|
||||
|
||||
private static final Set<Class<?>> DEFAULT_DELEGATES = new HashSet<>();
|
||||
static {
|
||||
DEFAULT_DELEGATES.add(Autofill.Delegate.class);
|
||||
DEFAULT_DELEGATES.add(ContentBlocking.Delegate.class);
|
||||
DEFAULT_DELEGATES.add(ContentDelegate.class);
|
||||
DEFAULT_DELEGATES.add(HistoryDelegate.class);
|
||||
DEFAULT_DELEGATES.add(MediaDelegate.class);
|
||||
DEFAULT_DELEGATES.add(MediaSession.Delegate.class);
|
||||
DEFAULT_DELEGATES.add(NavigationDelegate.class);
|
||||
DEFAULT_DELEGATES.add(PermissionDelegate.class);
|
||||
DEFAULT_DELEGATES.add(ProgressDelegate.class);
|
||||
DEFAULT_DELEGATES.add(PromptDelegate.class);
|
||||
DEFAULT_DELEGATES.add(ScrollDelegate.class);
|
||||
DEFAULT_DELEGATES.add(SelectionActionDelegate.class);
|
||||
DEFAULT_DELEGATES.add(TextInputDelegate.class);
|
||||
}
|
||||
|
||||
private static final Set<Class<?>> DEFAULT_RUNTIME_DELEGATES = new HashSet<>();
|
||||
static {
|
||||
DEFAULT_RUNTIME_DELEGATES.add(Autocomplete.StorageDelegate.class);
|
||||
DEFAULT_RUNTIME_DELEGATES.add(ActivityDelegate.class);
|
||||
DEFAULT_RUNTIME_DELEGATES.add(GeckoRuntime.Delegate.class);
|
||||
DEFAULT_RUNTIME_DELEGATES.add(ServiceWorkerDelegate.class);
|
||||
DEFAULT_RUNTIME_DELEGATES.add(WebNotificationDelegate.class);
|
||||
DEFAULT_RUNTIME_DELEGATES.add(WebExtensionController.PromptDelegate.class);
|
||||
DEFAULT_RUNTIME_DELEGATES.add(WebPushDelegate.class);
|
||||
}
|
||||
|
||||
private static class DefaultImpl implements
|
||||
// Session delegates
|
||||
Autofill.Delegate,
|
||||
ContentBlocking.Delegate,
|
||||
ContentDelegate,
|
||||
HistoryDelegate,
|
||||
MediaDelegate,
|
||||
MediaSession.Delegate,
|
||||
NavigationDelegate,
|
||||
PermissionDelegate,
|
||||
ProgressDelegate,
|
||||
PromptDelegate,
|
||||
ScrollDelegate,
|
||||
SelectionActionDelegate,
|
||||
TextInputDelegate,
|
||||
// Runtime delegates
|
||||
ActivityDelegate,
|
||||
Autocomplete.StorageDelegate,
|
||||
GeckoRuntime.Delegate,
|
||||
ServiceWorkerDelegate,
|
||||
WebExtensionController.PromptDelegate,
|
||||
WebNotificationDelegate,
|
||||
WebPushDelegate
|
||||
{
|
||||
@Override
|
||||
public GeckoResult<Intent> onStartActivityForResult(@NonNull PendingIntent intent) {
|
||||
return null;
|
||||
private static void addCallbackClasses(final List<Class<?>> list, final Class<?> ifce) {
|
||||
if (!Callbacks.class.equals(ifce.getDeclaringClass())) {
|
||||
list.add(ifce);
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onShutdown() {}
|
||||
@Override
|
||||
public GeckoResult<GeckoSession> onOpenWindow(@NonNull String url) {
|
||||
return GeckoResult.fromValue(null);
|
||||
final Class<?>[] superIfces = ifce.getInterfaces();
|
||||
for (final Class<?> superIfce : superIfces) {
|
||||
addCallbackClasses(list, superIfce);
|
||||
}
|
||||
}
|
||||
|
||||
private static final DefaultImpl DEFAULT_IMPL = new DefaultImpl();
|
||||
private static Set<Class<?>> getDefaultDelegates() {
|
||||
final Class<?>[] ifces = Callbacks.class.getDeclaredClasses();
|
||||
final List<Class<?>> list = new ArrayList<>(ifces.length);
|
||||
|
||||
for (final Class<?> ifce : ifces) {
|
||||
addCallbackClasses(list, ifce);
|
||||
}
|
||||
|
||||
return new HashSet<>(list);
|
||||
}
|
||||
|
||||
private static final Set<Class<?>> DEFAULT_DELEGATES = getDefaultDelegates();
|
||||
|
||||
public final Environment env = new Environment();
|
||||
|
||||
|
@ -944,67 +886,28 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
return mDisplays.get(mMainSession);
|
||||
}
|
||||
|
||||
protected static void setDelegate(final @NonNull Class<?> cls,
|
||||
protected static Object setDelegate(final @NonNull Class<?> cls,
|
||||
final @NonNull GeckoSession session,
|
||||
final @Nullable Object delegate)
|
||||
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
if (cls == GeckoSession.TextInputDelegate.class) {
|
||||
session.getTextInput().setDelegate((TextInputDelegate) delegate);
|
||||
} else if (cls == ContentBlocking.Delegate.class) {
|
||||
session.setContentBlockingDelegate((ContentBlocking.Delegate) delegate);
|
||||
} else if (cls == Autofill.Delegate.class) {
|
||||
session.setAutofillDelegate((Autofill.Delegate) delegate);
|
||||
} else if (cls == MediaSession.Delegate.class) {
|
||||
session.setMediaSessionDelegate((MediaSession.Delegate) delegate);
|
||||
} else {
|
||||
GeckoSession.class.getMethod("set" + cls.getSimpleName(), cls)
|
||||
.invoke(session, delegate);
|
||||
return SessionTextInput.class.getMethod("setDelegate", cls)
|
||||
.invoke(session.getTextInput(), delegate);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void setRuntimeDelegate(final @NonNull Class<?> cls,
|
||||
final @NonNull GeckoRuntime runtime,
|
||||
final @Nullable Object delegate)
|
||||
{
|
||||
if (cls == Autocomplete.StorageDelegate.class) {
|
||||
runtime.setAutocompleteStorageDelegate((Autocomplete.StorageDelegate) delegate);
|
||||
} else if (cls == ActivityDelegate.class) {
|
||||
runtime.setActivityDelegate((ActivityDelegate) delegate);
|
||||
} else if (cls == GeckoRuntime.Delegate.class) {
|
||||
runtime.setDelegate((GeckoRuntime.Delegate) delegate);
|
||||
} else if (cls == ServiceWorkerDelegate.class) {
|
||||
runtime.setServiceWorkerDelegate((ServiceWorkerDelegate) delegate);
|
||||
} else if (cls == WebNotificationDelegate.class) {
|
||||
runtime.setWebNotificationDelegate((WebNotificationDelegate) delegate);
|
||||
} else if (cls == WebExtensionController.PromptDelegate.class) {
|
||||
runtime.getWebExtensionController()
|
||||
.setPromptDelegate((WebExtensionController.PromptDelegate) delegate);
|
||||
} else if (cls == WebPushDelegate.class) {
|
||||
runtime.getWebPushController().setDelegate((WebPushDelegate) delegate);
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown runtime delegate " + cls.getName());
|
||||
if (cls == ContentBlocking.Delegate.class) {
|
||||
return GeckoSession.class.getMethod("setContentBlockingDelegate", cls)
|
||||
.invoke(session, delegate);
|
||||
}
|
||||
}
|
||||
|
||||
protected static Object getRuntimeDelegate(final @NonNull Class<?> cls,
|
||||
final @NonNull GeckoRuntime runtime) {
|
||||
if (cls == Autocomplete.StorageDelegate.class) {
|
||||
return runtime.getAutocompleteStorageDelegate();
|
||||
} else if (cls == ActivityDelegate.class) {
|
||||
return runtime.getActivityDelegate();
|
||||
} else if (cls == GeckoRuntime.Delegate.class) {
|
||||
return runtime.getDelegate();
|
||||
} else if (cls == ServiceWorkerDelegate.class) {
|
||||
return runtime.getServiceWorkerDelegate();
|
||||
} else if (cls == WebNotificationDelegate.class) {
|
||||
return runtime.getWebNotificationDelegate();
|
||||
} else if (cls == WebExtensionController.PromptDelegate.class) {
|
||||
return runtime.getWebExtensionController().getPromptDelegate();
|
||||
} else if (cls == WebPushDelegate.class) {
|
||||
return runtime.getWebPushController().getDelegate();
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown runtime delegate " + cls.getName());
|
||||
if (cls == Autofill.Delegate.class) {
|
||||
return GeckoSession.class.getMethod("setAutofillDelegate", cls)
|
||||
.invoke(session, delegate);
|
||||
}
|
||||
if (cls == MediaSession.Delegate.class) {
|
||||
return GeckoSession.class.getMethod("setMediaSessionDelegate", cls)
|
||||
.invoke(session, delegate);
|
||||
}
|
||||
return GeckoSession.class.getMethod("set" + cls.getSimpleName(), cls)
|
||||
.invoke(session, delegate);
|
||||
}
|
||||
|
||||
protected static Object getDelegate(final @NonNull Class<?> cls,
|
||||
|
@ -1035,9 +938,11 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
final List<ExternalDelegate<?>> waitDelegates = mWaitScopeDelegates.getExternalDelegates();
|
||||
final List<ExternalDelegate<?>> testDelegates = mTestScopeDelegates.getExternalDelegates();
|
||||
|
||||
final Set<Class<?>> set = new HashSet<>(DEFAULT_DELEGATES);
|
||||
set.addAll(DEFAULT_RUNTIME_DELEGATES);
|
||||
if (waitDelegates.isEmpty() && testDelegates.isEmpty()) {
|
||||
return DEFAULT_DELEGATES;
|
||||
}
|
||||
|
||||
final Set<Class<?>> set = new HashSet<>(DEFAULT_DELEGATES);
|
||||
for (final ExternalDelegate<?> delegate : waitDelegates) {
|
||||
set.add(delegate.delegate);
|
||||
}
|
||||
|
@ -1048,9 +953,15 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
}
|
||||
|
||||
private void addNullDelegate(final Class<?> delegate) {
|
||||
assertThat("Null-delegate must be valid interface class",
|
||||
delegate, either(isIn(DEFAULT_DELEGATES)).or(isIn(DEFAULT_RUNTIME_DELEGATES)));
|
||||
mNullDelegates.add(delegate);
|
||||
if (!Callbacks.class.equals(delegate.getDeclaringClass())) {
|
||||
assertThat("Null-delegate must be valid interface class",
|
||||
delegate, isIn(DEFAULT_DELEGATES));
|
||||
mNullDelegates.add(delegate);
|
||||
return;
|
||||
}
|
||||
for (final Class<?> ifce : delegate.getInterfaces()) {
|
||||
addNullDelegate(ifce);
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyAnnotations(final Collection<Annotation> annotations,
|
||||
|
@ -1133,18 +1044,16 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
ignore = mCallRecordHandler.handleCall(method, args);
|
||||
}
|
||||
|
||||
final boolean isDefaultDelegate =
|
||||
DEFAULT_DELEGATES.contains(method.getDeclaringClass());
|
||||
final boolean isDefaultRuntimeDelegate =
|
||||
DEFAULT_RUNTIME_DELEGATES.contains(method.getDeclaringClass());
|
||||
final boolean isExternalDelegate =
|
||||
!DEFAULT_DELEGATES.contains(method.getDeclaringClass());
|
||||
|
||||
if (!ignore) {
|
||||
if (isDefaultDelegate) {
|
||||
if (!isExternalDelegate) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
}
|
||||
|
||||
final GeckoSession session;
|
||||
if (!isDefaultDelegate) {
|
||||
if (isExternalDelegate) {
|
||||
session = null;
|
||||
} else {
|
||||
assertThat("Callback first argument must be session object",
|
||||
|
@ -1170,7 +1079,7 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
call = testDelegates.prepareMethodCall(session, method);
|
||||
}
|
||||
|
||||
if (!isDefaultDelegate && !isDefaultRuntimeDelegate) {
|
||||
if (isExternalDelegate) {
|
||||
assertThat("External delegate should be registered",
|
||||
call, notNullValue());
|
||||
}
|
||||
|
@ -1179,11 +1088,8 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
Object returnValue = null;
|
||||
try {
|
||||
mCurrentMethodCall = call;
|
||||
if (call != null && call.target != null) {
|
||||
returnValue = method.invoke(call.target, args);
|
||||
} else {
|
||||
returnValue = method.invoke(DEFAULT_IMPL, args);
|
||||
}
|
||||
returnValue = method.invoke((call != null) ? call.target
|
||||
: Callbacks.Default.INSTANCE, args);
|
||||
} catch (final IllegalAccessException | InvocationTargetException e) {
|
||||
throw unwrapRuntimeException(e);
|
||||
} finally {
|
||||
|
@ -1194,18 +1100,14 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
}
|
||||
};
|
||||
|
||||
final Set<Class<?>> delegates = new HashSet<>();
|
||||
delegates.addAll(DEFAULT_DELEGATES);
|
||||
delegates.addAll(DEFAULT_RUNTIME_DELEGATES);
|
||||
final Class<?>[] classes = delegates.toArray(
|
||||
new Class<?>[delegates.size()]);
|
||||
final Class<?>[] classes = DEFAULT_DELEGATES.toArray(
|
||||
new Class<?>[DEFAULT_DELEGATES.size()]);
|
||||
mCallbackProxy = Proxy.newProxyInstance(GeckoSession.class.getClassLoader(),
|
||||
classes, recorder);
|
||||
mAllDelegates = new HashSet<>(delegates);
|
||||
mAllDelegates = new HashSet<>(DEFAULT_DELEGATES);
|
||||
|
||||
mMainSession = new GeckoSession(settings);
|
||||
prepareSession(mMainSession);
|
||||
prepareRuntime(getRuntime());
|
||||
|
||||
if (mDisplaySize != null) {
|
||||
addDisplay(mMainSession, mDisplaySize.x, mDisplaySize.y);
|
||||
|
@ -1222,15 +1124,6 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
}
|
||||
}
|
||||
|
||||
protected void prepareRuntime(final GeckoRuntime runtime) {
|
||||
UiThreadUtils.waitForCondition(() ->
|
||||
RuntimeCreator.sTestSupport.get() != RuntimeCreator.TEST_SUPPORT_INITIAL,
|
||||
env.getDefaultTimeoutMillis());
|
||||
for (final Class<?> cls : DEFAULT_RUNTIME_DELEGATES) {
|
||||
setRuntimeDelegate(cls, runtime, mNullDelegates.contains(cls) ? null : mCallbackProxy);
|
||||
}
|
||||
}
|
||||
|
||||
protected void prepareSession(final GeckoSession session) {
|
||||
UiThreadUtils.waitForCondition(() ->
|
||||
RuntimeCreator.sTestSupport.get() != RuntimeCreator.TEST_SUPPORT_INITIAL,
|
||||
|
@ -1318,12 +1211,6 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
mTestScopeDelegates.clearAndAssert();
|
||||
}
|
||||
|
||||
protected void cleanupRuntime(final GeckoRuntime runtime) {
|
||||
for (final Class<?> cls : DEFAULT_RUNTIME_DELEGATES) {
|
||||
setRuntimeDelegate(cls, runtime, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void cleanupSession(final GeckoSession session) {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
|
@ -1370,7 +1257,6 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
cleanupSession(session);
|
||||
}
|
||||
|
||||
cleanupRuntime(getRuntime());
|
||||
cleanupSession(mMainSession);
|
||||
cleanupExtensions();
|
||||
|
||||
|
@ -1638,7 +1524,7 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
isSessionCallback = true;
|
||||
}
|
||||
|
||||
assertThat("Delegate should implement a GeckoSession, GeckoRuntime delegate " +
|
||||
assertThat("Delegate should implement a GeckoSession delegate " +
|
||||
"or registered external delegate",
|
||||
isSessionCallback, equalTo(true));
|
||||
|
||||
|
@ -1676,17 +1562,6 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
callback, sameInstance(mCallbackProxy));
|
||||
}
|
||||
|
||||
for (final Class<?> ifce : DEFAULT_RUNTIME_DELEGATES) {
|
||||
final Object callback = getRuntimeDelegate(ifce, getRuntime());
|
||||
if (mNullDelegates.contains(ifce)) {
|
||||
// Null-delegates are initially null but are allowed to be any value.
|
||||
continue;
|
||||
}
|
||||
assertThat(ifce.getSimpleName() + " callbacks should be " +
|
||||
"accessed through GeckoSessionTestRule delegate methods",
|
||||
callback, sameInstance(mCallbackProxy));
|
||||
}
|
||||
|
||||
if (methodCalls.isEmpty()) {
|
||||
// Waiting for any call on `delegate`; make sure it doesn't contain any null-delegates.
|
||||
for (final Class<?> ifce : mNullDelegates) {
|
||||
|
@ -1821,11 +1696,9 @@ public class GeckoSessionTestRule implements TestRule {
|
|||
|
||||
for (int index = mLastWaitStart; index < mLastWaitEnd; index++) {
|
||||
final CallRecord record = mCallRecords.get(index);
|
||||
|
||||
if (!record.method.getDeclaringClass().isInstance(callback) ||
|
||||
(session != null &&
|
||||
DEFAULT_DELEGATES.contains(record.method.getDeclaringClass())
|
||||
&& !session.equals(record.args[0]))) {
|
||||
(session != null && DEFAULT_DELEGATES.contains(
|
||||
record.method.getDeclaringClass()) && !session.equals(record.args[0]))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.geckoview.test.util
|
||||
|
||||
import org.mozilla.geckoview.AllowOrDeny
|
||||
import org.mozilla.geckoview.Autofill
|
||||
import org.mozilla.geckoview.ContentBlocking
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.GeckoSession.ContentDelegate.ContextElement
|
||||
import org.mozilla.geckoview.GeckoSession.NavigationDelegate.LoadRequest
|
||||
import org.mozilla.geckoview.MediaSession
|
||||
import org.mozilla.geckoview.WebRequestError
|
||||
|
||||
import android.view.inputmethod.CursorAnchorInfo
|
||||
import android.view.inputmethod.ExtractedText
|
||||
import android.view.inputmethod.ExtractedTextRequest
|
||||
import org.json.JSONObject
|
||||
|
||||
class Callbacks private constructor() {
|
||||
object Default : All
|
||||
|
||||
interface All : AutofillDelegate, ContentBlockingDelegate, ContentDelegate,
|
||||
HistoryDelegate, MediaDelegate, MediaSessionDelegate,
|
||||
NavigationDelegate, PermissionDelegate, ProgressDelegate,
|
||||
PromptDelegate, ScrollDelegate, SelectionActionDelegate,
|
||||
TextInputDelegate
|
||||
|
||||
interface AutofillDelegate : Autofill.Delegate {}
|
||||
interface ContentDelegate : GeckoSession.ContentDelegate {}
|
||||
interface NavigationDelegate : GeckoSession.NavigationDelegate {}
|
||||
interface PermissionDelegate : GeckoSession.PermissionDelegate {}
|
||||
interface ProgressDelegate : GeckoSession.ProgressDelegate {}
|
||||
interface PromptDelegate : GeckoSession.PromptDelegate {}
|
||||
interface ScrollDelegate : GeckoSession.ScrollDelegate {}
|
||||
interface ContentBlockingDelegate : ContentBlocking.Delegate {}
|
||||
interface SelectionActionDelegate : GeckoSession.SelectionActionDelegate {}
|
||||
@Suppress("DEPRECATION")
|
||||
interface MediaDelegate: GeckoSession.MediaDelegate {}
|
||||
interface HistoryDelegate : GeckoSession.HistoryDelegate {}
|
||||
interface MediaSessionDelegate: MediaSession.Delegate {}
|
||||
|
||||
interface TextInputDelegate : GeckoSession.TextInputDelegate {
|
||||
override fun restartInput(session: GeckoSession, reason: Int) {
|
||||
}
|
||||
|
||||
override fun showSoftInput(session: GeckoSession) {
|
||||
}
|
||||
|
||||
override fun hideSoftInput(session: GeckoSession) {
|
||||
}
|
||||
|
||||
override fun updateSelection(session: GeckoSession, selStart: Int, selEnd: Int, compositionStart: Int, compositionEnd: Int) {
|
||||
}
|
||||
|
||||
override fun updateExtractedText(session: GeckoSession, request: ExtractedTextRequest, text: ExtractedText) {
|
||||
}
|
||||
|
||||
override fun updateCursorAnchorInfo(session: GeckoSession, info: CursorAnchorInfo) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -642,17 +642,6 @@ public final class GeckoRuntime implements Parcelable {
|
|||
mServiceWorkerDelegate = serviceWorkerDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link ServiceWorkerDelegate} to be used for Service Worker requests.
|
||||
*
|
||||
* @return the {@link ServiceWorkerDelegate} instance set by {@link #setServiceWorkerDelegate}
|
||||
*/
|
||||
@UiThread
|
||||
@Nullable
|
||||
public ServiceWorkerDelegate getServiceWorkerDelegate() {
|
||||
return mServiceWorkerDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the delegate to be used for handling Web Notifications.
|
||||
*
|
||||
|
|
|
@ -1117,7 +1117,6 @@ public class GeckoSession {
|
|||
getEventDispatcher().registerUiThreadListener(this,
|
||||
"GeckoView:PinOnScreen",
|
||||
"GeckoView:Prompt",
|
||||
"GeckoView:Prompt:Dismiss",
|
||||
null);
|
||||
}
|
||||
|
||||
|
@ -1131,16 +1130,11 @@ public class GeckoSession {
|
|||
if ("GeckoView:PinOnScreen".equals(event)) {
|
||||
GeckoSession.this.setShouldPinOnScreen(message.getBoolean("pinned"));
|
||||
} else if ("GeckoView:Prompt".equals(event)) {
|
||||
mPromptController.handleEvent(
|
||||
GeckoSession.this, message, callback);
|
||||
} else if ("GeckoView:Prompt:Dismiss".equals(event)) {
|
||||
mPromptController.dismissPrompt(message.getString("id"));
|
||||
handlePromptEvent(GeckoSession.this, message, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final PromptController mPromptController;
|
||||
|
||||
protected @Nullable Window mWindow;
|
||||
private GeckoSessionSettings mSettings;
|
||||
|
||||
|
@ -1155,7 +1149,6 @@ public class GeckoSession {
|
|||
mListener.registerListeners();
|
||||
|
||||
mWebExtensionController = new WebExtension.SessionController(this);
|
||||
mPromptController = new PromptController();
|
||||
|
||||
mAutofillSupport = new Autofill.Support(this);
|
||||
mAutofillSupport.registerListeners();
|
||||
|
@ -2596,6 +2589,291 @@ public class GeckoSession {
|
|||
return mSelectionActionDelegate.getDelegate();
|
||||
}
|
||||
|
||||
/* package */ static void handlePromptEvent(final GeckoSession session,
|
||||
final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
final PromptDelegate delegate = session.getPromptDelegate();
|
||||
if (delegate == null) {
|
||||
// Default behavior is same as calling dismiss() on callback.
|
||||
callback.sendSuccess(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final String type = message.getString("type");
|
||||
final String mode = message.getString("mode");
|
||||
final String title = message.getString("title");
|
||||
final String msg = message.getString("msg");
|
||||
GeckoResult<PromptDelegate.PromptResponse> res = null;
|
||||
|
||||
switch (type) {
|
||||
case "alert": {
|
||||
final PromptDelegate.AlertPrompt prompt =
|
||||
new PromptDelegate.AlertPrompt(title, msg);
|
||||
res = delegate.onAlertPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "beforeUnload": {
|
||||
final PromptDelegate.BeforeUnloadPrompt prompt =
|
||||
new PromptDelegate.BeforeUnloadPrompt();
|
||||
res = delegate.onBeforeUnloadPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "repost": {
|
||||
final PromptDelegate.RepostConfirmPrompt prompt =
|
||||
new PromptDelegate.RepostConfirmPrompt();
|
||||
res = delegate.onRepostConfirmPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "button": {
|
||||
final PromptDelegate.ButtonPrompt prompt =
|
||||
new PromptDelegate.ButtonPrompt(title, msg);
|
||||
res = delegate.onButtonPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "text": {
|
||||
final String defaultValue = message.getString("value");
|
||||
final PromptDelegate.TextPrompt prompt =
|
||||
new PromptDelegate.TextPrompt(title, msg, defaultValue);
|
||||
res = delegate.onTextPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "auth": {
|
||||
final PromptDelegate.AuthPrompt.AuthOptions authOptions =
|
||||
new PromptDelegate.AuthPrompt.AuthOptions(message.getBundle("options"));
|
||||
final PromptDelegate.AuthPrompt prompt =
|
||||
new PromptDelegate.AuthPrompt(title, msg, authOptions);
|
||||
res = delegate.onAuthPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "choice": {
|
||||
final int intMode;
|
||||
if ("menu".equals(mode)) {
|
||||
intMode = PromptDelegate.ChoicePrompt.Type.MENU;
|
||||
} else if ("single".equals(mode)) {
|
||||
intMode = PromptDelegate.ChoicePrompt.Type.SINGLE;
|
||||
} else if ("multiple".equals(mode)) {
|
||||
intMode = PromptDelegate.ChoicePrompt.Type.MULTIPLE;
|
||||
} else {
|
||||
callback.sendError("Invalid mode");
|
||||
return;
|
||||
}
|
||||
|
||||
final GeckoBundle[] choiceBundles = message.getBundleArray("choices");
|
||||
final PromptDelegate.ChoicePrompt.Choice[] choices;
|
||||
if (choiceBundles == null || choiceBundles.length == 0) {
|
||||
choices = new PromptDelegate.ChoicePrompt.Choice[0];
|
||||
} else {
|
||||
choices = new PromptDelegate.ChoicePrompt.Choice[choiceBundles.length];
|
||||
for (int i = 0; i < choiceBundles.length; i++) {
|
||||
choices[i] = new PromptDelegate.ChoicePrompt.Choice(choiceBundles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
final PromptDelegate.ChoicePrompt prompt =
|
||||
new PromptDelegate.ChoicePrompt(title, msg, intMode, choices);
|
||||
res = delegate.onChoicePrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "color": {
|
||||
final String defaultValue = message.getString("value");
|
||||
final PromptDelegate.ColorPrompt prompt =
|
||||
new PromptDelegate.ColorPrompt(title, defaultValue);
|
||||
res = delegate.onColorPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "datetime": {
|
||||
final int intMode;
|
||||
if ("date".equals(mode)) {
|
||||
intMode = PromptDelegate.DateTimePrompt.Type.DATE;
|
||||
} else if ("month".equals(mode)) {
|
||||
intMode = PromptDelegate.DateTimePrompt.Type.MONTH;
|
||||
} else if ("week".equals(mode)) {
|
||||
intMode = PromptDelegate.DateTimePrompt.Type.WEEK;
|
||||
} else if ("time".equals(mode)) {
|
||||
intMode = PromptDelegate.DateTimePrompt.Type.TIME;
|
||||
} else if ("datetime-local".equals(mode)) {
|
||||
intMode = PromptDelegate.DateTimePrompt.Type.DATETIME_LOCAL;
|
||||
} else {
|
||||
callback.sendError("Invalid mode");
|
||||
return;
|
||||
}
|
||||
|
||||
final String defaultValue = message.getString("value");
|
||||
final String minValue = message.getString("min");
|
||||
final String maxValue = message.getString("max");
|
||||
final PromptDelegate.DateTimePrompt prompt =
|
||||
new PromptDelegate.DateTimePrompt(title, intMode, defaultValue, minValue, maxValue);
|
||||
res = delegate.onDateTimePrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "file": {
|
||||
final int intMode;
|
||||
if ("single".equals(mode)) {
|
||||
intMode = PromptDelegate.FilePrompt.Type.SINGLE;
|
||||
} else if ("multiple".equals(mode)) {
|
||||
intMode = PromptDelegate.FilePrompt.Type.MULTIPLE;
|
||||
} else {
|
||||
callback.sendError("Invalid mode");
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] mimeTypes = message.getStringArray("mimeTypes");
|
||||
final int capture = message.getInt("capture");
|
||||
final PromptDelegate.FilePrompt prompt =
|
||||
new PromptDelegate.FilePrompt(title, intMode, capture, mimeTypes);
|
||||
res = delegate.onFilePrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "popup": {
|
||||
final String targetUri = message.getString("targetUri");
|
||||
final PromptDelegate.PopupPrompt prompt =
|
||||
new PromptDelegate.PopupPrompt(targetUri);
|
||||
res = delegate.onPopupPrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "share": {
|
||||
final String text = message.getString("text");
|
||||
final String uri = message.getString("uri");
|
||||
final PromptDelegate.SharePrompt prompt =
|
||||
new PromptDelegate.SharePrompt(title, text, uri);
|
||||
res = delegate.onSharePrompt(session, prompt);
|
||||
break;
|
||||
}
|
||||
case "Autocomplete:Save:Login": {
|
||||
final int hint = message.getInt("hint");
|
||||
final GeckoBundle[] loginBundles =
|
||||
message.getBundleArray("logins");
|
||||
|
||||
if (loginBundles == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
final Autocomplete.LoginSaveOption[] options =
|
||||
new Autocomplete.LoginSaveOption[loginBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = new Autocomplete.LoginSaveOption(
|
||||
new Autocomplete.LoginEntry(loginBundles[i]),
|
||||
hint);
|
||||
}
|
||||
|
||||
final PromptDelegate.AutocompleteRequest
|
||||
<Autocomplete.LoginSaveOption> request =
|
||||
new PromptDelegate.AutocompleteRequest<>(options);
|
||||
|
||||
res = delegate.onLoginSave(session, request);
|
||||
break;
|
||||
}
|
||||
case "Autocomplete:Save:Address": {
|
||||
final int hint = message.getInt("hint");
|
||||
final GeckoBundle[] addressBundles =
|
||||
message.getBundleArray("addresses");
|
||||
|
||||
if (addressBundles == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
final Autocomplete.AddressSaveOption[] options =
|
||||
new Autocomplete.AddressSaveOption[addressBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = new Autocomplete.AddressSaveOption(
|
||||
new Autocomplete.Address(addressBundles[i]),
|
||||
hint);
|
||||
}
|
||||
|
||||
final PromptDelegate.AutocompleteRequest
|
||||
<Autocomplete.AddressSaveOption> request =
|
||||
new PromptDelegate.AutocompleteRequest<>(options);
|
||||
|
||||
res = delegate.onAddressSave(session, request);
|
||||
break;
|
||||
}
|
||||
case "Autocomplete:Select:Login": {
|
||||
final GeckoBundle[] optionBundles =
|
||||
message.getBundleArray("options");
|
||||
|
||||
if (optionBundles == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
final Autocomplete.LoginSelectOption[] options =
|
||||
new Autocomplete.LoginSelectOption[optionBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = Autocomplete.LoginSelectOption.fromBundle(
|
||||
optionBundles[i]);
|
||||
}
|
||||
|
||||
final PromptDelegate.AutocompleteRequest
|
||||
<Autocomplete.LoginSelectOption> request =
|
||||
new PromptDelegate.AutocompleteRequest<>(options);
|
||||
|
||||
res = delegate.onLoginSelect(session, request);
|
||||
break;
|
||||
}
|
||||
case "Autocomplete:Select:CreditCard": {
|
||||
final GeckoBundle[] optionBundles =
|
||||
message.getBundleArray("options");
|
||||
|
||||
if (optionBundles == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
final Autocomplete.CreditCardSelectOption[] options =
|
||||
new Autocomplete.CreditCardSelectOption[optionBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = Autocomplete.CreditCardSelectOption.fromBundle(
|
||||
optionBundles[i]);
|
||||
}
|
||||
|
||||
final PromptDelegate.AutocompleteRequest
|
||||
<Autocomplete.CreditCardSelectOption> request =
|
||||
new PromptDelegate.AutocompleteRequest<>(options);
|
||||
|
||||
res = delegate.onCreditCardSelect(session, request);
|
||||
break;
|
||||
}
|
||||
case "Autocomplete:Select:Address": {
|
||||
final GeckoBundle[] optionBundles =
|
||||
message.getBundleArray("options");
|
||||
|
||||
if (optionBundles == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
final Autocomplete.AddressSelectOption[] options =
|
||||
new Autocomplete.AddressSelectOption[optionBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = Autocomplete.AddressSelectOption.fromBundle(
|
||||
optionBundles[i]);
|
||||
}
|
||||
|
||||
final PromptDelegate.AutocompleteRequest
|
||||
<Autocomplete.AddressSelectOption> request =
|
||||
new PromptDelegate.AutocompleteRequest<>(options);
|
||||
|
||||
res = delegate.onAddressSelect(session, request);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
callback.sendError("Invalid type");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (res == null) {
|
||||
// Adhere to default behavior if the delegate returns null.
|
||||
callback.sendSuccess(null);
|
||||
} else {
|
||||
res.accept(value -> {
|
||||
value.dispatch(callback);
|
||||
}, exception -> callback.sendError("Failed to get prompt response."));
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
protected void setShouldPinOnScreen(final boolean pinned) {
|
||||
if (DEBUG) {
|
||||
|
@ -3637,57 +3915,21 @@ public class GeckoSession {
|
|||
}
|
||||
}
|
||||
|
||||
interface PromptInstanceDelegate {
|
||||
/**
|
||||
* Called when this prompt has been dismissed by the system.
|
||||
*
|
||||
* This can happen e.g. when the page navigates away and the content of the prompt
|
||||
* is not relevant anymore.
|
||||
*
|
||||
* When this method is called, you should hide the prompt UI elements.
|
||||
*
|
||||
* @param prompt the prompt that should be dismissed.
|
||||
*/
|
||||
@UiThread
|
||||
default void onPromptDismiss(final @NonNull BasePrompt prompt) {}
|
||||
}
|
||||
|
||||
// Prompt classes.
|
||||
public class BasePrompt {
|
||||
private boolean mIsCompleted;
|
||||
private boolean mIsConfirmed;
|
||||
private GeckoBundle mResult;
|
||||
private final WeakReference<Observer> mObserver;
|
||||
private PromptInstanceDelegate mDelegate;
|
||||
|
||||
protected interface Observer {
|
||||
@AnyThread
|
||||
default void onPromptCompleted(@NonNull BasePrompt prompt) {}
|
||||
}
|
||||
|
||||
private void complete() {
|
||||
mIsCompleted = true;
|
||||
final Observer observer = mObserver.get();
|
||||
if (observer != null) {
|
||||
observer.onPromptCompleted(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The title of this prompt; may be null.
|
||||
*/
|
||||
public final @Nullable String title;
|
||||
/* package */ String id;
|
||||
|
||||
private BasePrompt(
|
||||
@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
final Observer observer) {
|
||||
private BasePrompt(@Nullable final String title) {
|
||||
this.title = title;
|
||||
this.id = id;
|
||||
mIsConfirmed = false;
|
||||
mIsCompleted = false;
|
||||
mObserver = new WeakReference<>(observer);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
@ -3696,8 +3938,8 @@ public class GeckoSession {
|
|||
throw new RuntimeException("Cannot confirm/dismiss a Prompt twice.");
|
||||
}
|
||||
|
||||
mIsCompleted = true;
|
||||
mIsConfirmed = true;
|
||||
complete();
|
||||
return new PromptResponse(this);
|
||||
}
|
||||
|
||||
|
@ -3714,31 +3956,10 @@ public class GeckoSession {
|
|||
throw new RuntimeException("Cannot confirm/dismiss a Prompt twice.");
|
||||
}
|
||||
|
||||
complete();
|
||||
mIsCompleted = true;
|
||||
return new PromptResponse(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the delegate for this prompt.
|
||||
*
|
||||
* @param delegate the {@link PromptInstanceDelegate} instance.
|
||||
*/
|
||||
@UiThread
|
||||
public void setDelegate(final @Nullable PromptInstanceDelegate delegate) {
|
||||
mDelegate = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the delegate for this prompt.
|
||||
*
|
||||
* @return the {@link PromptInstanceDelegate} instance.
|
||||
*/
|
||||
@UiThread
|
||||
@Nullable
|
||||
public PromptInstanceDelegate getDelegate() {
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
/* package */ GeckoBundle ensureResult() {
|
||||
if (mResult == null) {
|
||||
// Usually result object contains two items.
|
||||
|
@ -3776,10 +3997,8 @@ public class GeckoSession {
|
|||
* See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
|
||||
*/
|
||||
class BeforeUnloadPrompt extends BasePrompt {
|
||||
protected BeforeUnloadPrompt(
|
||||
@NonNull final String id,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, null, observer);
|
||||
protected BeforeUnloadPrompt() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3802,10 +4021,8 @@ public class GeckoSession {
|
|||
* needs to resubmit POST data (e.g. due to page refresh).
|
||||
*/
|
||||
class RepostConfirmPrompt extends BasePrompt {
|
||||
protected RepostConfirmPrompt(
|
||||
@NonNull final String id,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, null, observer);
|
||||
protected RepostConfirmPrompt() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3834,11 +4051,9 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @Nullable String message;
|
||||
|
||||
protected AlertPrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
@Nullable final String message,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
protected AlertPrompt(@Nullable final String title,
|
||||
@Nullable final String message) {
|
||||
super(title);
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
@ -3871,11 +4086,9 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @Nullable String message;
|
||||
|
||||
protected ButtonPrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
@Nullable final String message,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
protected ButtonPrompt(@Nullable final String title,
|
||||
@Nullable final String message) {
|
||||
super(title);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
@ -3910,12 +4123,10 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @Nullable String defaultValue;
|
||||
|
||||
protected TextPrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
protected TextPrompt(@Nullable final String title,
|
||||
@Nullable final String message,
|
||||
@Nullable final String defaultValue,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
@Nullable final String defaultValue) {
|
||||
super(title);
|
||||
this.message = message;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
@ -4054,12 +4265,10 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @NonNull AuthOptions authOptions;
|
||||
|
||||
protected AuthPrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
protected AuthPrompt(@Nullable final String title,
|
||||
@Nullable final String message,
|
||||
@NonNull final AuthOptions authOptions,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
@NonNull final AuthOptions authOptions) {
|
||||
super(title);
|
||||
this.message = message;
|
||||
this.authOptions = authOptions;
|
||||
}
|
||||
|
@ -4212,13 +4421,11 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @NonNull Choice[] choices;
|
||||
|
||||
protected ChoicePrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
protected ChoicePrompt(@Nullable final String title,
|
||||
@Nullable final String message,
|
||||
@ChoiceType final int type,
|
||||
@NonNull final Choice[] choices,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
@NonNull final Choice[] choices) {
|
||||
super(title);
|
||||
this.message = message;
|
||||
this.type = type;
|
||||
this.choices = choices;
|
||||
|
@ -4306,11 +4513,9 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @Nullable String defaultValue;
|
||||
|
||||
protected ColorPrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
@Nullable final String defaultValue,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
protected ColorPrompt(@Nullable final String title,
|
||||
@Nullable final String defaultValue) {
|
||||
super(title);
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
@ -4387,14 +4592,12 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @Nullable String maxValue;
|
||||
|
||||
protected DateTimePrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
protected DateTimePrompt(@Nullable final String title,
|
||||
@DatetimeType final int type,
|
||||
@Nullable final String defaultValue,
|
||||
@Nullable final String minValue,
|
||||
@Nullable final String maxValue,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
@Nullable final String maxValue) {
|
||||
super(title);
|
||||
this.type = type;
|
||||
this.defaultValue = defaultValue;
|
||||
this.minValue = minValue;
|
||||
|
@ -4490,13 +4693,11 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @CaptureType int capture;
|
||||
|
||||
protected FilePrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
protected FilePrompt(@Nullable final String title,
|
||||
@FileType final int type,
|
||||
@CaptureType final int capture,
|
||||
@Nullable final String[] mimeTypes,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
@Nullable final String[] mimeTypes) {
|
||||
super(title);
|
||||
this.type = type;
|
||||
this.capture = capture;
|
||||
this.mimeTypes = mimeTypes;
|
||||
|
@ -4589,11 +4790,8 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @Nullable String targetUri;
|
||||
|
||||
protected PopupPrompt(
|
||||
@NonNull final String id,
|
||||
@Nullable final String targetUri,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, null, observer);
|
||||
protected PopupPrompt(@Nullable final String targetUri) {
|
||||
super(null);
|
||||
this.targetUri = targetUri;
|
||||
}
|
||||
|
||||
|
@ -4656,12 +4854,10 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @Nullable String uri;
|
||||
|
||||
protected SharePrompt(@NonNull final String id,
|
||||
@Nullable final String title,
|
||||
protected SharePrompt(@Nullable final String title,
|
||||
@Nullable final String text,
|
||||
@Nullable final String uri,
|
||||
@NonNull final Observer observer) {
|
||||
super(id, title, observer);
|
||||
@Nullable final String uri) {
|
||||
super(title);
|
||||
this.text = text;
|
||||
this.uri = uri;
|
||||
}
|
||||
|
@ -4706,10 +4902,8 @@ public class GeckoSession {
|
|||
*/
|
||||
public final @NonNull T[] options;
|
||||
|
||||
protected AutocompleteRequest(final @NonNull String id,
|
||||
final @NonNull T[] options,
|
||||
final Observer observer) {
|
||||
super(id, null, observer);
|
||||
protected AutocompleteRequest(final @NonNull T[] options) {
|
||||
super(null);
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
|
@ -5076,6 +5270,7 @@ public class GeckoSession {
|
|||
request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,624 +0,0 @@
|
|||
package org.mozilla.geckoview;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
|
||||
import org.mozilla.geckoview.Autocomplete.AddressSaveOption;
|
||||
import org.mozilla.geckoview.Autocomplete.AddressSelectOption;
|
||||
import org.mozilla.geckoview.Autocomplete.CreditCardSelectOption;
|
||||
import org.mozilla.geckoview.Autocomplete.LoginSaveOption;
|
||||
import org.mozilla.geckoview.Autocomplete.LoginSelectOption;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.AutocompleteRequest;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.AuthPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.AlertPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.BeforeUnloadPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.ButtonPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.BasePrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.ChoicePrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.ColorPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.DateTimePrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.FilePrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.PopupPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.PromptResponse;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.PromptInstanceDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.RepostConfirmPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.SharePrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.TextPrompt;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.AuthPrompt.AuthOptions;
|
||||
import org.mozilla.geckoview.GeckoSession.PromptDelegate.BasePrompt.Observer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/* package */ class PromptController {
|
||||
private static final String LOGTAG = "Prompts";
|
||||
|
||||
private static class PromptStorage implements BasePrompt.Observer {
|
||||
private final Map<String, BasePrompt> mPrompts = new HashMap<>();
|
||||
|
||||
public void addPrompt(final String id, final BasePrompt prompt) {
|
||||
if (mPrompts.containsKey(id)) {
|
||||
Log.e(LOGTAG, "Prompt already exists! id=" + id);
|
||||
if (BuildConfig.DEBUG) {
|
||||
throw new RuntimeException("Prompt already exists! id=" + id);
|
||||
}
|
||||
}
|
||||
mPrompts.put(id, prompt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPromptCompleted(final BasePrompt prompt) {
|
||||
// No need to notify this delegate since the prompt has been completed already.
|
||||
mPrompts.remove(prompt.id);
|
||||
}
|
||||
|
||||
public void dismiss(final String id) {
|
||||
final BasePrompt prompt = mPrompts.get(id);
|
||||
if (prompt == null) {
|
||||
return;
|
||||
}
|
||||
final PromptInstanceDelegate delegate = prompt.getDelegate();
|
||||
if (delegate != null) {
|
||||
delegate.onPromptDismiss(prompt);
|
||||
}
|
||||
mPrompts.remove(prompt.id);
|
||||
}
|
||||
}
|
||||
|
||||
final PromptStorage mStorage = new PromptStorage();
|
||||
|
||||
public void dismissPrompt(final String id) {
|
||||
mStorage.dismiss(id);
|
||||
}
|
||||
|
||||
public void handleEvent(final GeckoSession session,
|
||||
final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
final PromptDelegate delegate = session.getPromptDelegate();
|
||||
if (delegate == null) {
|
||||
// Default behavior is same as calling dismiss() on callback.
|
||||
callback.sendSuccess(null);
|
||||
return;
|
||||
}
|
||||
|
||||
final String type = message.getString("type");
|
||||
final PromptHandler<?> handler = sPromptHandlers.handlerFor(type);
|
||||
if (handler == null) {
|
||||
callback.sendError("Invalid type: " + type);
|
||||
return;
|
||||
}
|
||||
final GeckoResult<PromptResponse> res =
|
||||
getResponse(message, session, delegate, handler);
|
||||
|
||||
if (res == null) {
|
||||
// Adhere to default behavior if the delegate returns null.
|
||||
callback.sendSuccess(null);
|
||||
} else {
|
||||
res.accept(
|
||||
value -> value.dispatch(callback),
|
||||
exception -> callback.sendError("Failed to get prompt response."));
|
||||
}
|
||||
}
|
||||
|
||||
private <PromptType extends BasePrompt> GeckoResult<PromptResponse> getResponse(
|
||||
final GeckoBundle message,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate,
|
||||
final PromptHandler<PromptType> handler) {
|
||||
final PromptType prompt = handler.newPrompt(message, mStorage);
|
||||
if (prompt == null) {
|
||||
try {
|
||||
Log.e(LOGTAG, "Invalid prompt: " + message.toJSONObject().toString());
|
||||
} catch (final JSONException ex) {
|
||||
Log.e(LOGTAG, "Invalid prompt, invalid data", ex);
|
||||
}
|
||||
|
||||
return GeckoResult.fromException(
|
||||
new IllegalArgumentException("Invalid prompt data."));
|
||||
}
|
||||
|
||||
mStorage.addPrompt(prompt.id, prompt);
|
||||
return handler.callDelegate(prompt, session, delegate);
|
||||
}
|
||||
|
||||
private interface PromptHandler<PromptType extends BasePrompt> {
|
||||
PromptType newPrompt(GeckoBundle info, Observer observer);
|
||||
GeckoResult<PromptResponse> callDelegate(
|
||||
PromptType prompt, GeckoSession session, PromptDelegate delegate);
|
||||
}
|
||||
|
||||
private static final class AlertHandler implements PromptHandler<AlertPrompt> {
|
||||
@Override
|
||||
public AlertPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new AlertPrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
info.getString("msg"),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final AlertPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onAlertPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class BeforeUnloadHandler implements PromptHandler<BeforeUnloadPrompt> {
|
||||
@Override
|
||||
public BeforeUnloadPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new BeforeUnloadPrompt(
|
||||
info.getString("id"),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final BeforeUnloadPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onBeforeUnloadPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ButtonHandler implements PromptHandler<ButtonPrompt> {
|
||||
@Override
|
||||
public ButtonPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new ButtonPrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
info.getString("msg"),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final ButtonPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onButtonPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TextHandler implements PromptHandler<TextPrompt> {
|
||||
@Override
|
||||
public TextPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new TextPrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
info.getString("msg"),
|
||||
info.getString("value"),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final TextPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onTextPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class AuthHandler implements PromptHandler<AuthPrompt> {
|
||||
@Override
|
||||
public AuthPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new AuthPrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
info.getString("msg"),
|
||||
new AuthOptions(info.getBundle("options")),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final AuthPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onAuthPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ChoiceHandler implements PromptHandler<ChoicePrompt> {
|
||||
@Override
|
||||
public ChoicePrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
final int intMode;
|
||||
final String mode = info.getString("mode");
|
||||
if ("menu".equals(mode)) {
|
||||
intMode = ChoicePrompt.Type.MENU;
|
||||
} else if ("single".equals(mode)) {
|
||||
intMode = ChoicePrompt.Type.SINGLE;
|
||||
} else if ("multiple".equals(mode)) {
|
||||
intMode = ChoicePrompt.Type.MULTIPLE;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
final GeckoBundle[] choiceBundles = info.getBundleArray("choices");
|
||||
final ChoicePrompt.Choice[] choices;
|
||||
if (choiceBundles == null || choiceBundles.length == 0) {
|
||||
choices = new ChoicePrompt.Choice[0];
|
||||
} else {
|
||||
choices = new ChoicePrompt.Choice[choiceBundles.length];
|
||||
for (int i = 0; i < choiceBundles.length; i++) {
|
||||
choices[i] = new ChoicePrompt.Choice(choiceBundles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return new ChoicePrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
info.getString("msg"),
|
||||
intMode, choices,
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final ChoicePrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onChoicePrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ColorHandler implements PromptHandler<ColorPrompt> {
|
||||
@Override
|
||||
public ColorPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new ColorPrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
info.getString("value"),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final ColorPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onColorPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DateTimeHandler implements PromptHandler<DateTimePrompt> {
|
||||
@Override
|
||||
public DateTimePrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
final String mode = info.getString("mode");
|
||||
final int intMode;
|
||||
if ("date".equals(mode)) {
|
||||
intMode = DateTimePrompt.Type.DATE;
|
||||
} else if ("month".equals(mode)) {
|
||||
intMode = DateTimePrompt.Type.MONTH;
|
||||
} else if ("week".equals(mode)) {
|
||||
intMode = DateTimePrompt.Type.WEEK;
|
||||
} else if ("time".equals(mode)) {
|
||||
intMode = DateTimePrompt.Type.TIME;
|
||||
} else if ("datetime-local".equals(mode)) {
|
||||
intMode = DateTimePrompt.Type.DATETIME_LOCAL;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String defaultValue = info.getString("value");
|
||||
final String minValue = info.getString("min");
|
||||
final String maxValue = info.getString("max");
|
||||
return new DateTimePrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
intMode,
|
||||
defaultValue,
|
||||
minValue,
|
||||
maxValue,
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final DateTimePrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onDateTimePrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private final static class FileHandler implements PromptHandler<FilePrompt> {
|
||||
@Override
|
||||
public FilePrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
final String mode = info.getString("mode");
|
||||
final int intMode;
|
||||
if ("single".equals(mode)) {
|
||||
intMode = FilePrompt.Type.SINGLE;
|
||||
} else if ("multiple".equals(mode)) {
|
||||
intMode = FilePrompt.Type.MULTIPLE;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String[] mimeTypes = info.getStringArray("mimeTypes");
|
||||
final int capture = info.getInt("capture");
|
||||
return new FilePrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
intMode,
|
||||
capture,
|
||||
mimeTypes,
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final FilePrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onFilePrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class PopupHandler implements PromptHandler<PopupPrompt> {
|
||||
@Override
|
||||
public PopupPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new PopupPrompt(
|
||||
info.getString("id"),
|
||||
info.getString("targetUri"),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final PopupPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onPopupPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RepostHandler implements PromptHandler<RepostConfirmPrompt> {
|
||||
@Override
|
||||
public RepostConfirmPrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new RepostConfirmPrompt(info.getString("id"), observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final RepostConfirmPrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onRepostConfirmPrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ShareHandler implements PromptHandler<SharePrompt> {
|
||||
@Override
|
||||
public SharePrompt newPrompt(final GeckoBundle info, final Observer observer) {
|
||||
return new SharePrompt(
|
||||
info.getString("id"),
|
||||
info.getString("title"),
|
||||
info.getString("text"),
|
||||
info.getString("uri"),
|
||||
observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final SharePrompt prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onSharePrompt(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final class LoginSaveHandler
|
||||
implements PromptHandler<AutocompleteRequest<LoginSaveOption>> {
|
||||
@Override
|
||||
public AutocompleteRequest<LoginSaveOption> newPrompt(
|
||||
final GeckoBundle info,
|
||||
final Observer observer) {
|
||||
final int hint = info.getInt("hint");
|
||||
final GeckoBundle[] loginBundles =
|
||||
info.getBundleArray("logins");
|
||||
|
||||
if (loginBundles == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Autocomplete.LoginSaveOption[] options =
|
||||
new Autocomplete.LoginSaveOption[loginBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = new Autocomplete.LoginSaveOption(
|
||||
new Autocomplete.LoginEntry(loginBundles[i]),
|
||||
hint);
|
||||
}
|
||||
|
||||
return new AutocompleteRequest<>(info.getString("id"), options, observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final AutocompleteRequest<LoginSaveOption> prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onLoginSave(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class AddressSaveHandler
|
||||
implements PromptHandler<AutocompleteRequest<AddressSaveOption>> {
|
||||
@Override
|
||||
public AutocompleteRequest<AddressSaveOption> newPrompt(
|
||||
final GeckoBundle info,
|
||||
final Observer observer) {
|
||||
final GeckoBundle[] addressBundles =
|
||||
info.getBundleArray("addresses");
|
||||
|
||||
if (addressBundles == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Autocomplete.AddressSaveOption[] options =
|
||||
new Autocomplete.AddressSaveOption[addressBundles.length];
|
||||
|
||||
final int hint = info.getInt("hint");
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = new Autocomplete.AddressSaveOption(
|
||||
new Autocomplete.Address(addressBundles[i]),
|
||||
hint);
|
||||
}
|
||||
|
||||
return new AutocompleteRequest<>(info.getString("id"), options, observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final AutocompleteRequest<AddressSaveOption> prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onAddressSave(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class LoginSelectHandler
|
||||
implements PromptHandler<AutocompleteRequest<LoginSelectOption>> {
|
||||
@Override
|
||||
public AutocompleteRequest<LoginSelectOption> newPrompt(
|
||||
final GeckoBundle info,
|
||||
final Observer observer) {
|
||||
final GeckoBundle[] optionBundles =
|
||||
info.getBundleArray("options");
|
||||
|
||||
if (optionBundles == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Autocomplete.LoginSelectOption[] options =
|
||||
new Autocomplete.LoginSelectOption[optionBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = Autocomplete.LoginSelectOption.fromBundle(
|
||||
optionBundles[i]);
|
||||
}
|
||||
|
||||
return new AutocompleteRequest<>(info.getString("id"), options, observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final AutocompleteRequest<LoginSelectOption> prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onLoginSelect(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class CreditCardSelectHandler
|
||||
implements PromptHandler<AutocompleteRequest<CreditCardSelectOption>> {
|
||||
@Override
|
||||
public AutocompleteRequest<CreditCardSelectOption> newPrompt(
|
||||
final GeckoBundle info,
|
||||
final Observer observer) {
|
||||
final GeckoBundle[] optionBundles =
|
||||
info.getBundleArray("options");
|
||||
|
||||
if (optionBundles == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Autocomplete.CreditCardSelectOption[] options =
|
||||
new Autocomplete.CreditCardSelectOption[optionBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = Autocomplete.CreditCardSelectOption.fromBundle(
|
||||
optionBundles[i]);
|
||||
}
|
||||
|
||||
return new AutocompleteRequest<>(info.getString("id"), options, observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final AutocompleteRequest<CreditCardSelectOption> prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onCreditCardSelect(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class AddressSelectHandler
|
||||
implements PromptHandler<AutocompleteRequest<AddressSelectOption>> {
|
||||
@Override
|
||||
public AutocompleteRequest<AddressSelectOption> newPrompt(
|
||||
final GeckoBundle info,
|
||||
final Observer observer) {
|
||||
final GeckoBundle[] optionBundles =
|
||||
info.getBundleArray("options");
|
||||
|
||||
if (optionBundles == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Autocomplete.AddressSelectOption[] options =
|
||||
new Autocomplete.AddressSelectOption[optionBundles.length];
|
||||
|
||||
for (int i = 0; i < options.length; ++i) {
|
||||
options[i] = Autocomplete.AddressSelectOption.fromBundle(
|
||||
optionBundles[i]);
|
||||
}
|
||||
|
||||
return new AutocompleteRequest<>(info.getString("id"), options, observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeckoResult<PromptResponse> callDelegate(
|
||||
final AutocompleteRequest<AddressSelectOption> prompt,
|
||||
final GeckoSession session,
|
||||
final PromptDelegate delegate) {
|
||||
return delegate.onAddressSelect(session, prompt);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PromptHandlers {
|
||||
final Map<String, PromptHandler<?>> mPromptHandlers = new HashMap<>();
|
||||
|
||||
public void register(final PromptHandler<?> handler, final String type) {
|
||||
mPromptHandlers.put(type, handler);
|
||||
}
|
||||
|
||||
public PromptHandler<?> handlerFor(final String type) {
|
||||
return mPromptHandlers.get(type);
|
||||
}
|
||||
}
|
||||
|
||||
private static final PromptHandlers sPromptHandlers = new PromptHandlers();
|
||||
static {
|
||||
sPromptHandlers.register(new AlertHandler(), "alert");
|
||||
sPromptHandlers.register(new BeforeUnloadHandler(), "beforeUnload");
|
||||
sPromptHandlers.register(new ButtonHandler(), "button");
|
||||
sPromptHandlers.register(new TextHandler(), "text");
|
||||
sPromptHandlers.register(new AuthHandler(), "auth");
|
||||
sPromptHandlers.register(new ChoiceHandler(), "choice");
|
||||
sPromptHandlers.register(new ColorHandler(), "color");
|
||||
sPromptHandlers.register(new DateTimeHandler(), "datetime");
|
||||
sPromptHandlers.register(new FileHandler(), "file");
|
||||
sPromptHandlers.register(new PopupHandler(), "popup");
|
||||
sPromptHandlers.register(new RepostHandler(), "repost");
|
||||
sPromptHandlers.register(new ShareHandler(), "share");
|
||||
sPromptHandlers.register(new LoginSaveHandler(), "Autocomplete:Save:Login");
|
||||
sPromptHandlers.register(new AddressSaveHandler(),
|
||||
"Autocomplete:Save:Address");
|
||||
sPromptHandlers.register(new LoginSelectHandler(),
|
||||
"Autocomplete:Select:Login");
|
||||
sPromptHandlers.register(new CreditCardSelectHandler(),
|
||||
"Autocomplete:Select:CreditCard");
|
||||
sPromptHandlers.register(new AddressSelectHandler(),
|
||||
"Autocomplete:Select:Address");
|
||||
}
|
||||
}
|
|
@ -43,18 +43,6 @@ public class WebPushController {
|
|||
mDelegate = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link WebPushDelegate} for this instance.
|
||||
*
|
||||
* @return delegate The {@link WebPushDelegate} instance.
|
||||
*/
|
||||
@UiThread
|
||||
@Nullable
|
||||
public WebPushDelegate getDelegate() {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a push event for a given subscription.
|
||||
*
|
||||
|
|
|
@ -13,11 +13,6 @@ exclude: true
|
|||
|
||||
⚠️ breaking change and deprecation notices
|
||||
|
||||
## v93
|
||||
- Added [`PromptInstanceDelegate`][93.1] to allow GeckoView to dismiss stale prompts.
|
||||
|
||||
[93.1]: {{javadoc_uri}}/GeckoSession.PromptDelegate.PromptInstanceDelegate.html
|
||||
|
||||
## v92
|
||||
- Added [`GeckoSession.PermissionDelegate.PERMISSION_STORAGE_ACCESS`][92.1] to
|
||||
control the allowing of third-party frames to access first-party cookies and
|
||||
|
@ -1039,4 +1034,4 @@ to allow adding gecko profiler markers.
|
|||
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
|
||||
[65.25]: {{javadoc_uri}}/GeckoResult.html
|
||||
|
||||
[api-version]: d9a16c186a464d66dece49aa5084ee316c7225bf
|
||||
[api-version]: d0ed6375463fed98d5402a30aacb6eee7969079e
|
||||
|
|
|
@ -13,13 +13,6 @@ const { PromptUtils } = ChromeUtils.import(
|
|||
"resource://gre/modules/SharedPromptUtils.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"gPrompterService",
|
||||
"@mozilla.org/login-manager/prompter;1",
|
||||
Ci.nsILoginManagerPrompter
|
||||
);
|
||||
|
||||
/* eslint-disable block-scoped-var, no-var */
|
||||
|
||||
ChromeUtils.defineModuleGetter(
|
||||
|
@ -117,7 +110,6 @@ LoginManagerAuthPromptFactory.prototype = {
|
|||
// This enables us to consolidate auth prompts with the same browser and
|
||||
// hashkey (level, origin, realm).
|
||||
_pendingPrompts: new WeakMap(),
|
||||
_pendingSavePrompts: new WeakMap(),
|
||||
// We use a separate bucket for when we don't have a browser.
|
||||
// _noBrowser -> hashkey -> prompt
|
||||
_noBrowser: {},
|
||||
|
@ -152,15 +144,6 @@ LoginManagerAuthPromptFactory.prototype = {
|
|||
return this._pendingPrompts.get(browser)?.get(hashKey);
|
||||
},
|
||||
|
||||
_dismissPendingSavePrompt(browser) {
|
||||
this._pendingSavePrompts.get(browser)?.dismiss();
|
||||
this._pendingSavePrompts.delete(browser);
|
||||
},
|
||||
|
||||
_setPendingSavePrompt(browser, prompt) {
|
||||
this._pendingSavePrompts.set(browser, prompt);
|
||||
},
|
||||
|
||||
_setPendingPrompt(prompt, hashKey) {
|
||||
let browser = prompt.prompter.browser || this._noBrowser;
|
||||
let hashToPrompt = this._pendingPrompts.get(browser);
|
||||
|
@ -305,6 +288,7 @@ LoginManagerAuthPrompter.prototype = {
|
|||
_factory: null,
|
||||
_chromeWindow: null,
|
||||
_browser: null,
|
||||
_openerBrowser: null,
|
||||
|
||||
__strBundle: null, // String bundle for L10N
|
||||
get _strBundle() {
|
||||
|
@ -634,23 +618,13 @@ LoginManagerAuthPrompter.prototype = {
|
|||
return [formattedOrigin, formattedOrigin + pathname, uri.username];
|
||||
},
|
||||
|
||||
_canPromptToSaveLogin() {
|
||||
// Cannot prompt if we don't have a window
|
||||
if (!this._chromeWindow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Can only prompt if we have the prompter service
|
||||
return !!gPrompterService;
|
||||
},
|
||||
|
||||
async promptAuthInternal(aChannel, aLevel, aAuthInfo) {
|
||||
var selectedLogin = null;
|
||||
var checkbox = { value: false };
|
||||
var checkboxLabel = null;
|
||||
var epicfail = false;
|
||||
var canAutologin = false;
|
||||
var canPromptToSave = this._canPromptToSaveLogin();
|
||||
var notifyObj;
|
||||
var foundLogins;
|
||||
let autofilled = false;
|
||||
|
||||
|
@ -660,12 +634,12 @@ LoginManagerAuthPrompter.prototype = {
|
|||
// If the user submits a login but it fails, we need to remove the
|
||||
// notification prompt that was displayed. Conveniently, the user will
|
||||
// be prompted for authentication again, which brings us here.
|
||||
this._factory._dismissPendingSavePrompt(this._browser);
|
||||
this._removeLoginNotifications();
|
||||
|
||||
var [origin, httpRealm] = this._getAuthTarget(aChannel, aAuthInfo);
|
||||
|
||||
// Looks for existing logins to prefill the prompt with.
|
||||
foundLogins = await Services.logins.searchLoginsAsync({
|
||||
foundLogins = LoginHelper.searchLoginsWithObject({
|
||||
origin,
|
||||
httpRealm,
|
||||
schemeUpgrades: LoginHelper.schemeUpgrades,
|
||||
|
@ -709,9 +683,9 @@ LoginManagerAuthPrompter.prototype = {
|
|||
canRememberLogin = false;
|
||||
}
|
||||
|
||||
if (canRememberLogin && !canPromptToSave) {
|
||||
// If we cannot prompt the user to save the login, we display
|
||||
// a checkbox on the auth prompt instead.
|
||||
// if checkboxLabel is null, the checkbox won't be shown at all.
|
||||
notifyObj = this._getPopupNote();
|
||||
if (canRememberLogin && !notifyObj) {
|
||||
checkboxLabel = this._getLocalizedString("rememberPassword");
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -778,7 +752,7 @@ LoginManagerAuthPrompter.prototype = {
|
|||
// determine if the login should be saved. If there isn't a
|
||||
// notification prompt, only save the login if the user set the
|
||||
// checkbox to do so.
|
||||
var rememberLogin = canPromptToSave ? canRememberLogin : checkbox.value;
|
||||
var rememberLogin = notifyObj ? canRememberLogin : checkbox.value;
|
||||
if (!ok || !rememberLogin || epicfail) {
|
||||
return ok;
|
||||
}
|
||||
|
@ -808,13 +782,17 @@ LoginManagerAuthPrompter.prototype = {
|
|||
")"
|
||||
);
|
||||
|
||||
if (canPromptToSave) {
|
||||
if (notifyObj) {
|
||||
let promptBrowser = LoginHelper.getBrowserForPrompt(browser);
|
||||
let savePrompt = gPrompterService.promptToSavePassword(
|
||||
LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||
promptBrowser,
|
||||
newLogin
|
||||
newLogin,
|
||||
"password-save",
|
||||
{
|
||||
dismissed: this._inPrivateBrowsing,
|
||||
}
|
||||
);
|
||||
this._factory._setPendingSavePrompt(promptBrowser, savePrompt);
|
||||
Services.obs.notifyObservers(newLogin, "passwordmgr-prompt-save");
|
||||
} else {
|
||||
Services.logins.addLogin(newLogin);
|
||||
}
|
||||
|
@ -828,14 +806,8 @@ LoginManagerAuthPrompter.prototype = {
|
|||
httpRealm +
|
||||
")"
|
||||
);
|
||||
if (canPromptToSave) {
|
||||
let promptBrowser = LoginHelper.getBrowserForPrompt(browser);
|
||||
let savePrompt = gPrompterService.promptToChangePassword(
|
||||
promptBrowser,
|
||||
selectedLogin,
|
||||
newLogin
|
||||
);
|
||||
this._factory._setPendingSavePrompt(promptBrowser, savePrompt);
|
||||
if (notifyObj) {
|
||||
this._showChangeLoginNotification(browser, selectedLogin, newLogin);
|
||||
} else {
|
||||
this._updateLogin(selectedLogin, newLogin);
|
||||
}
|
||||
|
@ -886,7 +858,7 @@ LoginManagerAuthPrompter.prototype = {
|
|||
// If the user submits a login but it fails, we need to remove the
|
||||
// notification prompt that was displayed. Conveniently, the user will
|
||||
// be prompted for authentication again, which brings us here.
|
||||
this._factory._dismissPendingSavePrompt(this._browser);
|
||||
this._removeLoginNotifications();
|
||||
|
||||
cancelable = this._newAsyncPromptConsumer(aCallback, aContext);
|
||||
|
||||
|
@ -948,6 +920,7 @@ LoginManagerAuthPrompter.prototype = {
|
|||
this._chromeWindow = win;
|
||||
this._browser = browser;
|
||||
}
|
||||
this._openerBrowser = null;
|
||||
this._factory = aFactory || null;
|
||||
|
||||
this.log("===== initialized =====");
|
||||
|
@ -961,6 +934,86 @@ LoginManagerAuthPrompter.prototype = {
|
|||
return this._browser;
|
||||
},
|
||||
|
||||
set openerBrowser(aOpenerBrowser) {
|
||||
this._openerBrowser = aOpenerBrowser;
|
||||
},
|
||||
|
||||
_removeLoginNotifications() {
|
||||
var popupNote = this._getPopupNote();
|
||||
if (popupNote) {
|
||||
popupNote = popupNote.getNotification("password");
|
||||
}
|
||||
if (popupNote) {
|
||||
popupNote.remove();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows the Change Password popup notification.
|
||||
*
|
||||
* @param aBrowser
|
||||
* The relevant <browser>.
|
||||
* @param aOldLogin
|
||||
* The stored login we want to update.
|
||||
* @param aNewLogin
|
||||
* The login object with the changes we want to make.
|
||||
* @param dismissed
|
||||
* A boolean indicating if the prompt should be automatically
|
||||
* dismissed on being shown.
|
||||
* @param notifySaved
|
||||
* A boolean value indicating whether the notification should indicate that
|
||||
* a login has been saved
|
||||
*/
|
||||
_showChangeLoginNotification(
|
||||
aBrowser,
|
||||
aOldLogin,
|
||||
aNewLogin,
|
||||
dismissed = false,
|
||||
notifySaved = false,
|
||||
autoSavedLoginGuid = ""
|
||||
) {
|
||||
let login = aOldLogin.clone();
|
||||
login.origin = aNewLogin.origin;
|
||||
login.formActionOrigin = aNewLogin.formActionOrigin;
|
||||
login.password = aNewLogin.password;
|
||||
login.username = aNewLogin.username;
|
||||
|
||||
let messageStringID;
|
||||
if (
|
||||
aOldLogin.username === "" &&
|
||||
login.username !== "" &&
|
||||
login.password == aOldLogin.password
|
||||
) {
|
||||
// If the saved password matches the password we're prompting with then we
|
||||
// are only prompting to let the user add a username since there was one in
|
||||
// the form. Change the message so the purpose of the prompt is clearer.
|
||||
messageStringID = "updateLoginMsgAddUsername";
|
||||
}
|
||||
|
||||
let promptBrowser = LoginHelper.getBrowserForPrompt(aBrowser);
|
||||
LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||
promptBrowser,
|
||||
login,
|
||||
"password-change",
|
||||
{
|
||||
dismissed,
|
||||
extraAttr: notifySaved ? "attention" : "",
|
||||
},
|
||||
{
|
||||
notifySaved,
|
||||
messageStringID,
|
||||
autoSavedLoginGuid,
|
||||
}
|
||||
);
|
||||
|
||||
let oldGUID = aOldLogin.QueryInterface(Ci.nsILoginMetaInfo).guid;
|
||||
Services.obs.notifyObservers(
|
||||
aNewLogin,
|
||||
"passwordmgr-prompt-change",
|
||||
oldGUID
|
||||
);
|
||||
},
|
||||
|
||||
/* ---------- Internal Methods ---------- */
|
||||
|
||||
_updateLogin(login, aNewLogin) {
|
||||
|
@ -1000,6 +1053,48 @@ LoginManagerAuthPrompter.prototype = {
|
|||
return { win: chromeWin, browser };
|
||||
},
|
||||
|
||||
_getNotifyWindow() {
|
||||
if (this._openerBrowser) {
|
||||
let chromeDoc = this._chromeWindow.document.documentElement;
|
||||
|
||||
// Check to see if the current window was opened with chrome
|
||||
// disabled, and if so use the opener window. But if the window
|
||||
// has been used to visit other pages (ie, has a history),
|
||||
// assume it'll stick around and *don't* use the opener.
|
||||
if (chromeDoc.getAttribute("chromehidden") && !this._browser.canGoBack) {
|
||||
this.log("Using opener window for notification prompt.");
|
||||
return {
|
||||
win: this._openerBrowser.ownerGlobal,
|
||||
browser: this._openerBrowser,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
win: this._chromeWindow,
|
||||
browser: this._browser,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the popup notification to this prompter,
|
||||
* or null if there isn't one available.
|
||||
*/
|
||||
_getPopupNote() {
|
||||
let popupNote = null;
|
||||
|
||||
try {
|
||||
let { win: notifyWin } = this._getNotifyWindow();
|
||||
|
||||
// .wrappedJSObject needed here -- see bug 422974 comment 5.
|
||||
popupNote = notifyWin.wrappedJSObject.PopupNotifications;
|
||||
} catch (e) {
|
||||
this.log("Popup notifications not available on window");
|
||||
}
|
||||
|
||||
return popupNote;
|
||||
},
|
||||
|
||||
/**
|
||||
* The user might enter a login that isn't the one we prefilled, but
|
||||
* is the same as some other existing login. So, pick a login with a
|
||||
|
|
|
@ -138,7 +138,7 @@ class LoginManagerPrompter {
|
|||
) {
|
||||
log.debug("promptToSavePassword");
|
||||
let inPrivateBrowsing = PrivateBrowsingUtils.isBrowserPrivate(aBrowser);
|
||||
let notification = LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||
LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||
aBrowser,
|
||||
aLogin,
|
||||
"password-save",
|
||||
|
@ -153,13 +153,6 @@ class LoginManagerPrompter {
|
|||
}
|
||||
);
|
||||
Services.obs.notifyObservers(aLogin, "passwordmgr-prompt-save");
|
||||
|
||||
return {
|
||||
dismiss() {
|
||||
let { PopupNotifications } = aBrowser.ownerGlobal.wrappedJSObject;
|
||||
PopupNotifications.remove(notification);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -793,8 +786,6 @@ class LoginManagerPrompter {
|
|||
log.debug("Showing the ConfirmationHint");
|
||||
anchor.ownerGlobal.ConfirmationHint.show(anchor, "passwordSaved");
|
||||
}
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -849,7 +840,7 @@ class LoginManagerPrompter {
|
|||
messageStringID = "updateLoginMsgAddUsername2";
|
||||
}
|
||||
|
||||
let notification = LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||
LoginManagerPrompter._showLoginCaptureDoorhanger(
|
||||
aBrowser,
|
||||
login,
|
||||
"password-change",
|
||||
|
@ -872,13 +863,6 @@ class LoginManagerPrompter {
|
|||
"passwordmgr-prompt-change",
|
||||
oldGUID
|
||||
);
|
||||
|
||||
return {
|
||||
dismiss() {
|
||||
let { PopupNotifications } = aBrowser.ownerGlobal.wrappedJSObject;
|
||||
PopupNotifications.remove(notification);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,6 @@ XPIDL_SOURCES += [
|
|||
"nsILoginManagerPrompter.idl",
|
||||
"nsILoginManagerStorage.idl",
|
||||
"nsILoginMetaInfo.idl",
|
||||
"nsIPromptInstance.idl",
|
||||
]
|
||||
|
||||
XPIDL_MODULE = "loginmgr"
|
||||
|
|
|
@ -36,6 +36,13 @@ interface nsILoginManagerAuthPrompter : nsISupports {
|
|||
* This is required if the init function received a chrome window as argument.
|
||||
*/
|
||||
attribute Element browser;
|
||||
|
||||
/**
|
||||
* The opener browser that was used to open the window passed to init.
|
||||
* The opener can be used to determine in which window the prompt
|
||||
* should be shown.
|
||||
*/
|
||||
attribute Element openerBrowser;
|
||||
};
|
||||
%{C++
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIPromptInstance.idl"
|
||||
|
||||
interface nsILoginInfo;
|
||||
interface nsIDOMWindow;
|
||||
|
@ -33,13 +32,12 @@ interface nsILoginManagerPrompter : nsISupports {
|
|||
* Contains values from anything that we think, but are not sure, might be
|
||||
* a username or password. Has two properties, 'usernames' and 'passwords'.
|
||||
*/
|
||||
nsIPromptInstance promptToSavePassword(
|
||||
in Element aBrowser,
|
||||
in nsILoginInfo aLogin,
|
||||
[optional] in boolean dismissed,
|
||||
[optional] in boolean notifySaved,
|
||||
[optional] in AString autoFilledLoginGuid,
|
||||
[optional] in jsval possibleValues);
|
||||
void promptToSavePassword(in Element aBrowser,
|
||||
in nsILoginInfo aLogin,
|
||||
[optional] in boolean dismissed,
|
||||
[optional] in boolean notifySaved,
|
||||
[optional] in AString autoFilledLoginGuid,
|
||||
[optional] in jsval possibleValues);
|
||||
|
||||
/**
|
||||
* Ask the user if they want to change a login's password or username.
|
||||
|
@ -63,15 +61,14 @@ interface nsILoginManagerPrompter : nsISupports {
|
|||
* Contains values from anything that we think, but are not sure, might be
|
||||
* a username or password. Has two properties, 'usernames' and 'passwords'.
|
||||
*/
|
||||
nsIPromptInstance promptToChangePassword(
|
||||
in Element aBrowser,
|
||||
in nsILoginInfo aOldLogin,
|
||||
in nsILoginInfo aNewLogin,
|
||||
[optional] in boolean dismissed,
|
||||
[optional] in boolean notifySaved,
|
||||
[optional] in AString autoSavedLoginGuid,
|
||||
[optional] in AString autoFilledLoginGuid,
|
||||
[optional] in jsval possibleValues);
|
||||
void promptToChangePassword(in Element aBrowser,
|
||||
in nsILoginInfo aOldLogin,
|
||||
in nsILoginInfo aNewLogin,
|
||||
[optional] in boolean dismissed,
|
||||
[optional] in boolean notifySaved,
|
||||
[optional] in AString autoSavedLoginGuid,
|
||||
[optional] in AString autoFilledLoginGuid,
|
||||
[optional] in jsval possibleValues);
|
||||
|
||||
/**
|
||||
* Ask the user if they want to change the password for one of
|
||||
|
@ -91,7 +88,7 @@ interface nsILoginManagerPrompter : nsISupports {
|
|||
* will be set (using the user's selection) before modifyLogin()
|
||||
* is called.
|
||||
*/
|
||||
nsIPromptInstance promptToChangePasswordWithUsernames(
|
||||
void promptToChangePasswordWithUsernames(
|
||||
in Element aBrowser,
|
||||
in Array<nsILoginInfo> logins,
|
||||
in nsILoginInfo aNewLogin);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* An object representing a prompt or doorhanger.
|
||||
*/
|
||||
[scriptable, uuid(889842e9-052c-46c9-99f3-f4a426571e38)]
|
||||
interface nsIPromptInstance : nsISupports {
|
||||
/**
|
||||
* Dismiss this prompt (e.g. because it's not relevant anymore).
|
||||
*/
|
||||
void dismiss();
|
||||
};
|
Загрузка…
Ссылка в новой задаче