| OLD | NEW |
| (Empty) |
| 1 description('Tests that when an href attribute is set, the href is no longer sub
ject to updates to the document base URI.'); | |
| 2 | |
| 3 var a = document.createElement('a'); | |
| 4 var base = document.createElement('base'); | |
| 5 document.head.appendChild(base); | |
| 6 | |
| 7 | |
| 8 debug("Search attribute, update document base URI without attribute having been
set"); | |
| 9 base.href = "http://old_base/"; | |
| 10 a.href = "?search"; | |
| 11 base.href = "http://new_base/"; | |
| 12 shouldBe("a.href", "'http://new_base/?search'"); | |
| 13 | |
| 14 debug("Search attribute, update document base URI after attribute has been set")
; | |
| 15 base.href = "http://old_base/"; | |
| 16 a.href = "?foo"; | |
| 17 a.search = "search"; | |
| 18 base.href = "http://new_base/"; | |
| 19 shouldBe("a.href", "'http://old_base/?search'"); | |
| 20 debug(''); | |
| 21 | |
| 22 | |
| 23 debug("Pathname attribute, update document base URI without attribute having bee
n set"); | |
| 24 base.href = "http://old_base/"; | |
| 25 a.href = "path"; | |
| 26 base.href = "http://new_base/"; | |
| 27 shouldBe("a.href", "'http://new_base/path'"); | |
| 28 | |
| 29 debug("Pathname attribute, update document base URI after attribute has been set
"); | |
| 30 base.href = "http://old_base/"; | |
| 31 a.href = "foo"; | |
| 32 a.pathname = "path"; | |
| 33 base.href = "http://new_base/"; | |
| 34 shouldBe("a.href", "'http://old_base/path'"); | |
| 35 debug(''); | |
| 36 | |
| 37 | |
| 38 debug("Hash attribute, update document base URI without attribute having been se
t"); | |
| 39 base.href = "http://old_base/"; | |
| 40 a.href = "#hash"; | |
| 41 base.href = "http://new_base/"; | |
| 42 shouldBe("a.href", "'http://new_base/#hash'"); | |
| 43 | |
| 44 debug("Pathname attribute, update document base URI after attribute has been set
"); | |
| 45 base.href = "http://old_base/"; | |
| 46 a.href = "#foo"; | |
| 47 a.hash = "hash"; | |
| 48 base.href = "http://new_base/"; | |
| 49 shouldBe("a.href", "'http://old_base/#hash'"); | |
| 50 debug(''); | |
| 51 | |
| 52 | |
| 53 debug('Note that for the following attributes, updating the document base URI ha
s no effect because we have to use an abosulte URL for the href in order to set
an initial value for the attribute we wish to update. They are included for comp
leteness.'); | |
| 54 debug(''); | |
| 55 | |
| 56 | |
| 57 debug("Host attribute, update document base URI without attribute having been se
t"); | |
| 58 base.href = "http://old_base/"; | |
| 59 a.href = "http://host:0"; | |
| 60 base.href = "http://new_base/"; | |
| 61 shouldBe("a.href", "'http://host:0/'"); | |
| 62 | |
| 63 debug("Host attribute, update document base URI after attribute has been set"); | |
| 64 base.href = "http://old_base/"; | |
| 65 a.href = "http://foo:80"; | |
| 66 a.host = "host:0"; | |
| 67 base.href = "http://new_base/"; | |
| 68 shouldBe("a.href", "'http://host:0/'"); | |
| 69 debug(''); | |
| 70 | |
| 71 | |
| 72 debug("Hostname attribute, update document base URI without attribute having bee
n set"); | |
| 73 base.href = "http://old_base/"; | |
| 74 a.href = "http://host"; | |
| 75 base.href = "http://new_base/"; | |
| 76 shouldBe("a.href", "'http://host/'"); | |
| 77 | |
| 78 debug("Hostname attribute, update document base URI after attribute has been set
"); | |
| 79 base.href = "http://old_base/"; | |
| 80 a.href = "http://foo"; | |
| 81 a.hostname = "host"; | |
| 82 base.href = "http://new_base/"; | |
| 83 shouldBe("a.href", "'http://host/'"); | |
| 84 debug(''); | |
| 85 | |
| 86 | |
| 87 debug("Protocol attribute, update document base URI without attribute having bee
n set"); | |
| 88 base.href = "http://old_base/"; | |
| 89 a.href = "protocol:"; | |
| 90 base.href = "http://new_base/"; | |
| 91 shouldBe("a.href", "'protocol:'"); | |
| 92 | |
| 93 debug("Protocol attribute, update document base URI after attribute has been set
"); | |
| 94 base.href = "http://old_base/"; | |
| 95 a.href = "foo:"; | |
| 96 a.protocol = "protocol:"; | |
| 97 base.href = "http://new_base/"; | |
| 98 shouldBe("a.href", "'protocol:'"); | |
| 99 debug(''); | |
| 100 | |
| 101 | |
| 102 debug("Port attribute, update document base URI without attribute having been se
t"); | |
| 103 base.href = "http://old_base/"; | |
| 104 a.href = "http://host:0"; | |
| 105 base.href = "http://new_base/"; | |
| 106 shouldBe("a.href", "'http://host:0/'"); | |
| 107 | |
| 108 debug("Port attribute, update document base URI after attribute has been set"); | |
| 109 base.href = "http://old_base/"; | |
| 110 a.href = "http://host:80"; | |
| 111 a.port = 0; | |
| 112 base.href = "http://new_base/"; | |
| 113 shouldBe("a.href", "'http://host:0/'"); | |
| 114 debug(''); | |
| 115 | |
| 116 | |
| 117 base.href = ''; | |
| OLD | NEW |