Bug 1258828 - Convert test_formless_autofill.html from m-chrome to m-plain. r=paolo
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 25 Mar 2016 09:21:14 -0400
changeset 290279 d823452bea13282527bce173c1133f2f12990d7f
parent 290278 96bfe329ad1ebbf3a07395fb410083838ed1aed6
child 290280 fe2112d79fc1178e0b34f7674e61309f7de082ab
push id18365
push usermozilla@noorenberghe.ca
push dateFri, 25 Mar 2016 13:23:49 +0000
treeherderfx-team@d823452bea13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1258828
milestone48.0a1
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
toolkit/components/passwordmgr/test/chrome/chrome.ini
toolkit/components/passwordmgr/test/chrome/test_formless_autofill.html
toolkit/components/passwordmgr/test/mochitest/mochitest.ini
toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html
--- 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
@@ -18,14 +18,15 @@ support-files =
 [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,21 @@
 <!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();
-
-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);
+let mm = runInParent(SimpleTest.getTestFileURL("pwmgr_common.js"));
 
 document.addEventListener("DOMContentLoaded", () => {
   document.getElementById("loginFrame").addEventListener("load", (evt) => {
     // Tell the parent to setup test logins.
     mm.sendAsyncMessage("setupParent", { selfFilling: true });
   });
 });
 
@@ -32,17 +25,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 +104,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 +127,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>