| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | |
| 8 description('Test the behavior of multiple base elements.'); | |
| 9 | |
| 10 var originalBase = document.URL.replace(/[^/]*$/, ""); | |
| 11 | |
| 12 function clean(url) | |
| 13 { | |
| 14 if (url.length < originalBase.length) | |
| 15 return url; | |
| 16 if (url.substring(0, originalBase.length) !== originalBase) | |
| 17 return url; | |
| 18 return "http://originalbase.com/" + url.substring(originalBase.length); | |
| 19 } | |
| 20 | |
| 21 var anchor = document.createElement('a'); | |
| 22 anchor.href = "file"; | |
| 23 | |
| 24 document.body.appendChild(anchor); | |
| 25 | |
| 26 shouldBe("clean(anchor.href)", "'http://originalbase.com/file'"); | |
| 27 | |
| 28 var base = document.createElement('base'); | |
| 29 base.href = "http://domain.com/base/"; | |
| 30 | |
| 31 shouldBe("document.head.appendChild(base), clean(anchor.href)", "'http://domain.
com/base/file'"); | |
| 32 shouldBe("base.href = 'http://domain.com/base-changed/', clean(anchor.href)", "'
http://domain.com/base-changed/file'"); | |
| 33 shouldBe("document.head.removeChild(base), clean(anchor.href)", "'http://origina
lbase.com/file'"); | |
| 34 | |
| 35 base.href = "http://domain.com/base/"; | |
| 36 | |
| 37 var base2 = document.createElement('base'); | |
| 38 base2.href = "http://domain.com/base2/"; | |
| 39 | |
| 40 var base3 = document.createElement('base'); | |
| 41 base3.href = "http://domain.com/base3/"; | |
| 42 | |
| 43 shouldBe("document.head.appendChild(base), document.head.appendChild(base2), cle
an(anchor.href)", "'http://domain.com/base/file'"); | |
| 44 shouldBe("base.removeAttribute('href'), clean(anchor.href)", "'http://domain.com
/base2/file'"); | |
| 45 shouldBe("document.head.appendChild(base3), clean(anchor.href)", "'http://domain
.com/base2/file'"); | |
| 46 | |
| 47 document.head.removeChild(base); | |
| 48 document.head.removeChild(base2); | |
| 49 document.head.removeChild(base3); | |
| 50 </script> | |
| 51 </body> | |
| 52 </html> | |
| OLD | NEW |