Skip to content
Snippets Groups Projects
Commit 0061b5e5 authored by Pavlich Phillip's avatar Pavlich Phillip
Browse files

Testcases for UI are complete

parent 70fc5d98
No related branches found
No related tags found
1 merge request!8Browser action Merging
......@@ -44,7 +44,7 @@
Domain:
</div>
<div class="col-xs-9">
<input class="inputbox" id="domain" type="text" value="Domain" readonly>
<input class="inputbox" id="domain" type="text" value="Domain" >
</div>
<div class="col-xs-3">
UserKey:
......@@ -80,5 +80,8 @@
<!--Links to JavaScript Scripts that execute behind the scenes actions -->
<script src="js/browser_action.js"></script>
<script src="./../module/dist/bundle.js"></script>
<!--uncomment below if testing to UI is being done -->
<script src="js/browser_action_Testing.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -92,19 +92,5 @@ This code also calls on other scripts for password data. */
})()
/*
function generate() {
alert("here");
var masterPassword = document.getElementById('master').value
var output = document.getElementById('output')
alert("here1");
var p = new PretzelPass()
alert("here2");
p.setSalt(salt)
alert("here3");
p.setOptions(JSON.parse(localStorage['options' + domain] || localStorage['options'] || '{}'))
alert("here4");
var generatedPassword = p.generatePassword(masterPassword, domain)
alert("here5");
output.value = generatedPassword
}*/
var test = require('tape')
var browserAction = require('./browser_action')
/*This file is used for testing the user interface */
test('passwords are the same', function (t) {
var p = new browserAction()
var p2 = new browserAction()
var pass1 = p.generatePassword('abc123', 'http://google.com')
var pass2 = p.generatePassword('abc123', 'http://google.com')
var pass3 = p2.generatePassword('abc123', 'http://google.com')
t.equals(pass1, pass2, 'password should be the same')
t.equals(pass2, pass3, 'password should be the same')
console.log(pass1, pass2, pass3)
t.end()
})
(function(){
/*This function tests the ability for the user key button to hide and
unhide the text for the user key*/
function testingUserKeyHidden(){
var togglePasswordField = document.getElementById('togglePasswordField')
var passField = document.getElementById('master')
togglePasswordField.addEventListener('click', function () {
console.log("TestCase 1: ")
console.log("The user key button has been clicked")
if (passField.type === 'text') {
console.log("User Key type was text!")
console.log("User Key type is now password!")
} else {
console.log("User Key type was password!")
console.log("User Key type is now text!")
}
})
/*
test('passwords are different', function (t) {
var p = new PretzelPass()
var pass1a = p.generatePassword('abc123', 'http://google.com')
var pass1b = p.generatePassword('abc12', 'http://google.com')
var pass2a = p.generatePassword('abc124', 'http://google.com')
var pass2b = p.generatePassword('abc124', 'http://googl.com')
t.notEquals(pass1a, pass1b, 'password should not be the same with different master key')
t.notEquals(pass2a, pass2b, 'password should not be the same with different domain')
console.log(pass1a, pass1b, pass2a, pass2b)
t.end()
})
}
testingUserKeyHidden()
test('test long password', function (t) {
var p = new PretzelPass()
p.setOptions({
length: 1000,
})
var pass1 = p.generatePassword('master', 'https://reddit.com')
t.equals(1000, pass1.length, 'password should have correct length')
t.end()
})
/*This function tests the info button to verify that it
correctly displays the help information*/
function testingInfoButton(){
var begin = true
var infoButton = document.getElementById('infobtn')
var instructions = document.getElementById('how')
var htmlpage = document.getElementById('page')
test('constraints', function (t) {
var p = new PretzelPass()
p.setOptions({
length: 20,
minCharacters: {
special: 2,
number: 2,
letter: 2,
alphaNum: 2,
lowerCase: 2,
upperCase: 2
},
algorithm: 'sha256',
rounds: 1
})
var pass1 = p.generatePassword('master', 'https://reddit.com')
infoButton.addEventListener('click', function () {
console.log("TestCase 2: ")
console.log("The info button has been clicked!")
/*The other script is run prior to switch the value. Testing must be opposite */
if (begin === true || instructions.style.display !== 'none') {
console.log("The help information should now be visible!")
begin = false
} else {
console.log("The help information should no longer visible!")
}
})
}
testingInfoButton()
t.equals(20, pass1.length, 'password should have correct length')
t.equals('.:49unIyozAQS2xwsww9', pass1, 'password should generate with constraints')
t.end()
})
*/
\ No newline at end of file
/*This function tests the programs ability to get the correct
domain of the current tab upon clicking on the main page */
function testingTabChanged (tab) {
var wholePage = document.getElementById('page')
wholePage.addEventListener('click', function () {
console.log("TestCase 3: ")
var domainField = document.getElementById('domain')
chrome.tabs.getSelected(null, function (tab) {
domain = new URL(tab.url).hostname
console.log("This is the value of the actual domain: "+ domain)
})
var domainFieldNew = document.getElementById('domain')
console.log("This is the value of the domain box: "+domainFieldNew.value)
})
}
testingTabChanged()
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
})()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment