mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-10-01 01:26:10 -04:00
making feature detection work as intended in chrome
This commit is contained in:
parent
6fcd82fb85
commit
a6aef109cc
@ -566,10 +566,10 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
|
|
||||||
// if $element is given, apply text to element
|
// if $element is given, apply text to element
|
||||||
if ($element !== null) {
|
if ($element !== null) {
|
||||||
// get last text node of element
|
// set the last text node of element
|
||||||
let content = $element.contents();
|
let content = $element.contents();
|
||||||
if (content.length > 1) {
|
if (content.length > 1) {
|
||||||
content[content.length - 1].nodeValue = ' ' + output;
|
$element.html(' ' + output).prepend(content[0]);
|
||||||
} else {
|
} else {
|
||||||
$element.text(output);
|
$element.text(output);
|
||||||
}
|
}
|
||||||
@ -4803,11 +4803,21 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
*/
|
*/
|
||||||
function isOldBrowser() {
|
function isOldBrowser() {
|
||||||
// webcrypto support
|
// webcrypto support
|
||||||
if (typeof window.crypto !== 'object') {
|
if (!(
|
||||||
|
'crypto' in window &&
|
||||||
|
'getRandomValues' in window.crypto &&
|
||||||
|
'subtle' in window.crypto &&
|
||||||
|
'encrypt' in window.crypto.subtle &&
|
||||||
|
'decrypt' in window.crypto.subtle &&
|
||||||
|
'Uint32Array' in window
|
||||||
|
)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof WebAssembly !== 'object' && typeof WebAssembly.instantiate !== 'function') {
|
if (!(
|
||||||
|
'WebAssembly' in window &&
|
||||||
|
'instantiate' in window.WebAssembly
|
||||||
|
)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -10,7 +10,7 @@ describe('Alert', function () {
|
|||||||
function (icon, message) {
|
function (icon, message) {
|
||||||
icon = icon.join('');
|
icon = icon.join('');
|
||||||
message = message.join('');
|
message = message.join('');
|
||||||
var expected = '<div id="status" role="alert" ' +
|
const expected = '<div id="status" role="alert" ' +
|
||||||
'class="statusmessage alert alert-info"><span ' +
|
'class="statusmessage alert alert-info"><span ' +
|
||||||
'class="glyphicon glyphicon-' + icon +
|
'class="glyphicon glyphicon-' + icon +
|
||||||
'" aria-hidden="true"></span> ' + message + '</div>';
|
'" aria-hidden="true"></span> ' + message + '</div>';
|
||||||
@ -21,7 +21,7 @@ describe('Alert', function () {
|
|||||||
);
|
);
|
||||||
$.PrivateBin.Alert.init();
|
$.PrivateBin.Alert.init();
|
||||||
$.PrivateBin.Alert.showStatus(message, icon);
|
$.PrivateBin.Alert.showStatus(message, icon);
|
||||||
var result = $('body').html();
|
const result = $('body').html();
|
||||||
return expected === result;
|
return expected === result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -39,7 +39,7 @@ describe('Alert', function () {
|
|||||||
function (icon, message) {
|
function (icon, message) {
|
||||||
icon = icon.join('');
|
icon = icon.join('');
|
||||||
message = message.join('');
|
message = message.join('');
|
||||||
var expected = '<div id="errormessage" role="alert" ' +
|
const expected = '<div id="errormessage" role="alert" ' +
|
||||||
'class="statusmessage alert alert-danger"><span ' +
|
'class="statusmessage alert alert-danger"><span ' +
|
||||||
'class="glyphicon glyphicon-' + icon +
|
'class="glyphicon glyphicon-' + icon +
|
||||||
'" aria-hidden="true"></span> ' + message + '</div>';
|
'" aria-hidden="true"></span> ' + message + '</div>';
|
||||||
@ -50,7 +50,7 @@ describe('Alert', function () {
|
|||||||
);
|
);
|
||||||
$.PrivateBin.Alert.init();
|
$.PrivateBin.Alert.init();
|
||||||
$.PrivateBin.Alert.showError(message, icon);
|
$.PrivateBin.Alert.showError(message, icon);
|
||||||
var result = $('body').html();
|
const result = $('body').html();
|
||||||
return expected === result;
|
return expected === result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -69,7 +69,7 @@ describe('Alert', function () {
|
|||||||
function (message, string, number) {
|
function (message, string, number) {
|
||||||
message = message.join('');
|
message = message.join('');
|
||||||
string = string.join('');
|
string = string.join('');
|
||||||
var expected = '<div id="remainingtime" role="alert" ' +
|
const expected = '<div id="remainingtime" role="alert" ' +
|
||||||
'class="alert alert-info"><span ' +
|
'class="alert alert-info"><span ' +
|
||||||
'class="glyphicon glyphicon-fire" aria-hidden="true">' +
|
'class="glyphicon glyphicon-fire" aria-hidden="true">' +
|
||||||
'</span> ' + string + message + number + '</div>';
|
'</span> ' + string + message + number + '</div>';
|
||||||
@ -80,7 +80,7 @@ describe('Alert', function () {
|
|||||||
);
|
);
|
||||||
$.PrivateBin.Alert.init();
|
$.PrivateBin.Alert.init();
|
||||||
$.PrivateBin.Alert.showRemaining(['%s' + message + '%d', string, number]);
|
$.PrivateBin.Alert.showRemaining(['%s' + message + '%d', string, number]);
|
||||||
var result = $('body').html();
|
const result = $('body').html();
|
||||||
return expected === result;
|
return expected === result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -98,7 +98,7 @@ describe('Alert', function () {
|
|||||||
function (message, icon) {
|
function (message, icon) {
|
||||||
message = message.join('');
|
message = message.join('');
|
||||||
icon = icon.join('');
|
icon = icon.join('');
|
||||||
var defaultMessage = 'Loading…';
|
const defaultMessage = 'Loading…';
|
||||||
if (message.length === 0) {
|
if (message.length === 0) {
|
||||||
message = defaultMessage;
|
message = defaultMessage;
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ describe('Alert', function () {
|
|||||||
);
|
);
|
||||||
$.PrivateBin.Alert.init();
|
$.PrivateBin.Alert.init();
|
||||||
$.PrivateBin.Alert.showLoading(message, icon);
|
$.PrivateBin.Alert.showLoading(message, icon);
|
||||||
var result = $('body').html();
|
const result = $('body').html();
|
||||||
return expected === result;
|
return expected === result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -182,7 +182,7 @@ describe('Alert', function () {
|
|||||||
jsc.array(common.jscAlnumString()),
|
jsc.array(common.jscAlnumString()),
|
||||||
function (trigger, message) {
|
function (trigger, message) {
|
||||||
message = message.join('');
|
message = message.join('');
|
||||||
var handlerCalled = false,
|
let handlerCalled = false,
|
||||||
defaultMessage = 'Loading…',
|
defaultMessage = 'Loading…',
|
||||||
functions = [
|
functions = [
|
||||||
$.PrivateBin.Alert.showStatus,
|
$.PrivateBin.Alert.showStatus,
|
||||||
|
@ -22,7 +22,6 @@ describe('InitialCheck', function () {
|
|||||||
'</body></html>'
|
'</body></html>'
|
||||||
);
|
);
|
||||||
$.PrivateBin.Alert.init();
|
$.PrivateBin.Alert.init();
|
||||||
window.crypto = null;
|
|
||||||
const result1 = !$.PrivateBin.InitialCheck.init(),
|
const result1 = !$.PrivateBin.InitialCheck.init(),
|
||||||
result2 = !$('#errormessage').hasClass('hidden');
|
result2 = !$('#errormessage').hasClass('hidden');
|
||||||
clean();
|
clean();
|
||||||
@ -61,24 +60,19 @@ describe('InitialCheck', function () {
|
|||||||
jsc.property(
|
jsc.property(
|
||||||
'shows error, if HTTP only site is detected',
|
'shows error, if HTTP only site is detected',
|
||||||
'bool',
|
'bool',
|
||||||
jsc.elements(['localhost', '127.0.0.1', '[::1]', '']),
|
|
||||||
jsc.nearray(common.jscA2zString()),
|
jsc.nearray(common.jscA2zString()),
|
||||||
jsc.elements(['.onion', '.i2p', '']),
|
function (secureProtocol, domain) {
|
||||||
function (secureProtocol, localhost, domain, tld) {
|
const clean = jsdom('', {
|
||||||
const isDomain = localhost === '',
|
'url': (secureProtocol ? 'https' : 'http' ) + '://' + domain.join('') + '/'
|
||||||
isSecureContext = secureProtocol || !isDomain || tld.length > 0,
|
|
||||||
clean = jsdom('', {
|
|
||||||
'url': (secureProtocol ? 'https' : 'http' ) + '://' +
|
|
||||||
(isDomain ? domain.join('') + tld : localhost) + '/'
|
|
||||||
});
|
});
|
||||||
$('body').html(
|
$('body').html(
|
||||||
'<html><body><div id="httpnotice" class="hidden"></div>'+
|
'<html><body><div id="httpnotice" class="hidden"></div>'+
|
||||||
'</body></html>'
|
'</body></html>'
|
||||||
);
|
);
|
||||||
$.PrivateBin.Alert.init();
|
$.PrivateBin.Alert.init();
|
||||||
window.crypto = null;
|
window.crypto = new WebCrypto();
|
||||||
const result1 = $.PrivateBin.InitialCheck.init(),
|
const result1 = $.PrivateBin.InitialCheck.init(),
|
||||||
result2 = isSecureContext === $('#httpnotice').hasClass('hidden');
|
result2 = secureProtocol === $('#httpnotice').hasClass('hidden');
|
||||||
clean();
|
clean();
|
||||||
return result1 && result2;
|
return result1 && result2;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ if ($MARKDOWN):
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-aACEZbSPO13YywWwP/gTTBdZgYlKuDfKAJU5PJyqVRsuZiT7rAAhFRf1KdF8OX8QFHqTrQhQ47qlFtIslJMnkg==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-wPZVhFyyfvXUeXfRMp8hDUmYd5kG/sbCPiCdn+J+4t8YQNGuhXNa7g992HayQOQuiZeCU4/VczTaoGrQgsyjkg==" crossorigin="anonymous"></script>
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -49,7 +49,7 @@ if ($MARKDOWN):
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-aACEZbSPO13YywWwP/gTTBdZgYlKuDfKAJU5PJyqVRsuZiT7rAAhFRf1KdF8OX8QFHqTrQhQ47qlFtIslJMnkg==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-wPZVhFyyfvXUeXfRMp8hDUmYd5kG/sbCPiCdn+J+4t8YQNGuhXNa7g992HayQOQuiZeCU4/VczTaoGrQgsyjkg==" crossorigin="anonymous"></script>
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
Loading…
Reference in New Issue
Block a user