| OLD | NEW |
| (Empty) | |
| 1 <?xml version="1.0" encoding="UTF-8"?> |
| 2 <!DOCTYPE html> |
| 3 <html id="h" xmlns="http://www.w3.org/1999/xhtml" xml:base=""> |
| 4 <head> |
| 5 <title>HTML Test: Dynamic changes to base URLs</title> |
| 6 <link rel="author" title="Intel" href="http://www.intel.com/"/> |
| 7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dynamic-chang
es-to-base-urls" /> |
| 8 <script src="/resources/testharness.js" id="s1"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 </head> |
| 11 <body> |
| 12 <div id="log"></div> |
| 13 <div id="div" style="display:none" xml:base=""></div> |
| 14 <script> |
| 15 <![CDATA[ |
| 16 var div = document.getElementById("div"), |
| 17 html = document.getElementById("h"), |
| 18 url = document.location.href; |
| 19 |
| 20 var testData = [ |
| 21 {elements: ["a", "link", "area"], set: "href", get: "href"}, |
| 22 {elements: ["q", "blockquote", "ins", "del"], set: "cite", get: "cite"}, |
| 23 {elements: ["img", "embed", "video", "iframe", "script", "source", "trac
k"], set: "src", get: "src"}, |
| 24 {elements: ["form"], set: "action", get: "action"}, |
| 25 {elements: ["object"], set: "data", get: "data"}, |
| 26 {elements: ["button"], set: "formaction", get: "formAction"} |
| 27 ]; |
| 28 |
| 29 for (var i in testData) { |
| 30 var item = testData[i]; |
| 31 for (var j in item.elements) { |
| 32 test(function () { |
| 33 var ele = document.createElement(item.elements[j]); |
| 34 |
| 35 ele.setAttribute(item.set, "test.txt"); |
| 36 div.appendChild(ele); |
| 37 |
| 38 html.setAttribute("xml:base", ""); |
| 39 assert_equals(ele[item.get], url.substr(0, url.lastIndexOf("/")) +"/
test.txt", "The '" + item.get + "' attribute is incorrect."); |
| 40 html.setAttribute("xml:base", "http://{{domains[www]}}:{{ports[http]
[0]}}"); |
| 41 assert_equals(ele[item.get], "http://{{domains[www]}}:{{ports[http][
0]}}/test.txt", "The '" + item.get + "' attribute is incorrect."); |
| 42 }, "The '" + item.set + "' attribute of the '" + item.elements[j] + "'
element"); |
| 43 } |
| 44 } |
| 45 |
| 46 test(function () { |
| 47 var s1 = document.getElementById("s1"); |
| 48 var val1 = s1.src; |
| 49 var val2 = div.firstChild.href; |
| 50 |
| 51 div.setAttribute("xml:base", "http://{{domains[www2]}}:{{ports[http][0]}
}"); |
| 52 assert_equals(s1.src, val1, "The outer element must not be effected."); |
| 53 assert_not_equals(div.firstChild.href, val2, "The inner element must be
effected."); |
| 54 assert_equals(div.firstChild.href, "http://{{domains[www2]}}:{{ports[htt
p][0]}}/test.txt"); |
| 55 }, "Change the base URL must effect the descendant elements only"); |
| 56 ]]> |
| 57 </script> |
| 58 </body> |
| 59 </html> |
| OLD | NEW |