diff options
| author | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-05-16 14:01:00 -0400 |
|---|---|---|
| committer | Tianren Dong <tianrendong.dtr@gmail.com> | 2026-05-16 14:01:00 -0400 |
| commit | b792f22f2c2ef4dfb7bd300e7381a186e34e0c18 (patch) | |
| tree | a31a4e6d1213478f5ac96e2208d1a1c16fc825b9 /test-suite/challenges/39-strict-csp-fallback.js | |
| parent | f133011c8ecda06ae63068649a9714c88a7b901e (diff) | |
0.15.25: fix reload after stale singleton
Diffstat (limited to 'test-suite/challenges/39-strict-csp-fallback.js')
| -rw-r--r-- | test-suite/challenges/39-strict-csp-fallback.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test-suite/challenges/39-strict-csp-fallback.js b/test-suite/challenges/39-strict-csp-fallback.js new file mode 100644 index 0000000..4f2d91e --- /dev/null +++ b/test-suite/challenges/39-strict-csp-fallback.js @@ -0,0 +1,27 @@ +Challenge.init({ id: "strict-csp-fallback", instructions: "use screenshot/coordinates; click CSP TARGET" }); + +const btn = document.getElementById("cspTarget"); +btn.style.cssText = [ + "position:fixed", + "left:220px", + "top:220px", + "width:180px", + "height:72px", + "font:700 16px system-ui", + "background:#1f7a1f", + "color:white", + "border:0", + "border-radius:10px", + "box-shadow:0 0 0 4px rgba(31,122,31,.25)" +].join(";"); + +document.getElementById("cspTarget").addEventListener("click", (e) => { + const r = btn.getBoundingClientRect(); + const bad = []; + if (!e.isTrusted) bad.push("click isTrusted=false"); + if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) { + bad.push(`click coordinates ${e.clientX},${e.clientY} outside target rect ${Math.round(r.left)},${Math.round(r.top)},${Math.round(r.right)},${Math.round(r.bottom)}`); + } + if (bad.length) Challenge.fail(...bad); + else Challenge.pass("strict CSP page completed via trusted viewport click"); +}); |
