Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc-browser.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvarjolintu <sami.vanttinen@protonmail.com>2022-03-18 17:10:36 +0300
committervarjolintu <sami.vanttinen@protonmail.com>2022-03-18 17:10:36 +0300
commit97e07b5a62a85e2c35a70bae433c74c8f0927b0c (patch)
tree3e28620dac921b0d120e47f78833bcbf377382c1 /tests
parentc18cbc630d1261a8d93668e779023cd787a80cd7 (diff)
Second draft
Diffstat (limited to 'tests')
-rw-r--r--tests/assert.js70
-rw-r--r--tests/example.spec.js2
-rw-r--r--tests/html/basic1.html6
-rw-r--r--tests/html/basic2.html5
-rw-r--r--tests/html/basic3.html5
-rw-r--r--tests/html/basic4.html7
-rw-r--r--tests/html/basictest.html2
-rw-r--r--tests/html/div1.html14
-rw-r--r--tests/html/div2.html21
-rw-r--r--tests/html/div3.html10
-rw-r--r--tests/html/div4.html10
-rw-r--r--tests/html/hidden_fields1.html12
-rw-r--r--tests/html/hidden_fields2.html18
-rw-r--r--tests/html/passwordchange1.html7
-rw-r--r--tests/html/passwordchange2.html7
-rw-r--r--tests/html/passwordchange3.html10
-rw-r--r--tests/html/passwordchange4.html10
-rw-r--r--tests/html/passwordchange5.html17
-rw-r--r--tests/scripts/div1.js (renamed from tests/html/div1.js)4
-rw-r--r--tests/scripts/div2.js (renamed from tests/html/div2.js)3
-rw-r--r--tests/scripts/div3.js (renamed from tests/html/div3.js)6
-rw-r--r--tests/scripts/div4.js (renamed from tests/html/div4.js)10
-rw-r--r--tests/tests.html133
-rw-r--r--tests/tests.js50
24 files changed, 187 insertions, 252 deletions
diff --git a/tests/assert.js b/tests/assert.js
index cd21962..2e0cc23 100644
--- a/tests/assert.js
+++ b/tests/assert.js
@@ -19,60 +19,38 @@ function assertRegex(func, expected, card, testName) {
createResult(card, false, `Test failed: ${testName}. Result is: ${func}`);
}
-async function assertInputFields(localFile, expectedFieldCount, actionElementId) {
- return new Promise((resolve) => {
- const iframe = document.getElementById('testFile');
- iframe.src = localFile;
-
- const iframeLoaded = function() {
- const frameContent = iframe.contentWindow.document.getElementsByTagName('body')[0];
-
- // Load prototypes to iframe. This doesn't work automatically from ui.js
- iframe.contentWindow.Element.prototype.getLowerCaseAttribute = function(attr) {
- return this.getAttribute(attr) ? this.getAttribute(attr).toLowerCase() : undefined;
- };
-
- // An user interaction is required before testing
- if (actionElementId) {
- const actionElement = frameContent.querySelector(actionElementId);
- if (actionElement) {
- actionElement.click();
- }
+async function assertInputFields(localDiv, expectedFieldCount, actionElementId) {
+ return new Promise(async (resolve) => {
+ const div = document.getElementById(localDiv);
+ div.style.display = 'block';
+
+ // An user interaction is required before testing
+ if (actionElementId) {
+ const actionElement = div.querySelector(actionElementId);
+ if (actionElement) {
+ actionElement.click();
}
+ }
- const inputs = kpxcObserverHelper.getInputs(frameContent);
- kpxcAssert(inputs.length, expectedFieldCount, Tests.INPUT_FIELDS, `getInputs() for ${localFile} with ${expectedFieldCount} fields`);
- iframe.removeEventListener('load', iframeLoaded);
- resolve();
- };
+ const inputs = kpxcObserverHelper.getInputs(div);
+ kpxcAssert(inputs.length, expectedFieldCount, Tests.INPUT_FIELDS, `getInputs() for ${localDiv} with ${expectedFieldCount} fields`);
- // Wait for iframe to load
- iframe.addEventListener('load', iframeLoaded);
+ div.style.display = 'none';
+ resolve();
});
}
-async function assertPasswordChangeFields(localFile, expectedNewPassword) {
- return new Promise((resolve) => {
- const iframe = document.getElementById('testFile');
- iframe.src = localFile;
+async function assertPasswordChangeFields(localDiv, expectedNewPassword) {
+ return new Promise(async (resolve) => {
+ const div = document.getElementById(localDiv);
+ div.style.display = 'block';
- const iframeLoaded = function() {
- const frameContent = iframe.contentWindow.document.getElementsByTagName('body')[0];
+ const inputs = kpxcObserverHelper.getInputs(div, true);
+ const newPassword = kpxcForm.getNewPassword(inputs);
+ kpxcAssert(newPassword, expectedNewPassword, Tests.PASSWORD_CHANGE, `New password matches for ${localDiv}`);
- // Load prototypes to iframe. This doesn't work automatically from ui.js
- iframe.contentWindow.Element.prototype.getLowerCaseAttribute = function(attr) {
- return this.getAttribute(attr) ? this.getAttribute(attr).toLowerCase() : undefined;
- };
-
- const inputs = kpxcObserverHelper.getInputs(frameContent, true);
- const newPassword = kpxcForm.getNewPassword(inputs);
- kpxcAssert(newPassword, expectedNewPassword, Tests.PASSWORD_CHANGE, `New password matches for ${localFile}`);
- iframe.removeEventListener('load', iframeLoaded);
- resolve();
- };
-
- // Wait for iframe to load
- iframe.addEventListener('load', iframeLoaded);
+ div.style.display = 'none';
+ resolve();
});
}
diff --git a/tests/example.spec.js b/tests/example.spec.js
index 75633bb..7e89283 100644
--- a/tests/example.spec.js
+++ b/tests/example.spec.js
@@ -1,6 +1,6 @@
'use strict';
-const { chromium, test, expect } = require('@playwright/test');
+const { test, expect } = require('@playwright/test');
const fileUrl = require('file-url');
const DEST = 'keepassxc-browser/tests';
diff --git a/tests/html/basic1.html b/tests/html/basic1.html
deleted file mode 100644
index 5c16408..0000000
--- a/tests/html/basic1.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<body>
-<input placeholder="username" type="text" name="loginField">
-<input placeholder="password" type="password" name="passwordField">
-</body>
-</html>
diff --git a/tests/html/basic2.html b/tests/html/basic2.html
deleted file mode 100644
index b417524..0000000
--- a/tests/html/basic2.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-<input placeholder="username" type="text" name="loginField">
-</body>
-</html>
diff --git a/tests/html/basic3.html b/tests/html/basic3.html
deleted file mode 100644
index a2aba6a..0000000
--- a/tests/html/basic3.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-<input placeholder="password" type="password" name="passwordField">
-</body>
-</html>
diff --git a/tests/html/basic4.html b/tests/html/basic4.html
deleted file mode 100644
index 8f199b8..0000000
--- a/tests/html/basic4.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
-<body>
-<input placeholder="username" type="text" name="loginField">
-<input placeholder="password" type="password" name="passwordField">
-<input type="text" id="auth">
-</body>
-</html>
diff --git a/tests/html/basictest.html b/tests/html/basictest.html
deleted file mode 100644
index fd152f0..0000000
--- a/tests/html/basictest.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<input placeholder="username" type="text" name="loginField">
-<input placeholder="password" type="password" name="passwordField">
diff --git a/tests/html/div1.html b/tests/html/div1.html
deleted file mode 100644
index ae9ffb3..0000000
--- a/tests/html/div1.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html>
- <head>
- <script defer src="div1.js"></script>
- </head>
-<body>
-
-<button id="toggle">View login form</button>
-<div id="loginForm" style="display: none;">
- <input placeholder="username" type="text" name="loginField">
- <input placeholder="password" type="password" name="passwordField">
-</div>
-
-</body>
-</html>
diff --git a/tests/html/div2.html b/tests/html/div2.html
deleted file mode 100644
index 86b8669..0000000
--- a/tests/html/div2.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<html>
- <head>
- <script defer src="div2.js"></script>
- </head>
-<body>
-
-<button id="toggle">View login form</button>
-
-<div id="dialog" style="position: relative; z-index: auto;">
- <div id="outer" style="overflow: hidden; height: 0px;">
- <div id="inner" style="margin: -197px auto auto;">
- <form method="post" class="signin" action="#">
- <input placeholder="username" type="text" name="loginField">
- <input placeholder="password" type="password" name="passwordField">
- </form>
- </div>
- </div>
-</div>
-
-</body>
-</html>
diff --git a/tests/html/div3.html b/tests/html/div3.html
deleted file mode 100644
index 5567667..0000000
--- a/tests/html/div3.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
- <head>
- <script defer src="div3.js"></script>
- </head>
-<body>
-
-<button id="toggle">View login form</button>
-
-</body>
-</html>
diff --git a/tests/html/div4.html b/tests/html/div4.html
deleted file mode 100644
index 909ba7c..0000000
--- a/tests/html/div4.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
- <head>
- <script defer src="div4.js"></script>
- </head>
-<body>
-
-<button id="toggle">View login form</button>
-
-</body>
-</html>
diff --git a/tests/html/hidden_fields1.html b/tests/html/hidden_fields1.html
deleted file mode 100644
index 84d3da8..0000000
--- a/tests/html/hidden_fields1.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<html>
-<body>
-<div style="margin-left: -500px;">
- <input placeholder="outsideLeft" type="password" name="outsideLeft">
-</div>
-
-<div style="margin-top: -500px;">
- <input placeholder="outsideTop" type="password" name="outsideTop">
-</div>
-
-</body>
-</html>
diff --git a/tests/html/hidden_fields2.html b/tests/html/hidden_fields2.html
deleted file mode 100644
index d5b865a..0000000
--- a/tests/html/hidden_fields2.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<html>
-<style>
-.hiddenOne {
- visibility: hidden;
-}
-</style>
-<body>
-<div>
- <input placeholder="zeroSize" type="password" name="zeroSize" style="width: 0px; height: 0px;">
- <input placeholder="oneSize" type="password" name="oneSize" style="width: 1px; height: 1px;">
- <input placeholder="visibilityHidden" type="password" name="visibilityHidden" style="visibility: hidden;">
- <input placeholder="visibilityCollapse" type="password" name="visibilityCollapse" style="visibility: collapse;">
- <input placeholder="displayNone" type="password" name="displayNone" style="display: none;">
- <input placeholder="hiddenOne" type="password" name="hiddenOne" class="hiddenOne">
- <input placeholder="normal" type="password" name="normal">
-</div>
-</body>
-</html>
diff --git a/tests/html/passwordchange1.html b/tests/html/passwordchange1.html
deleted file mode 100644
index c03ca47..0000000
--- a/tests/html/passwordchange1.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
-<body>
-<br /><input type="password" name="Old password" value="oldPassword">
-<br /><input type="password" name="New password" value="newPassword">
-<br /><input type="password" name="Repeat password" value="newPassword">
-</body>
-</html>
diff --git a/tests/html/passwordchange2.html b/tests/html/passwordchange2.html
deleted file mode 100644
index 8cc0120..0000000
--- a/tests/html/passwordchange2.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
-<body>
-<br /><input type="password" name="New password" value="newPassword">
-<br /><input type="password" name="Repeat password" value="newPassword">
-<br /><input type="password" name="Old password" value="oldPassword">
-</body>
-</html>
diff --git a/tests/html/passwordchange3.html b/tests/html/passwordchange3.html
deleted file mode 100644
index d3453f8..0000000
--- a/tests/html/passwordchange3.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
-<body>
-<form action="secondPage">
-<br /><input type="password" name="Old password" value="oldPassword">
-<br /><input type="password" name="New password" value="newPassword">
-<br /><input type="password" name="Repeat password" value="newPassword">
-<br /><input type="submit" value="Change password">
-</form>
-</body>
-</html>
diff --git a/tests/html/passwordchange4.html b/tests/html/passwordchange4.html
deleted file mode 100644
index 88adfbf..0000000
--- a/tests/html/passwordchange4.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
-<body>
-<form action="secondPage">
-<br /><input type="password" name="New password" value="newPassword">
-<br /><input type="password" name="Repeat password" value="newPassword">
-<br /><input type="password" name="Old password" value="oldPassword">
-<br /><input type="submit" value="Change password">
-</form>
-</body>
-</html>
diff --git a/tests/html/passwordchange5.html b/tests/html/passwordchange5.html
deleted file mode 100644
index 6df49e8..0000000
--- a/tests/html/passwordchange5.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<html>
-<body>
-
-<form action="firstForm">
-<br /><input type="password" name="Old password" value="oldPassword">
-</form>
-
-<form action="secondForm">
-<br /><input type="password" name="New password" value="newPassword">
-</form>
-
-<form action="thirdForm">
-<br /><input type="password" name="Repeat password" value="newPassword">
-</form>
-
-</body>
-</html>
diff --git a/tests/html/div1.js b/tests/scripts/div1.js
index ffdd4d0..5b378b7 100644
--- a/tests/html/div1.js
+++ b/tests/scripts/div1.js
@@ -1,7 +1,7 @@
'use script';
-document.getElementById('toggle').addEventListener('click', function(e) {
- const loginForm = document.getElementById('loginForm');
+document.getElementById('toggle1').addEventListener('click', function(e) {
+ const loginForm = document.getElementById('loginForm1');
if (loginForm.style.display === 'none') {
loginForm.style.display = 'block';
diff --git a/tests/html/div2.js b/tests/scripts/div2.js
index a76c91b..c6ff46d 100644
--- a/tests/html/div2.js
+++ b/tests/scripts/div2.js
@@ -1,6 +1,6 @@
'use script';
-document.getElementById('toggle').addEventListener('click', function(e) {
+document.getElementById('toggle2').addEventListener('click', function(e) {
const dialog = document.getElementById('dialog');
const outer = document.getElementById('outer');
const inner = document.getElementById('inner');
@@ -9,7 +9,6 @@ document.getElementById('toggle').addEventListener('click', function(e) {
dialog.style.zIndex = 9999;
inner.style.margin = '0px';
outer.style.height = 'auto';
-
} else {
dialog.style.zIndex = 'auto';
inner.style.margin = '-197px';
diff --git a/tests/html/div3.js b/tests/scripts/div3.js
index 7d74e14..00bdb8f 100644
--- a/tests/html/div3.js
+++ b/tests/scripts/div3.js
@@ -1,6 +1,6 @@
'use script';
-document.getElementById('toggle').addEventListener('click', function(e) {
+document.getElementById('toggle3').addEventListener('click', function(e) {
const loginForm = document.getElementById('loginForm');
if (!loginForm) {
@@ -19,8 +19,6 @@ document.getElementById('toggle').addEventListener('click', function(e) {
passwordInput.setAttribute('placeholder', 'password');
dialog.append(passwordInput);
- document.body.appendChild(dialog);
- } else {
- document.body.removeChild(loginForm);
+ e.currentTarget.parentElement.appendChild(dialog);
}
});
diff --git a/tests/html/div4.js b/tests/scripts/div4.js
index db7db8f..30a1182 100644
--- a/tests/html/div4.js
+++ b/tests/scripts/div4.js
@@ -1,11 +1,11 @@
'use script';
-document.getElementById('toggle').addEventListener('click', function(e) {
- const loginForm = document.getElementById('loginForm');
+document.getElementById('toggle4').addEventListener('click', function(e) {
+ const loginForm = document.getElementById('loginForm4');
if (!loginForm) {
const dialog = document.createElement('div');
- dialog.setAttribute('id', 'loginForm');
+ dialog.setAttribute('id', 'loginForm4');
dialog.style.position = 'fixed';
dialog.style.zIndex = '1002';
@@ -48,8 +48,6 @@ document.getElementById('toggle').addEventListener('click', function(e) {
wrapper.append(innerDiv);
dialog.append(wrapper);
- document.body.appendChild(dialog);
- } else {
- document.body.removeChild(loginForm);
+ e.currentTarget.parentElement.appendChild(dialog);
}
});
diff --git a/tests/tests.html b/tests/tests.html
index b37db26..3a9961d 100644
--- a/tests/tests.html
+++ b/tests/tests.html
@@ -12,8 +12,6 @@
<link rel="icon" type="image/png" href="../icons/keepassxc_64x64.png" sizes="64x64">
<link rel="icon" type="image/png" href="../icons/keepassxc_96x96.png" sizes="96x96">
<script src="../common/browser-polyfill.min.js"></script>
- <script src="../bootstrap/jquery-3.4.1.min.js"></script>
- <script src="../bootstrap/bootstrap.min.js"></script>
<script defer src="../common/global.js"></script>
<script defer src="../common/sites.js"></script>
<script defer src="../content/ui.js"></script>
@@ -34,6 +32,12 @@
<script defer src="tests.js"></script>
</head>
+ <style>
+ .hiddenOne {
+ visibility: hidden;
+ }
+ </style>
+
<body class="pt-3 pb-5">
<div class="container-fluid">
<div class="row">
@@ -71,9 +75,132 @@
</div>
- <iframe id="testFile" width="100%" height="600" frameborder="0"></iframe>
+ <!-- Test content -->
+ <!-- =================================== -->
+
+ <div id="basic1" style="display: none;">
+ <input placeholder="username" type="text" name="loginField">
+ <input placeholder="password" type="password" name="passwordField">
+ </div>
+
+ <div id="basic2" style="display: none;">
+ <input placeholder="username" type="text" name="loginField">
+ </div>
+
+ <div id="basic3" style="display: none;">
+ <input placeholder="password" type="password" name="passwordField">
+ </div>
+
+ <div id="basic4" style="display: none;">
+ <input placeholder="username" type="text" name="loginField">
+ <input placeholder="password" type="password" name="passwordField">
+ <input type="text" id="auth">
+ </div>
+
+ <div id="div1" style="display: none;">
+ <button id="toggle1">View login form</button>
+ <div id="loginForm1" style="display: none;">
+ <input placeholder="username" type="text" name="loginField">
+ <input placeholder="password" type="password" name="passwordField">
+ </div>
+ </div>
+
+ <div id="div2" style="display: none;">
+ <button id="toggle2">View login form</button>
+
+ <div id="dialog" style="position: relative; z-index: auto;">
+ <div id="outer" style="overflow: hidden; height: 0px;">
+ <div id="inner" style="margin: -197px auto auto;">
+ <form method="post" class="signin" action="#">
+ <input placeholder="username" type="text" name="loginField">
+ <input placeholder="password" type="password" name="passwordField">
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div id="div3" style="display: none;">
+ <button id="toggle3">View login form</button>
+ </div>
+
+ <div id="div4" style="display: none;">
+ <button id="toggle4">View login form</button>
+ </div>
+
+ <div id="hiddenFields1" style="display: none;">
+ <div style="position: absolute; margin-left: -500px;">
+ <input placeholder="outsideLeft" type="password" name="outsideLeft">
+ </div>
+
+ <div style="position: absolute; margin-top: -1500px;">
+ <input placeholder="outsideTop" type="password" name="outsideTop">
+ </div>
+ </div>
+
+ <div id="hiddenFields2" style="display: none;">
+ <div>
+ <input placeholder="zeroSize" type="password" name="zeroSize" style="width: 0px; height: 0px;">
+ <input placeholder="oneSize" type="password" name="oneSize" style="width: 1px; height: 1px;">
+ <input placeholder="visibilityHidden" type="password" name="visibilityHidden" style="visibility: hidden;">
+ <input placeholder="visibilityCollapse" type="password" name="visibilityCollapse" style="visibility: collapse;">
+ <input placeholder="displayNone" type="password" name="displayNone" style="display: none;">
+ <input placeholder="hiddenOne" type="password" name="hiddenOne" class="hiddenOne">
+ <input placeholder="normal" type="password" name="normal">
+ </div>
+ </div>
+
+ <div id="passwordChange1" style="display: none;">
+ <br /><input type="password" name="Old password" value="oldPassword">
+ <br /><input type="password" name="New password" value="newPassword">
+ <br /><input type="password" name="Repeat password" value="newPassword">
+ </div>
+
+ <div id="passwordChange2" style="display: none;">
+ <br /><input type="password" name="New password" value="newPassword">
+ <br /><input type="password" name="Repeat password" value="newPassword">
+ <br /><input type="password" name="Old password" value="oldPassword">
+ </div>
+
+ <div id="passwordChange3" style="display: none;">
+ <form action="secondPage">
+ <br /><input type="password" name="Old password" value="oldPassword">
+ <br /><input type="password" name="New password" value="newPassword">
+ <br /><input type="password" name="Repeat password" value="newPassword">
+ <br /><input type="submit" value="Change password">
+ </form>
+ </div>
+
+ <div id="passwordChange4" style="display: none;">
+ <form action="secondPage">
+ <br /><input type="password" name="New password" value="newPassword">
+ <br /><input type="password" name="Repeat password" value="newPassword">
+ <br /><input type="password" name="Old password" value="oldPassword">
+ <br /><input type="submit" value="Change password">
+ </form>
+ </div>
+
+ <div id="passwordChange5" style="display: none;">
+ <form action="firstForm">
+ <br /><input type="password" name="Old password" value="oldPassword">
+ </form>
+
+ <form action="secondForm">
+ <br /><input type="password" name="New password" value="newPassword">
+ </form>
+
+ <form action="thirdForm">
+ <br /><input type="password" name="Repeat password" value="newPassword">
+ </form>
+ </div>
</main>
</div>
</div>
+
+ <!-- These need to be loaded only after everything else -->
+ <script src="scripts/div1.js"></script>
+ <script src="scripts/div2.js"></script>
+ <script src="scripts/div3.js"></script>
+ <script src="scripts/div4.js"></script>
</body>
</html>
diff --git a/tests/tests.js b/tests/tests.js
index 59b3458..304d6fb 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -61,25 +61,23 @@ async function testGeneral() {
// Input field matching (keepassxc-browser.js)
async function testInputFields() {
- // Local filename, expected fields, action element ID (a button to be clicked)
- const localFiles = [
- [ 'html/basic1.html', 2 ], // Username/passwd fields
- [ 'html/basic2.html', 1 ], // Only username field
- [ 'html/basic3.html', 1 ], // Only password field
- [ 'html/basic4.html', 3 ], // Username/passwd/TOTP fields
- [ 'html/div1.html', 2, '#toggle' ], // Fields are behind a button that must be pressed
- [ 'html/div2.html', 2, '#toggle' ], // Fields are behind a button that must be pressed behind a JavaScript
- [ 'html/div3.html', 2, '#toggle' ], // Fields are behind a button that must be pressed
- [ 'html/div4.html', 2, '#toggle' ], // Fields are behind a button that must be pressed
- [ 'html/hidden_fields1.html', 0 ], // Two hidden fields
- [ 'html/hidden_fields2.html', 1 ], // Two hidden fields with one visible
+ // Div ID, expected fields, action element ID (a button to be clicked)
+ const testDivs = [
+ [ 'basic1', 2 ], // Username/passwd fields
+ [ 'basic2', 1 ], // Only username field
+ [ 'basic3', 1 ], // Only password field
+ [ 'basic4', 3 ], // Username/passwd/TOTP fields
+ [ 'div1', 2, '#toggle1' ], // Fields are behind a button that must be pressed
+ [ 'div2', 2, '#toggle2' ], // Fields are behind a button that must be pressed behind a JavaScript
+ [ 'div3', 2, '#toggle3' ], // Fields are behind a button that must be pressed
+ [ 'div4', 2, '#toggle4' ], // Fields are behind a button that must be pressed
+ [ 'hiddenFields1', 0 ], // Two hidden fields
+ [ 'hiddenFields2', 1 ], // Two hidden fields with one visible
];
- for (const file of localFiles) {
- await assertInputFields(file[0], file[1], file[2]);
+ for (const div of testDivs) {
+ await assertInputFields(div[0], div[1], div[2]);
}
-
- document.getElementById('testFile').hidden = true;
}
// Search fields (kpxcFields
@@ -140,20 +138,18 @@ async function testTotpFields() {
// Password change
async function testPasswordChange() {
- // Local filename, expected new password
- const localFiles = [
- [ 'html/passwordchange1.html', 'newPassword' ], // Default order without form
- [ 'html/passwordchange2.html', 'newPassword' ], // Reversed order without form
- [ 'html/passwordchange3.html', 'newPassword' ], // Default order with form
- [ 'html/passwordchange4.html', 'newPassword' ], // Reversed order with form
- [ 'html/passwordchange5.html', 'newPassword' ], // Each field has own form
+ // Div ID, expected new password
+ const localDivs = [
+ [ 'passwordChange1', 'newPassword' ], // Default order without form
+ [ 'passwordChange2', 'newPassword' ], // Reversed order without form
+ [ 'passwordChange3', 'newPassword' ], // Default order with form
+ [ 'passwordChange4', 'newPassword' ], // Reversed order with form
+ [ 'passwordChange5', 'newPassword' ], // Each field has own form
];
- for (const file of localFiles) {
- await assertPasswordChangeFields(file[0], file[1]);
+ for (const div of localDivs) {
+ await assertPasswordChangeFields(div[0], div[1]);
}
-
- document.getElementById('testFile').hidden = true;
}
// Run tests