Files
sousa-gecko/testing/web-platform/tests/svg/struct/SVGSVGElement-currentTranslate-SameObject.html
T
Karl Dubost 155ea38acc Bug 2051481 [wpt PR 60985] - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=318044, a=testonly
Automatic update from web-platform-tests
WebKit export of https://bugs.webkit.org/show_bug.cgi?id=318044 (#60985)
--

wpt-commits: 02453451e40ac14c80849d1c50316a39725ccd60
wpt-pr: 60985
2026-07-10 09:21:45 +00:00

41 lines
1.7 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>SVGSVGElement.currentTranslate is [SameObject]</title>
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/struct.html#__svg__SVGSVGElement__currentTranslate">
<link rel="help" href="https://webidl.spec.whatwg.org/#SameObject">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100" height="100"></svg>
<script>
const svg = document.getElementById("svg");
test(() => {
assert_equals(svg.currentTranslate, svg.currentTranslate);
}, "currentTranslate returns the same object on consecutive reads ([SameObject])");
test(() => {
const p = svg.currentTranslate;
p.x = 10;
assert_equals(svg.currentTranslate, p, "same object after mutating x");
}, "currentTranslate identity is stable across value changes");
test(() => {
svg.currentTranslate.x = 42;
assert_equals(svg.currentTranslate.x, 42);
}, "mutations through currentTranslate are observable on re-read");
test(() => {
svg.currentTranslate.x = 7;
svg.currentTranslate.y = 9;
const replacement = svg.createSVGPoint();
replacement.x = 100;
replacement.y = 200;
// Assignment to a readonly attribute is ignored (silently in non-strict mode).
// Asserted on the value, not object identity, so this isolates readonly from
// [SameObject]: an engine that fails identity still passes this if it honors readonly.
try { svg.currentTranslate = replacement; } catch (e) {}
assert_equals(svg.currentTranslate.x, 7, "x value unchanged");
assert_equals(svg.currentTranslate.y, 9, "y value unchanged");
}, "currentTranslate is readonly; assignment does not change the value");
</script>