Bug 1258828 - Convert test_formless_autofill.html from m-chrome to m-plain. r=paolo
No test logic changes, only setup stuff.
MozReview-Commit-ID: IzoR5kZLWxE
--- a/toolkit/components/passwordmgr/test/chrome/chrome.ini
+++ b/toolkit/components/passwordmgr/test/chrome/chrome.ini
@@ -1,11 +1,10 @@
[DEFAULT]
skip-if = buildapp == 'b2g' || os == 'android'
support-files =
../formsubmit.sjs
../notification_common.js
../pwmgr_common.js
-[test_formless_autofill.html]
[test_formless_submit.html]
[test_privbrowsing_perwindowpb.html]
skip-if = true # Bug 1173337
--- a/toolkit/components/passwordmgr/test/mochitest/mochitest.ini
+++ b/toolkit/components/passwordmgr/test/mochitest/mochitest.ini
@@ -22,14 +22,15 @@ skip-if = true
[test_basic_form_pwevent.html]
[test_basic_form_pwonly.html]
[test_bug_776171.html]
[test_case_differences.html]
skip-if = toolkit == 'android' # autocomplete
[test_form_action_1.html]
[test_form_action_2.html]
[test_form_action_javascript.html]
+[test_formless_autofill.html]
[test_input_events.html]
[test_input_events_for_identical_values.html]
[test_maxlength.html]
[test_passwords_in_type_password.html]
[test_recipe_login_fields.html]
[test_xhr_2.html]
rename from toolkit/components/passwordmgr/test/chrome/test_formless_autofill.html
rename to toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html
--- a/toolkit/components/passwordmgr/test/chrome/test_formless_autofill.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html
@@ -1,28 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test autofilling of fields outside of a form</title>
- <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script src="pwmgr_common.js"></script>
- <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script type="application/javascript;version=1.8">
-SimpleTest.waitForExplicitFinish();
+let mm = runInParent(SimpleTest.getTestFileURL("pwmgr_common.js"));
-const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
-Cu.import("resource://gre/modules/Task.jsm");
-const LMCBackstagePass = Cu.import("resource://gre/modules/LoginManagerContent.jsm");
-const { LoginManagerContent, FormLikeFactory } = LMCBackstagePass;
-
-let parentScriptURL = SimpleTest.getTestFileURL("pwmgr_common.js");
-let mm = SpecialPowers.loadChromeScript(parentScriptURL);
+SimpleTest.registerCleanupFunction(() => {
+ mm.destroy();
+})
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("loginFrame").addEventListener("load", (evt) => {
// Tell the parent to setup test logins.
mm.sendAsyncMessage("setupParent", { selfFilling: true });
});
});
@@ -32,17 +29,24 @@ mm.addMessageListener("doneSetup", funct
siteRecipes: [{
hosts: ["mochi.test:8888"],
usernameSelector: "input[name='recipeuname']",
passwordSelector: "input[name='recipepword']",
}],
});
});
-mm.addMessageListener("loadedRecipes", () => runTest());
+let loadedRecipesPromise = new Promise(resolve => {
+ mm.addMessageListener("loadedRecipes", resolve);
+});
+
+add_task(function* setup() {
+ yield loadedRecipesPromise;
+});
+
const DEFAULT_ORIGIN = "http://mochi.test:8888";
const TESTCASES = [
{
// Inputs
document: `<input type=password>`,
// Expected outputs
@@ -104,17 +108,17 @@ const TESTCASES = [
<input>
<input type=password>
</form>`,
expectedFormCount: 2,
expectedInputValues: ["testuser", "", "", "", "testpass", "", ""],
},
];
-let runTest = Task.async(function*() {
+add_task(function* test() {
let loginFrame = document.getElementById("loginFrame");
let frameDoc = loginFrame.contentWindow.document;
for (let tc of TESTCASES) {
info("Starting testcase: " + JSON.stringify(tc));
let numFormLikesExpected = tc.expectedFormCount || 1;
@@ -127,18 +131,16 @@ let runTest = Task.async(function*() {
let testInputs = frameDoc.documentElement.querySelectorAll("input");
is(testInputs.length, tc.expectedInputValues.length, "Check number of inputs");
for (let i = 0; i < tc.expectedInputValues.length; i++) {
let expectedValue = tc.expectedInputValues[i];
is(testInputs[i].value, expectedValue,
"Check expected input value " + i + ": " + expectedValue);
}
}
-
- SimpleTest.finish();
});
</script>
<p id="display"></p>
<div id="content">
<iframe id="loginFrame" src="http://mochi.test:8888/tests/toolkit/components/passwordmgr/test/blank.html"></iframe>