wpt / svg / linking / scripted / xlink-href-compat.html

Status: FAIL | Duration: 56ms | Subtests: 0/12 | Open test on wpt.live | wpt.fyi

Data from commit:
a50cb89 wpt: run reference-named files which are themselves tests (#836) (2026-09-03)

SubtestStatusMessage
XLink 'href' backwards compatibility, IDL href backed by "href" after setAttribute(href).FAILnot a callable function
XLink 'href' backwards compatibility, IDL href backed by "xlink:href" after setAttribute(xlink:href).FAILnot a callable function
XLink 'href' backwards compatibility, IDL href backed by "href" after baseVal setter.FAILcannot convert 'null' or 'undefined' to object
XLink 'href' backwards compatibility, IDL href reflects "href"; setAttribute(xlink:href) does not override baseVal setter.FAILcannot convert 'null' or 'undefined' to object
XLink 'href' backwards compatibility, IDL href prefers "href" over "xlink:href" after setAttribute(href) overrides.FAILnot a callable function
XLink 'href' backwards compatibility, IDL href reflects "xlink:href"; setAttribute(xlink:href) w/ NS-prefix.FAILnot a callable function
XLink 'href' backwards compatibility, IDL href reflects "xlink:href" after removeAttribute(href).FAILnot a callable function
XLink 'href' backwards compatibility, IDL href reflects "xlink:href"; removeAttribute(xlink:href) has no effect.FAILnot a callable function
XLink 'href' backwards compatibility, IDL href reflects "xlink:href"; removeAttribute(xlink:href) resets to default.FAILnot a callable function
XLink 'href' backwards compatibility, IDL href reflects "xlink:href"; removeAttribute(xlink:href) w/o NS-prefix resets to default.FAILnot a callable function
XLink 'href' backwards compatibility, href.animVal reflects "xlink:href" when it is set.FAILnot a callable function
XLink 'href' backwards compatibility, href.animVal reflects "href" when it is set.FAILnot a callable function

/svg/linking/scripted/xlink-href-compat.html

<!DOCTYPE html>
<title>XLink 'href' backwards compatibility</title>
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/linking.html#XLinkRefAttrs">
<link rel="help" href="https://w3c.github.io/svgwg/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>