summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html')
-rw-r--r--toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html121
1 files changed, 0 insertions, 121 deletions
diff --git a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html b/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html
deleted file mode 100644
index 4283f128c..000000000
--- a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html
+++ /dev/null
@@ -1,121 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Test no capturing of fields outside of a form due to navigation</title>
- <script src="/tests/SimpleTest/SimpleTest.js"></script>
- <script src="/tests/SimpleTest/SpawnTask.js"></script>
- <script src="pwmgr_common.js"></script>
- <link rel="stylesheet" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<script type="application/javascript;version=1.8">
-const LMCBackstagePass = SpecialPowers.Cu.import("resource://gre/modules/LoginManagerContent.jsm");
-const { LoginManagerContent, LoginFormFactory } = LMCBackstagePass;
-
-SimpleTest.requestFlakyTimeout("Testing that a message doesn't arrive");
-
-let chromeScript = runInParent(SimpleTest.getTestFileURL("pwmgr_common.js"));
-
-let loadPromise = new Promise(resolve => {
- document.addEventListener("DOMContentLoaded", () => {
- document.getElementById("loginFrame").addEventListener("load", (evt) => {
- resolve();
- });
- });
-});
-
-function submissionProcessed(...args) {
- ok(false, "No formSubmissionProcessed should occur in this test");
- info("got: " + JSON.stringify(args));
-}
-
-add_task(function* setup() {
- yield SpecialPowers.pushPrefEnv({
- set: [
- ["signon.formlessCapture.enabled", true],
- ],
- });
-
- info("Waiting for page and frame loads");
- yield loadPromise;
-
- chromeScript.addMessageListener("formSubmissionProcessed", submissionProcessed);
-
- SimpleTest.registerCleanupFunction(() => {
- chromeScript.removeMessageListener("formSubmissionProcessed", submissionProcessed);
- });
-});
-
-const DEFAULT_ORIGIN = "http://test1.mochi.test:8888";
-const SCRIPTS = {
- PUSHSTATE: `history.pushState({}, "Pushed state", "?pushed");`,
- WINDOW_LOCATION: `window.location = "data:text/html;charset=utf-8,window.location";`,
- WINDOW_LOCATION_RELOAD: `window.location.reload();`,
- HISTORY_BACK: `history.back();`,
- HISTORY_GO_MINUS1: `history.go(-1);`,
-};
-const TESTCASES = [
- // Begin test cases that shouldn't trigger capture.
- {
- // For now we don't trigger upon navigation if <form> is used.
- document: `<form><input type=password value="pass1"></form>`,
- },
- {
- // Empty password field
- document: `<input type=password value="">`,
- },
- {
- // Test with an input that would normally be captured but with SCRIPTS that
- // shouldn't trigger capture.
- document: `<input type=password value="pass2">`,
- wouldCapture: true,
- },
-];
-
-add_task(function* test() {
- let loginFrame = document.getElementById("loginFrame");
-
- for (let tc of TESTCASES) {
- for (let scriptName of Object.keys(SCRIPTS)) {
- if (tc.wouldCapture && ["PUSHSTATE", "WINDOW_LOCATION"].includes(scriptName)) {
- // Don't run scripts that should actually capture for this testcase.
- continue;
- }
-
- info("Starting testcase with script " + scriptName + ": " + JSON.stringify(tc));
- let loadedPromise = new Promise((resolve) => {
- loginFrame.addEventListener("load", function frameLoaded() {
- loginFrame.removeEventListener("load", frameLoaded);
- resolve();
- });
- });
- loginFrame.src = DEFAULT_ORIGIN + "/tests/toolkit/components/passwordmgr/test/mochitest/blank.html";
- yield loadedPromise;
-
- let frameDoc = SpecialPowers.wrap(loginFrame.contentWindow).document;
- frameDoc.documentElement.innerHTML = tc.document;
-
- // Wait for the form to be processed before trying to submit.
- yield promiseFormsProcessed();
-
- info("Running " + scriptName + " script to check for a submission");
- frameDoc.defaultView.eval(SCRIPTS[scriptName]);
-
- // Wait for 5000ms to see if the promise above resolves.
- yield new Promise(resolve => setTimeout(resolve, 5000));
- ok(true, "Done waiting for captures");
- }
- }
-});
-
-</script>
-
-<p id="display"></p>
-
-<div id="content">
- <iframe id="loginFrame" src="http://test1.mochi.test:8888/tests/toolkit/components/passwordmgr/test/mochitest/blank.html"></iframe>
-</div>
-<pre id="test"></pre>
-</body>
-</html>