tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / dom / HTMLBaseElement / script-tests / multiple-base-elements.js
1 description('Test the behavior of multiple base elements.');
2
3 var originalBase = document.URL.replace(/[^/]*$/, "");
4
5 function clean(url)
6 {
7     if (url.length < originalBase.length)
8         return url;
9     if (url.substring(0, originalBase.length) !== originalBase)
10         return url;
11     return "http://originalbase.com/" + url.substring(originalBase.length);
12 }
13
14 var anchor = document.createElement('a');
15 anchor.href = "file";
16
17 document.body.appendChild(anchor);
18
19 shouldBe("clean(anchor.href)", "'http://originalbase.com/file'");
20
21 var base = document.createElement('base');
22 base.href = "http://domain.com/base/";
23
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'");
27
28 base.href = "http://domain.com/base/";
29
30 var base2 = document.createElement('base');
31 base2.href = "http://domain.com/base2/";
32
33 var base3 = document.createElement('base');
34 base3.href = "http://domain.com/base3/";
35
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'");
39
40 document.head.removeChild(base);
41 document.head.removeChild(base2);
42 document.head.removeChild(base3);