add tests

This commit is contained in:
Erik Krogh Kristensen
2022-03-01 16:12:18 +01:00
parent 559f03ebbc
commit fc79242674
2 changed files with 32 additions and 1 deletions

View File

@@ -466,3 +466,25 @@ function domMethods() {
let cell = row.insertCell();
cell.innerHTML = source; // NOT OK
}
function urlStuff() {
var url = document.location.search.substr(1);
$("<a>", {href: url}).appendTo("body"); // NOT OK - but not detected [INCONSISTENCY]
$("#foo").attr("href", url); // NOT OK - but not detected [INCONSISTENCY]
$("#foo").attr({href: url}); // NOT OK - but not detected [INCONSISTENCY]
$("<img>", {src: url}).appendTo("body"); // NOT OK - but not detected [INCONSISTENCY]
$("<a>", {href: win.location.href}).appendTo("body"); // OK
$("<img>", {src: "http://google.com/" + url}).appendTo("body"); // OK
$("<img>", {src: ["http://google.com", url].join("/")}).appendTo("body"); // OK
if (url.startsWith("https://")) {
$("<img>", {src: url}).appendTo("body"); // OK
} else {
$("<img>", {src: url}).appendTo("body"); // NOT OK - but not detected [INCONSISTENCY]
}
window.open(location.hash.substr(1)); // OK - any JavaScript is executed in another context
}

View File

@@ -72,4 +72,13 @@ function quz() {
var payload = history.location.hash.substr(1);
history.replace(payload); // NOT OK
}
}
function bar() {
var url = document.location.search.substr(1);
$("<a>", {href: url}).appendTo("body"); // NOT OK - but not detected [INCONSISTENCY]
$("#foo").attr("href", url); // NOT OK - but not detected [INCONSISTENCY]
$("#foo").attr({href: url}); // NOT OK - but not detected [INCONSISTENCY]
$("<img>", {src: url}).appendTo("body"); // NOT OK - but not detected [INCONSISTENCY]
}