Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/infrastructure/urls/dynamic-changes-to-base-urls/historical.sub.xhtml - WPT Dashboard Interop Dashboard
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<head>
<title>Historical xml:base must be removed</title>
<script src="/resources/testharness.js" id="s1"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="div" style="display:none" xml:base=""></div>
<script>
<![CDATA[
var div = document.getElementById("div"),
html = document.getElementById("h"),
url = document.location.href;
var testData = [
{elements: ["a", "link", "area"], set: "href", get: "href"},
{elements: ["q", "blockquote", "ins", "del"], set: "cite", get: "cite"},
{elements: ["audio", "input", "img", "embed", "video", "iframe", "script", "source", "track"], set: "src", get: "src"},
{elements: ["form"], set: "action", get: "action"},
{elements: ["object"], set: "data", get: "data"},
{elements: ["button"], set: "formaction", get: "formAction"}
];
for (var i in testData) {
var item = testData[i];
for (var j in item.elements) {
test(function () {
var ele = document.createElement(item.elements[j]);
ele.setAttribute(item.set, "test.txt");
div.appendChild(ele);
html.setAttribute("xml:base", "");
assert_equals(ele[item.get], url.substr(0, url.lastIndexOf("/")) +"/test.txt", "The '" + item.get + "' attribute is incorrect.");
assert_not_equals(ele[item.get], "http://{{domains[www]}}:{{ports[http][0]}}/test.txt", "The '" + item.get + "' attribute is incorrect.");
}, "The '" + item.set + "' attribute of the '" + item.elements[j] + "' element");
}
}
test(function () {
var s1 = document.getElementById("s1");
var val1 = s1.src;
var val2 = div.firstChild.href;
assert_equals(s1.src, val1, "The outer element must not be effected.");
assert_equals(div.firstChild.href, val2, "The inner element must be effected.");
}, "Change the base URL must not effect the descendant elements");
]]>
</script>
</body>
</html>