1 description('Test the behavior of multiple base elements.');
3 var originalBase = document.URL.replace(/[^/]*$/, "");
7 if (url.length < originalBase.length)
9 if (url.substring(0, originalBase.length) !== originalBase)
11 return "http://originalbase.com/" + url.substring(originalBase.length);
14 var anchor = document.createElement('a');
17 document.body.appendChild(anchor);
19 shouldBe("clean(anchor.href)", "'http://originalbase.com/file'");
21 var base = document.createElement('base');
22 base.href = "http://domain.com/base/";
24 shouldBe("document.head.appendChild(base), clean(anchor.href)", "'http://domain.com/base/file'");
25 shouldBe("base.href = 'http://domain.com/base-changed/', clean(anchor.href)", "'http://domain.com/base-changed/file'");
26 shouldBe("document.head.removeChild(base), clean(anchor.href)", "'http://originalbase.com/file'");
28 base.href = "http://domain.com/base/";
30 var base2 = document.createElement('base');
31 base2.href = "http://domain.com/base2/";
33 var base3 = document.createElement('base');
34 base3.href = "http://domain.com/base3/";
36 shouldBe("document.head.appendChild(base), document.head.appendChild(base2), clean(anchor.href)", "'http://domain.com/base/file'");
37 shouldBe("base.removeAttribute('href'), clean(anchor.href)", "'http://domain.com/base2/file'");
38 shouldBe("document.head.appendChild(base3), clean(anchor.href)", "'http://domain.com/base2/file'");
40 document.head.removeChild(base);
41 document.head.removeChild(base2);
42 document.head.removeChild(base3);