tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 2360ca36aacf887ac54a354b8f7ecc90515fddd6
parent 493a31c88954ca5f9f4a979fc488e37e80168049
Author: Fredrik Söderquist <fs@opera.com>
Date:   Tue, 16 Dec 2025 08:45:58 +0000

Bug 2005574 [wpt PR 56687] - Export svg/dom/href-semantics.html to WPT, a=testonly

Automatic update from web-platform-tests
Export svg/dom/href-semantics.html to WPT

Rename to xlink-href-compat.html. Do some minor touch ups (var -> const,
add spec links).

In response to https://github.com/w3c/svgwg/issues/1043

Change-Id: I84c2b6f2e7b37d4cf64d858254c3ce4d40037fff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7252369
Reviewed-by: Philip Rogers <pdr@chromium.org>
Auto-Submit: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1557468}

--

wpt-commits: a6d1a6d151dac407ea1ab773f54f9b897bcae7bc
wpt-pr: 56687

Diffstat:
Atesting/web-platform/tests/svg/linking/scripted/xlink-href-compat.html | 157+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 157 insertions(+), 0 deletions(-)

diff --git a/testing/web-platform/tests/svg/linking/scripted/xlink-href-compat.html b/testing/web-platform/tests/svg/linking/scripted/xlink-href-compat.html @@ -0,0 +1,157 @@ +<!DOCTYPE html> +<title>XLink 'href' backwards compatibility</title> +<link rel="help" href="https://svgwg.org/svg2-draft/linking.html#XLinkRefAttrs"> +<link rel="help" href="https://svgwg.org/svg2-draft/linking.html#linkRefAttrs"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +const svgNs = 'http://www.w3.org/2000/svg'; +const xlinkNs = 'http://www.w3.org/1999/xlink'; + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(null, 'href', 'foo'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist'); + assert_equals(element.href.baseVal, 'foo'); + + element.href.baseVal = 'bar'; + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still does not exist'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists'); + assert_equals(element.getAttributeNS(null, 'href'), 'bar'); +}, document.title+', IDL href backed by "href" after setAttribute(href).'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(xlinkNs, 'href', 'foo'); + assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_equals(element.href.baseVal, 'foo'); + + element.href.baseVal = 'bar'; + assert_false(element.hasAttributeNS(null, 'href'), '"href" still does not exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exists'); + assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar'); +}, document.title+', IDL href backed by "xlink:href" after setAttribute(xlink:href).'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.href.baseVal = 'foo'; + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); + assert_equals(element.href.baseVal, 'foo'); +}, document.title+', IDL href backed by "href" after baseVal setter.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.href.baseVal = 'foo'; + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); + assert_equals(element.href.baseVal, 'foo'); + + element.setAttributeNS(xlinkNs, 'href', 'bar'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" still exists'); + assert_equals(element.href.baseVal, 'foo', 'baseVal still reflects "href"'); + assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'bar'); +}, document.title+', IDL href reflects "href"; setAttribute(xlink:href) does not override baseVal setter.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(xlinkNs, 'href', 'baz'); + element.href.baseVal = 'foo'; + assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_equals(element.href.baseVal, 'foo'); + assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo'); + + element.setAttributeNS(null, 'href', 'bar'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exists'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); + assert_equals(element.href.baseVal, 'bar', 'baseVal prefers "href" to "xlink:href"'); + assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo'); + assert_equals(element.getAttributeNS(null, 'href'), 'bar'); +}, document.title+', IDL href prefers "href" over "xlink:href" after setAttribute(href) overrides.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(xlinkNs, 'href', 'foo'); + assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_equals(element.href.baseVal, 'foo'); + assert_equals(element.getAttributeNS(xlinkNs, 'href'), 'foo'); + + element.setAttributeNS(xlinkNs, 'xlink:href', 'bar'); + assert_equals(element.href.baseVal, 'bar'); +}, document.title+', IDL href reflects "xlink:href"; setAttribute(xlink:href) w/ NS-prefix.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(null, 'href', 'foo'); + element.setAttributeNS(xlinkNs, 'href', 'bar'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); + assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"'); + + element.removeAttributeNS(null, 'href'); + assert_false(element.hasAttributeNS(null, 'href'), '"href" no longer exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" still exist'); + assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"'); +}, document.title+', IDL href reflects "xlink:href" after removeAttribute(href).'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(null, 'href', 'foo'); + element.setAttributeNS(xlinkNs, 'href', 'bar'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); + assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"'); + + element.removeAttributeNS(xlinkNs, 'href'); + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" still exist'); + assert_equals(element.href.baseVal, 'foo', 'baseVal reflects "href"'); +}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) has no effect.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(xlinkNs, 'href', 'bar'); + assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"'); + + element.removeAttributeNS(xlinkNs, 'href'); + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist'); + assert_equals(element.href.baseVal, ''); +}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) resets to default.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(xlinkNs, 'xlink:href', 'bar'); + assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"'); + + element.removeAttributeNS(xlinkNs, 'href'); + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" no longer exist'); + assert_equals(element.href.baseVal, ''); +}, document.title+', IDL href reflects "xlink:href"; removeAttribute(xlink:href) w/o NS-prefix resets to default.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(xlinkNs, 'xlink:href', 'bar'); + assert_false(element.hasAttributeNS(null, 'href'), '"href" does not exist'); + assert_true(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" exists'); + assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "xlink:href"'); + assert_equals(element.href.animVal, 'bar', 'animVal reflects "xlink:href"'); +}, document.title+', href.animVal reflects "xlink:href" when it is set.'); + +test(function() { + const element = document.createElementNS(svgNs, 'a'); + element.setAttributeNS(null, 'href', 'bar'); + assert_true(element.hasAttributeNS(null, 'href'), '"href" exists'); + assert_false(element.hasAttributeNS(xlinkNs, 'href'), '"xlink:href" does not exist'); + assert_equals(element.href.baseVal, 'bar', 'baseVal reflects "href"'); + assert_equals(element.href.animVal, 'bar', 'animVal reflects "href"'); +}, document.title+', href.animVal reflects "href" when it is set.'); +</script>