making feature detection work as intended in chrome

This commit is contained in:
El RIDO 2019-08-27 23:16:06 +02:00
parent 6fcd82fb85
commit a6aef109cc
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
5 changed files with 30 additions and 26 deletions

View file

@ -22,7 +22,6 @@ describe('InitialCheck', function () {
'</body></html>'
);
$.PrivateBin.Alert.init();
window.crypto = null;
const result1 = !$.PrivateBin.InitialCheck.init(),
result2 = !$('#errormessage').hasClass('hidden');
clean();
@ -61,24 +60,19 @@ describe('InitialCheck', function () {
jsc.property(
'shows error, if HTTP only site is detected',
'bool',
jsc.elements(['localhost', '127.0.0.1', '[::1]', '']),
jsc.nearray(common.jscA2zString()),
jsc.elements(['.onion', '.i2p', '']),
function (secureProtocol, localhost, domain, tld) {
const isDomain = localhost === '',
isSecureContext = secureProtocol || !isDomain || tld.length > 0,
clean = jsdom('', {
'url': (secureProtocol ? 'https' : 'http' ) + '://' +
(isDomain ? domain.join('') + tld : localhost) + '/'
function (secureProtocol, domain) {
const clean = jsdom('', {
'url': (secureProtocol ? 'https' : 'http' ) + '://' + domain.join('') + '/'
});
$('body').html(
'<html><body><div id="httpnotice" class="hidden"></div>'+
'</body></html>'
);
$.PrivateBin.Alert.init();
window.crypto = null;
window.crypto = new WebCrypto();
const result1 = $.PrivateBin.InitialCheck.init(),
result2 = isSecureContext === $('#httpnotice').hasClass('hidden');
result2 = secureProtocol === $('#httpnotice').hasClass('hidden');
clean();
return result1 && result2;
}