diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/bindings/test/test_proxy_accessors.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/bindings/test/test_proxy_accessors.html')
-rw-r--r-- | dom/bindings/test/test_proxy_accessors.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/dom/bindings/test/test_proxy_accessors.html b/dom/bindings/test/test_proxy_accessors.html new file mode 100644 index 0000000000..9474369688 --- /dev/null +++ b/dom/bindings/test/test_proxy_accessors.html @@ -0,0 +1,78 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1700052 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1700052</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1700052">Mozilla Bug 1700052</a> +<p id="display"></p> +<form id="theform"></form> +<pre id="test"> +<script> +function expandoTests() { + // Get a DOM proxy with an expando object. Define/redefine a "foo" getter/setter + // and ensure the right function is called. + + var obj = document.getElementById("theform"); + var count1 = 0, count2 = 0, count3 = 0; + var fun1 = function() { count1++; }; + var fun2 = function() { count2++; }; + var fun3 = function() { count3++; }; + + Object.defineProperty(obj, "foo", {configurable: true, get: fun1, set: fun1}); + + for (var i = 0; i < 100; i++) { + obj.foo; + obj.foo = i; + if (i === 50) { + Object.defineProperty(obj, "foo", {configurable: true, get: fun2, set: fun2}); + } else if (i === 80) { + Object.defineProperty(obj, "foo", {configurable: true, get: fun3, set: fun3}); + } + } + + is(count1, 102, "call count for fun1 must match"); + is(count2, 60, "call count for fun2 must match"); + is(count3, 38, "call count for fun3 must match"); +} +expandoTests(); + +function unshadowedTests() { + // Same as above, but for non-shadowing properties on the prototype. + + var obj = document.getElementById("theform"); + var proto = Object.getPrototypeOf(obj); + + var count1 = 0, count2 = 0; + var fun1 = function() { count1++; }; + var fun2 = function() { count2++; }; + + for (var i = 0; i < 100; i++) { + obj.name; + obj.name = "test"; + if (i === 50) { + let desc = Object.getOwnPropertyDescriptor(proto, "name"); + desc.get = desc.set = fun1; + Object.defineProperty(proto, "name", desc); + } + if (i === 90) { + let desc = Object.getOwnPropertyDescriptor(proto, "name"); + desc.get = desc.set = fun2; + Object.defineProperty(proto, "name", desc); + } + } + + is(count1, 80, "call count for fun1 must match"); + is(count2, 18, "call count for fun2 must match"); +} +unshadowedTests(); +</script> +</pre> +</body> +</html> |