diff options
Diffstat (limited to 'Base/res')
-rw-r--r-- | Base/res/html/misc/private-element-test.html | 63 | ||||
-rw-r--r-- | Base/res/html/misc/welcome.html | 1 |
2 files changed, 64 insertions, 0 deletions
diff --git a/Base/res/html/misc/private-element-test.html b/Base/res/html/misc/private-element-test.html new file mode 100644 index 0000000000..1a9d669298 --- /dev/null +++ b/Base/res/html/misc/private-element-test.html @@ -0,0 +1,63 @@ +<html> + <body> + <span + >If passed, the text below should say: "Passed" And the iframe should have loaded</span + > + <div id="result">Starting up</div> + <script> + class Base { + constructor(o) { + return o; + } + } + + class Stamper extends Base { + #x = 10; + static hasX(o) { + return #x in o; + } + } + + let failed = false; + function status(text, fail = false) { + console.log("Status", text, fail, failed); + const output = document.getElementById("result"); + if (fail) { + output.innerHTML += "Fail: " + text + "<br />"; + output.style.color = "red"; + failed = true; + } else if (!failed) { + output.innerHTML = text; + output.style.color = "blue"; + } + } + + function fail(text) { + return status(text, true); + } + + status("Running"); + + const iframe = document.body.appendChild(document.createElement("iframe")); + iframe.src = "file:///res/html/misc/welcome.html"; + iframe.onload = () => { + status("Inside onload", false); + // FIXME: Also test on contentWindow itself once that is an actual WindowProxy. + const locationObject = iframe.contentWindow.location; + try { + new Stamper(locationObject); + fail("Should have thrown type error!"); + } catch (e) { + if (!(e instanceof TypeError)) + fail("Should have thrown type error! But threw: " + e); + } + if (Stamper.hasX(locationObject)) { + fail("Stamped #x on Location"); + } else { + status("Passed"); + } + }; + status("Set src and onload, waiting for onload"); + </script> + </body> +</html> diff --git a/Base/res/html/misc/welcome.html b/Base/res/html/misc/welcome.html index 0ff3d086e8..e3462f0cde 100644 --- a/Base/res/html/misc/welcome.html +++ b/Base/res/html/misc/welcome.html @@ -170,6 +170,7 @@ <li><a href="async-js.html">Basic test for async functions and their integration with the LibWeb event loop</a></li> <li><a href="worker_parent.html">Workers</a></li> <li><a href="storage.html">Web Storage API</a></li> + <li><a href="private-element-test.html">Test for rejecting private elements on special objects</a></li> <li><h3>Canvas</h3></li> <li><a href="canvas.html">canvas 2D test</a></li> <li><a href="canvas-rotate.html">canvas rotate()</a></li> |