diff --git a/js/privatebin.js b/js/privatebin.js index 60db54fb..a512283b 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -1468,7 +1468,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { throw 'password prompt canceled'; } if (password.length === 0) { - // recursive… + // recurse… return me.requestPassword(); } @@ -1476,7 +1476,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) { } /** - * getthe cached password + * get the cached password * * If you do not get a password with this function * (returns an empty string), use requestPassword. diff --git a/js/test.js b/js/test.js index a59885a5..3e6e0775 100644 --- a/js/test.js +++ b/js/test.js @@ -22,6 +22,7 @@ global.sjcl = require('./sjcl-1.0.6'); global.Base64 = require('./base64-2.1.9').Base64; global.RawDeflate = require('./rawdeflate-0.5').RawDeflate; global.RawDeflate.inflate = require('./rawinflate-0.3').RawDeflate.inflate; +require('./bootstrap-3.3.7'); require('./privatebin'); // redirect console messages to log file @@ -1264,3 +1265,40 @@ describe('PasteStatus', function () { }); }); +describe('Prompt', function () { + // TODO: this does not test the prompt() fallback, since that isn't available + // in nodejs -> replace the prompt in the "page" template with a modal + describe('requestPassword & getPassword', function () { + this.timeout(30000); + before(function () { + cleanup(); + }); + + jsc.property( + 'returns the password fed into the dialog', + 'string', + function (password) { + password = password.replace(/\r+/g, ''); + var clean = jsdom('', {url: 'ftp://example.com/#0'}); + $('body').html( + '
{}
' + ); + $.PrivateBin.Model.init(); + $.PrivateBin.Prompt.init(); + $.PrivateBin.Prompt.requestPassword(); + $('#passworddecrypt').val(password); + $('#passwordform').submit(); + var result = $.PrivateBin.Prompt.getPassword(); + clean(); + return result == password; + } + ); + }); +}); + diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index aa574902..37442ff0 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -69,7 +69,7 @@ if ($MARKDOWN): - + diff --git a/tpl/page.php b/tpl/page.php index 67970d26..46e4d7dd 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -47,7 +47,7 @@ if ($MARKDOWN): - +