File: test_autocomplete_sandboxed.html

package info (click to toggle)
thunderbird 1%3A91.13.0-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,953,400 kB
  • sloc: cpp: 6,084,049; javascript: 4,790,441; ansic: 3,341,496; python: 862,958; asm: 366,542; xml: 204,277; java: 152,477; sh: 111,436; makefile: 21,388; perl: 15,312; yacc: 4,583; objc: 3,026; lex: 1,720; exp: 762; pascal: 635; awk: 564; sql: 453; php: 436; lisp: 432; ruby: 99; sed: 69; csh: 45
file content (84 lines) | stat: -rw-r--r-- 2,902 bytes parent folder | download | duplicates (4)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!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>

<script>
SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
                                    true]]});

var chromeScript = runChecksAfterCommonInit();

addLoginsInParent(
  [window.location.origin, "", null, "tempuser1", "temppass1", "uname", "pword"]);
</script>
<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_task(async function setup() {
  await SpecialPowers.pushPrefEnv({"set": [
    ["security.insecure_field_warning.contextual.enabled", true],
  ]});

  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() {
  pword.focus();
  let shownPromise = promiseACShown();
  synthesizeKey("KEY_ArrowDown"); // open the popup
  let results = await shownPromise;

  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(results, expectedMenuItems, hostname, "Check all menuitems are displayed correctly.");

  checkLoginForm(uname, "", pword, "");
});
</script>
</pre>
</body>
</html>