OLD | NEW |
(Empty) | |
| 1 description('Test handling of the searchParams attribute of the URL in HTMLAncho
rElement.'); |
| 2 |
| 3 var a = document.createElement('a'); |
| 4 |
| 5 debug("Inspect single name-value via searchParams"); |
| 6 a.href = "https://www.mydomain.com/path/?key=value"; |
| 7 shouldBeTrue("a.searchParams.has('key')"); |
| 8 shouldBeEqualToString("a.searchParams.get('key')", "value"); |
| 9 shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?key=value"); |
| 10 |
| 11 debug("Add name-value pair using searchParams"); |
| 12 a.href = "https://www.mydomain.com/path/"; |
| 13 a.searchParams.append("k e y", "value"); |
| 14 shouldBeTrue("a.searchParams.has('k e y')"); |
| 15 shouldBeEqualToString("a.searchParams.get('k e y')", "value"); |
| 16 shouldBeEqualToString("a.search", "?k+e+y=value"); |
| 17 shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?k+e+y=value"); |
| 18 |
| 19 debug("Update name-value pair using searchParams"); |
| 20 a.href = "https://www.mydomain.com/path/?key=value"; |
| 21 a.searchParams.set("key", "newvalue"); |
| 22 shouldBeTrue("a.searchParams.has('key')"); |
| 23 shouldBeEqualToString("a.searchParams.get('key')", "newvalue"); |
| 24 shouldBeEqualToString("a.search", "?key=newvalue"); |
| 25 shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?key=newvalue"); |
| 26 |
| 27 debug("Remove name-value pair using searchParams"); |
| 28 a.href = "https://www.mydomain.com/path/?key=value"; |
| 29 a.searchParams.delete("key"); |
| 30 shouldBeFalse("a.searchParams.has('key')"); |
| 31 shouldBeEqualToString("a.search", ""); |
| 32 shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?"); |
| 33 |
| 34 debug("Have searchParams reflect removed name-value pairs"); |
| 35 a.href = "https://www.mydomain.com/path/?key=value"; |
| 36 var searchParams = a.searchParams; |
| 37 shouldBeTrue("searchParams.has('key')"); |
| 38 a.search = ""; |
| 39 shouldBeFalse("searchParams.has('key')"); |
| 40 shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?"); |
OLD | NEW |