Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 14 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /mathml/relations/html5-tree/anchor-hyperlinkutils-getter-setter.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8">
<title>MathMLAnchorElement getters and setters</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<math>
<a>anchor</a>
</math>
<script>
// Elements for each test: [property, oldresult, newvalue, newresult, oldurl, newurl]
// [0] [1] [2] [3] [4] [5]
tests = [
["hash", "#somehash", "someother", "#someother",
["hash", "#somehash", "#someother", "#someother",
["host", "google.com:1234", "github.com:4444", "github.com:4444",
["hostname", "google.com", "github.com", "github.com",
["href", "http://google.com:1234/somedir", "http://goo-gle.com:1234/other/x.html", "http://goo-gle.com:1234/other/x.html",
["password", "flabada", "blubb", "blubb",
["pathname", "/somedir/someotherdir/index.html", "/newpath/x.txt", "/newpath/x.txt",
["port", "1234", "4444", "4444", "http://google.com:1234/somedir", "http://google.com:4444/somedir"],
["username", "anonymous", "wellknown", "wellknown",
];
for (var i = 0; i < tests.length; i++) {
test(function (t) {
const [property, oldresult, newval, newresult, oldurl, newurl] = tests[i]
var a = document.querySelector('a');
t.add_cleanup(() => {
a.href = "";
});
a.href = oldurl;
var r1 = a[property];
assert_equals(r1, oldresult);
a[property] = newval;
var r2 = a[property];
assert_equals(r2, newresult);
var r3 = a.href;
assert_equals(r3, newurl);
}, `Getter and setter for attribute of anchor element(${i}): ${tests[i][0]}`);
}
</script>