| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/set-href-attribute-prevents-rebase.js"></script> | 7 <script> |
| 8 description('Tests that when an href attribute is set, the href is no longer sub
ject to updates to the document base URI.'); |
| 9 |
| 10 var a = document.createElement('a'); |
| 11 var base = document.createElement('base'); |
| 12 document.head.appendChild(base); |
| 13 |
| 14 |
| 15 debug("Search attribute, update document base URI without attribute having been
set"); |
| 16 base.href = "http://old_base/"; |
| 17 a.href = "?search"; |
| 18 base.href = "http://new_base/"; |
| 19 shouldBe("a.href", "'http://new_base/?search'"); |
| 20 |
| 21 debug("Search attribute, update document base URI after attribute has been set")
; |
| 22 base.href = "http://old_base/"; |
| 23 a.href = "?foo"; |
| 24 a.search = "search"; |
| 25 base.href = "http://new_base/"; |
| 26 shouldBe("a.href", "'http://old_base/?search'"); |
| 27 debug(''); |
| 28 |
| 29 |
| 30 debug("Pathname attribute, update document base URI without attribute having bee
n set"); |
| 31 base.href = "http://old_base/"; |
| 32 a.href = "path"; |
| 33 base.href = "http://new_base/"; |
| 34 shouldBe("a.href", "'http://new_base/path'"); |
| 35 |
| 36 debug("Pathname attribute, update document base URI after attribute has been set
"); |
| 37 base.href = "http://old_base/"; |
| 38 a.href = "foo"; |
| 39 a.pathname = "path"; |
| 40 base.href = "http://new_base/"; |
| 41 shouldBe("a.href", "'http://old_base/path'"); |
| 42 debug(''); |
| 43 |
| 44 |
| 45 debug("Hash attribute, update document base URI without attribute having been se
t"); |
| 46 base.href = "http://old_base/"; |
| 47 a.href = "#hash"; |
| 48 base.href = "http://new_base/"; |
| 49 shouldBe("a.href", "'http://new_base/#hash'"); |
| 50 |
| 51 debug("Pathname attribute, update document base URI after attribute has been set
"); |
| 52 base.href = "http://old_base/"; |
| 53 a.href = "#foo"; |
| 54 a.hash = "hash"; |
| 55 base.href = "http://new_base/"; |
| 56 shouldBe("a.href", "'http://old_base/#hash'"); |
| 57 debug(''); |
| 58 |
| 59 |
| 60 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.'); |
| 61 debug(''); |
| 62 |
| 63 |
| 64 debug("Host attribute, update document base URI without attribute having been se
t"); |
| 65 base.href = "http://old_base/"; |
| 66 a.href = "http://host:0"; |
| 67 base.href = "http://new_base/"; |
| 68 shouldBe("a.href", "'http://host:0/'"); |
| 69 |
| 70 debug("Host attribute, update document base URI after attribute has been set"); |
| 71 base.href = "http://old_base/"; |
| 72 a.href = "http://foo:80"; |
| 73 a.host = "host:0"; |
| 74 base.href = "http://new_base/"; |
| 75 shouldBe("a.href", "'http://host:0/'"); |
| 76 debug(''); |
| 77 |
| 78 |
| 79 debug("Hostname attribute, update document base URI without attribute having bee
n set"); |
| 80 base.href = "http://old_base/"; |
| 81 a.href = "http://host"; |
| 82 base.href = "http://new_base/"; |
| 83 shouldBe("a.href", "'http://host/'"); |
| 84 |
| 85 debug("Hostname attribute, update document base URI after attribute has been set
"); |
| 86 base.href = "http://old_base/"; |
| 87 a.href = "http://foo"; |
| 88 a.hostname = "host"; |
| 89 base.href = "http://new_base/"; |
| 90 shouldBe("a.href", "'http://host/'"); |
| 91 debug(''); |
| 92 |
| 93 |
| 94 debug("Protocol attribute, update document base URI without attribute having bee
n set"); |
| 95 base.href = "http://old_base/"; |
| 96 a.href = "protocol:"; |
| 97 base.href = "http://new_base/"; |
| 98 shouldBe("a.href", "'protocol:'"); |
| 99 |
| 100 debug("Protocol attribute, update document base URI after attribute has been set
"); |
| 101 base.href = "http://old_base/"; |
| 102 a.href = "foo:"; |
| 103 a.protocol = "protocol:"; |
| 104 base.href = "http://new_base/"; |
| 105 shouldBe("a.href", "'protocol:'"); |
| 106 debug(''); |
| 107 |
| 108 |
| 109 debug("Port attribute, update document base URI without attribute having been se
t"); |
| 110 base.href = "http://old_base/"; |
| 111 a.href = "http://host:0"; |
| 112 base.href = "http://new_base/"; |
| 113 shouldBe("a.href", "'http://host:0/'"); |
| 114 |
| 115 debug("Port attribute, update document base URI after attribute has been set"); |
| 116 base.href = "http://old_base/"; |
| 117 a.href = "http://host:80"; |
| 118 a.port = 0; |
| 119 base.href = "http://new_base/"; |
| 120 shouldBe("a.href", "'http://host:0/'"); |
| 121 debug(''); |
| 122 |
| 123 |
| 124 base.href = ''; |
| 125 </script> |
| 8 </body> | 126 </body> |
| 9 </html> | 127 </html> |
| OLD | NEW |