1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test form field autocomplete in sandboxed documents (null principal)</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.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" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<!-- we presumably can't hide the content for this test. -->
<div id="content">
<iframe id="sandboxed"
sandbox=""
src="form_basic.html"></iframe>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Login Manager: form field autocomplete in sandboxed documents (null principal) **/
let sandboxed = document.getElementById("sandboxed");
let uname;
let pword;
let hostname;
add_setup(async () => {
await setStoredLoginsAsync(
[window.location.origin, "", null, "tempuser1", "temppass1", "uname", "pword"]
);
let frameWindow = SpecialPowers.wrap(sandboxed).contentWindow;
// Can't use SimpleTest.promiseFocus as it doesn't work with the sandbox.
await SimpleTest.promiseWaitForCondition(() => {
return frameWindow.document.readyState == "complete" && frameWindow.location.href != "about:blank";
}, "Check frame is loaded");
let frameDoc = SpecialPowers.wrap(sandboxed).contentDocument;
uname = frameDoc.getElementById("form-basic-username");
pword = frameDoc.getElementById("form-basic-password");
hostname = frameDoc.documentURIObject.host;
});
add_task(async function test_no_autofill() {
// Make sure initial form is empty as autofill shouldn't happen in the sandboxed frame.
checkLoginForm(uname, "", pword, "");
let popupState = await getPopupState();
is(popupState.open, false, "Check popup is initially closed");
});
add_task(async function test_autocomplete_warning_no_logins() {
const { items } = await openPopupOn(pword);
let popupState = await getPopupState();
is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
let expectedMenuItems = [
"This connection is not secure. Logins entered here could be compromised. Learn More",
];
checkAutoCompleteResults(items, expectedMenuItems, hostname, "Check all menuitems are displayed correctly.");
checkLoginForm(uname, "", pword, "");
});
</script>
</pre>
</body>
</html>
|