summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_autofill_related_realms_no_dupes.html
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/passwordmgr/test/mochitest/test_autocomplete_autofill_related_realms_no_dupes.html')
-rw-r--r--toolkit/components/passwordmgr/test/mochitest/test_autocomplete_autofill_related_realms_no_dupes.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_autofill_related_realms_no_dupes.html b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_autofill_related_realms_no_dupes.html
new file mode 100644
index 0000000000..b229993a42
--- /dev/null
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_autofill_related_realms_no_dupes.html
@@ -0,0 +1,112 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Login Manager: Related Realms</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="../../../satchel/test/satchel_common.js"></script>
+ <script type="text/javascript" src="pwmgr_common.js"></script>
+ <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content"></div>
+<pre id="test">
+Testing related realms
+
+Related realms is feature to provide login suggestion based on similar domains.
+
+Out of the scope of this feature is subdomain handling, which is already part
+of the base functionality. The intent is to cover the ebay.com/ebay.co.uk and
+all other country TLD cases where the sign in page is actually
+signin.ebay.com/signin.ebay.co.uk but credentials could have manually been
+entered for ebay.com/ebay.co.uk or automatically stored as
+signin.ebay.com/sigin.ebay.co.uk
+
+The related realms feature can be enabled via the preference
+signon.relatedRealms.enabled. It is disabled by default.
+
+This test proves that related logins show up in the autocomplete menu when
+the feature is enabled and that the related logins do not count as duplicates
+and therefore the form gets filled directly.
+
+<template id="form1-template">
+ <form id="form1" action="https://www.example.com">
+ <input type="text" name="uname">
+ <input type="password" name="pword">
+ </form>
+</template>
+
+<script class="testbody" type="text/javascript">
+ const formTemplate = document.getElementById("form1-template");
+
+ add_setup(async () => {
+ await setStoredLoginsDuringTest(
+ ["https://example.com", "https://example.com", null, "example.com-user", "password", "uname", "pword"],
+
+ // Related domain relationship where example.com and other-example.com are in the related domains list
+ ["https://other-example.com", "https://other-example.com", null, "other-example.com-user", "password", "uname", "pword"],
+
+ // example.com and example.co.uk are related, so sub.example.co.uk is also related
+ ["https://sub.example.co.uk", "https://sub.example.co.uk", null, "sub.example.co.uk-user", "password", "uname", "pword"],
+
+ // www subdomain on same TLD
+ ["https://www.example.com", "https://www.example.com", null, "www.example.com-user", "password", "uname", "pword"],
+
+ // other subdomain on same TLD
+ ["https://sub.example.com", "https://sub.example.com", null, "sub.example.com-user", "password", "uname", "pword"],
+ );
+ });
+
+ add_named_task("with relatedRealms disabled, related logins do not show up in autocomplete menu", async () => {
+ await setPreferencesForTask(["signon.relatedRealms.enabled", false]);
+
+ const form = setContentForTask(formTemplate);
+
+ const autofillResult = await formAutofillResult(form.id);
+ is(autofillResult, "filled", "form has been filled");
+
+ // reset the form and open autocomplete popup by focusing username input
+ form.reset();
+ const results = await popupBy(() => form.uname.focus());
+ checkAutoCompleteResults(results, [
+ "example.com-user",
+ "sub.example.com-user",
+ "www.example.com-user",
+ ], window.location.host, "all logins are present and in order");
+ });
+
+ add_named_task("with relatedRealms enabled, related logins show up in autocomplete menu", async () => {
+ await setPreferencesForTask(["signon.relatedRealms.enabled", true]);
+
+ const form = setContentForTask(formTemplate);
+
+ const result = await formAutofillResult(form.id);
+ is(result, "filled", "form has been filled");
+
+ // reset the form and open autocomplete popup by focusing username input
+ form.reset();
+ const results = await popupBy(() => form.uname.focus());
+ checkAutoCompleteResults(results, [
+ "example.com-user",
+ "other-example.com-user",
+ "sub.example.co.uk-user",
+ "sub.example.com-user",
+ "www.example.com-user",
+ ], window.location.host, "all logins are present and in order");
+ });
+
+ add_named_task("even with relatedRealms enabled, related logins are not considered duplicates, so form will be filled", async () => {
+ await setPreferencesForTask(["signon.relatedRealms.enabled", true]);
+
+ const form = setContentForTask(formTemplate);
+
+ const autofillResult = await formAutofillResult(form.id);
+ is(autofillResult, "filled", "form has been filled");
+
+ is(form.uname.value, "example.com-user", "username from exact tld is filled in");
+ });
+</script>
+</pre>
+</body>
+</html>