|
19 | 19 |
|
20 | 20 | SimpleTest.waitForExplicitFinish(); |
21 | 21 | addEventListener("__taintreport", (report) => { |
22 | | - SimpleTest.is(report.detail.str, "tainted=hello", "Check sink string content"); |
23 | | - |
| 22 | + if(i == 0) { |
| 23 | + SimpleTest.is(report.detail.str, "url", "Check sink string content"); |
| 24 | + } else { |
| 25 | + SimpleTest.is(report.detail.str, "console.log();", "Check sink string content"); |
| 26 | + } |
24 | 27 | let flow = report.detail.str.taint[0].flow; |
25 | | - SimpleTest.is(flow[2].operation, sink_names[i]); |
| 28 | + SimpleTest.is(flow[2].operation, sink_names[i], `${sink_names[i]} sink test`); |
26 | 29 |
|
27 | 30 | i += 1; |
28 | 31 | if (i >= sink_names.length) { |
29 | 32 | SimpleTest.finish(); |
30 | 33 | } |
31 | 34 | }, false); |
32 | 35 |
|
| 36 | + function setScriptProperty(text, f) { |
| 37 | + let script = document.createElement("script"); |
| 38 | + script.id = "tempscript"; |
| 39 | + f(script, text); |
| 40 | + document.body.appendChild(script); |
| 41 | + document.body.removeChild(script); |
| 42 | + } |
| 43 | + |
33 | 44 | function startTest() { |
34 | | - let tainted = String.tainted("tainted=hello"); |
35 | | - let script = document.getElementById("emptyScript"); |
36 | | - script.src = tainted; |
37 | | - script.text = tainted; |
38 | | - script.innerHTML = tainted; |
39 | | - script.textContent = tainted; |
| 45 | + let tainted = String.tainted("console.log();"); |
| 46 | + setScriptProperty(String.tainted("url"), (s,t) => s.src = t); |
| 47 | + setScriptProperty(tainted, (s,t) => s.text = t); |
| 48 | + setScriptProperty(tainted, (s,t) => s.innerHTML = t); |
| 49 | + setScriptProperty(tainted, (s,t) => s.textContent = t); |
40 | 50 | } |
41 | 51 |
|
42 | 52 | </script> |
43 | | - <script id="emptyScript"> |
44 | | - </script> |
| 53 | + |
45 | 54 | </head> |
46 | 55 |
|
47 | 56 | <body onload="startTest();"> |
|
0 commit comments