Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
testEscapeForHTML : function () {
var originalString = "<div class="\"class\"">/</div>";
var escapedForAttrString = "<div class=""class"" id="'id'">/</div>";
var escapedForHTMLString = "<div id='id' class=\"class\">/</div>";
var escapedForAllString = "<div id='id' class="class">/</div>";
this.assertTrue(ariaUtilsString.escapeForHTML(originalString) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, null) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, 5) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, '5') === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, true) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : true
}) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, false) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : false
}) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : true
testEscapeForHTML : function () {
var originalString = "<div class="\"class\"">/</div>";
var escapedForAttrString = "<div class=""class"" id="'id'">/</div>";
var escapedForHTMLString = "<div id='id' class=\"class\">/</div>";
var escapedForAllString = "<div id='id' class="class">/</div>";
this.assertTrue(ariaUtilsString.escapeForHTML(originalString) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, null) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, 5) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, '5') === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, true) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : true
}) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, false) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : false
}) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : true
}) === escapedForAttrString, "Full HTML escape failed.");
var originalString = "<div class="\"class\"">/</div>";
var escapedForAttrString = "<div class=""class"" id="'id'">/</div>";
var escapedForHTMLString = "<div id='id' class=\"class\">/</div>";
var escapedForAllString = "<div id='id' class="class">/</div>";
this.assertTrue(ariaUtilsString.escapeForHTML(originalString) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, null) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, 5) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, '5') === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, true) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : true
}) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, false) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : false
}) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : true
}) === escapedForAttrString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : false
}) === escapedForHTMLString, "Full HTML escape failed.");
},
testEscapeForHTML : function () {
var originalString = "<div class="\"class\"">/</div>";
var escapedForAttrString = "<div class=""class"" id="'id'">/</div>";
var escapedForHTMLString = "<div id='id' class=\"class\">/</div>";
var escapedForAllString = "<div id='id' class="class">/</div>";
this.assertTrue(ariaUtilsString.escapeForHTML(originalString) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, null) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, 5) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, '5') === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, true) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : true
}) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, false) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : false
}) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, null) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, 5) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, '5') === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, true) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : true
}) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, false) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : false
}) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : true
}) === escapedForAttrString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : false
}) === escapedForHTMLString, "Full HTML escape failed.");
},
testEscapeForHTML : function () {
var originalString = "<div class="\"class\"">/</div>";
var escapedForAttrString = "<div class=""class"" id="'id'">/</div>";
var escapedForHTMLString = "<div id='id' class=\"class\">/</div>";
var escapedForAllString = "<div id='id' class="class">/</div>";
this.assertTrue(ariaUtilsString.escapeForHTML(originalString) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, null) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, 5) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, '5') === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, true) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : true,
attr : true
}) === escapedForAllString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, false) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : false
}) === originalString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
text : false,
attr : true
}) === escapedForAttrString, "Full HTML escape failed.");
this.assertTrue(ariaUtilsString.escapeForHTML(originalString, {
var textComparator = function(errorMessage, domElement) {
var expected = errorMessage.localizedMessage;
expected = ariaUtilsString.escapeForHTML(expected, errorMessage.escape);
var actual = getElementHTML(domElement);
return compareCaseInsensitive(actual, expected);
};