mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1184186 - Convert robocop testAboutLogins to mochitest-chrome; r=ally
This commit is contained in:
parent
d628391e18
commit
e2c11b08fe
@ -2,4 +2,5 @@
|
||||
skip-if = os != 'android'
|
||||
support-files =
|
||||
|
||||
[test_about_logins.html]
|
||||
[test_app_constants.html]
|
||||
|
100
mobile/android/tests/browser/chrome/test_about_logins.html
Normal file
100
mobile/android/tests/browser/chrome/test_about_logins.html
Normal file
@ -0,0 +1,100 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1136477
|
||||
Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1136477</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript;version=1.7">
|
||||
|
||||
"use strict"
|
||||
|
||||
const { interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const LOGIN_FIELDS = {
|
||||
hostname: "http://example.org/tests/robocop/robocop_blank_01.html",
|
||||
formSubmitUrl: "",
|
||||
realmAny: null,
|
||||
username: "username1",
|
||||
password: "password1",
|
||||
usernameField: "",
|
||||
passwordField: ""
|
||||
};
|
||||
|
||||
const LoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1", "nsILoginInfo", "init");
|
||||
|
||||
let BrowserApp;
|
||||
let browser;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function add_login(login) {
|
||||
let newLogin = new LoginInfo(login.hostname,
|
||||
login.formSubmitUrl,
|
||||
login.realmAny,
|
||||
login.username,
|
||||
login.password,
|
||||
login.usernameField,
|
||||
login.passwordField);
|
||||
|
||||
Services.logins.addLogin(newLogin);
|
||||
}
|
||||
|
||||
function password_setup() {
|
||||
add_login(LOGIN_FIELDS);
|
||||
|
||||
// Load about:logins.
|
||||
BrowserApp = Services.wm.getMostRecentWindow("navigator:browser").BrowserApp;
|
||||
browser = BrowserApp.addTab("about:logins", { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
|
||||
|
||||
browser.addEventListener("load", function handle(event) {
|
||||
browser.removeEventListener("load", handle, true);
|
||||
Services.tm.mainThread.dispatch(test_passwords_list, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function test_passwords_list() {
|
||||
// Test that the (single) entry added in setup is correct.
|
||||
let logins_list = browser.contentDocument.getElementById("logins-list");
|
||||
|
||||
let hostname = logins_list.querySelector(".hostname");
|
||||
is(hostname.textContent, LOGIN_FIELDS.hostname, "hostname is correct");
|
||||
|
||||
let username = logins_list.querySelector(".username");
|
||||
is(username.textContent, LOGIN_FIELDS.username, "username is correct");
|
||||
|
||||
// Cleanup: close about:logins, opened in password_setup()
|
||||
BrowserApp.closeTab(BrowserApp.selectedTab);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
if (AppConstants.NIGHTLY_BUILD) {
|
||||
password_setup();
|
||||
} else {
|
||||
ok(true, "this test is disabled on non-Nightly builds");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1136477">Mozilla Bug 1136477</a>
|
||||
<br>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1184186">Migrated from Robocop testAboutLogins</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -6,7 +6,6 @@ subsuite = robocop
|
||||
[testAboutPage.java]
|
||||
# disabled on Android 2.3; bug 975187
|
||||
skip-if = android_version == "10"
|
||||
[testAboutLogins.java]
|
||||
[testAddonManager.java]
|
||||
# disabled on 2.3: bug 941624, bug 1063509, bug 1073374, bug 1087221, bug 1088023, bug 1088027, bug 1090206; on 4.3, bug 1144918
|
||||
skip-if = android_version == "10" || android_version == "18"
|
||||
|
@ -1,25 +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/. */
|
||||
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
|
||||
public class testAboutLogins extends JavascriptTest {
|
||||
private static final String LOGTAG = testAboutLogins.class.getSimpleName();
|
||||
|
||||
public testAboutLogins() {
|
||||
super("testAboutLogins.js");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testJavascript() throws Exception {
|
||||
// This feature is only available in Nightly.
|
||||
if (!AppConstants.NIGHTLY_BUILD) {
|
||||
mAsserter.dumpLog(LOGTAG + " is disabled on non-Nightly builds: returning");
|
||||
return;
|
||||
}
|
||||
super.testJavascript();
|
||||
}
|
||||
}
|
@ -1,65 +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/. */
|
||||
|
||||
"use strict"
|
||||
|
||||
const { interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/AndroidLog.jsm");
|
||||
|
||||
const LOGIN_FIELDS = {
|
||||
hostname: "http://example.org/tests/robocop/robocop_blank_01.html",
|
||||
formSubmitUrl: "",
|
||||
realmAny: null,
|
||||
username: "username1",
|
||||
password: "password1",
|
||||
usernameField: "",
|
||||
passwordField: ""
|
||||
};
|
||||
|
||||
const LoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1", "nsILoginInfo", "init");
|
||||
|
||||
let BrowserApp;
|
||||
let browser;
|
||||
|
||||
function add_login(login) {
|
||||
let newLogin = new LoginInfo(login.hostname,
|
||||
login.formSubmitUrl,
|
||||
login.realmAny,
|
||||
login.username,
|
||||
login.password,
|
||||
login.usernameField,
|
||||
login.passwordField);
|
||||
|
||||
Services.logins.addLogin(newLogin);
|
||||
}
|
||||
|
||||
add_test(function password_setup() {
|
||||
add_login(LOGIN_FIELDS);
|
||||
|
||||
// Load about:logins.
|
||||
BrowserApp = Services.wm.getMostRecentWindow("navigator:browser").BrowserApp;
|
||||
browser = BrowserApp.addTab("about:logins", { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
|
||||
|
||||
browser.addEventListener("load", () => {
|
||||
browser.removeEventListener("load", this, true);
|
||||
Services.tm.mainThread.dispatch(run_next_test, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}, true);
|
||||
});
|
||||
|
||||
add_test(function test_passwords_list() {
|
||||
// Test that the (single) entry added in setup is correct.
|
||||
let logins_list = browser.contentDocument.getElementById("logins-list");
|
||||
|
||||
let hostname = logins_list.querySelector(".hostname");
|
||||
do_check_eq(hostname.textContent, LOGIN_FIELDS.hostname);
|
||||
|
||||
let username = logins_list.querySelector(".username");
|
||||
do_check_eq(username.textContent, LOGIN_FIELDS.username);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
run_next_test();
|
Loading…
Reference in New Issue
Block a user