Index: LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-searchParams.js |
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-searchParams.js b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-searchParams.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cd0f62487585552584cd5a64360d506f6a4499de |
--- /dev/null |
+++ b/LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-searchParams.js |
@@ -0,0 +1,40 @@ |
+description('Test handling of the searchParams attribute of the URL in HTMLAnchorElement.'); |
+ |
+var a = document.createElement('a'); |
+ |
+debug("Inspect single name-value via searchParams"); |
+a.href = "https://www.mydomain.com/path/?key=value"; |
+shouldBeTrue("a.searchParams.has('key')"); |
+shouldBeEqualToString("a.searchParams.get('key')", "value"); |
+shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?key=value"); |
+ |
+debug("Add name-value pair using searchParams"); |
+a.href = "https://www.mydomain.com/path/"; |
+a.searchParams.append("k e y", "value"); |
+shouldBeTrue("a.searchParams.has('k e y')"); |
+shouldBeEqualToString("a.searchParams.get('k e y')", "value"); |
+shouldBeEqualToString("a.search", "?k+e+y=value"); |
+shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?k+e+y=value"); |
+ |
+debug("Update name-value pair using searchParams"); |
+a.href = "https://www.mydomain.com/path/?key=value"; |
+a.searchParams.set("key", "newvalue"); |
+shouldBeTrue("a.searchParams.has('key')"); |
+shouldBeEqualToString("a.searchParams.get('key')", "newvalue"); |
+shouldBeEqualToString("a.search", "?key=newvalue"); |
+shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?key=newvalue"); |
+ |
+debug("Remove name-value pair using searchParams"); |
+a.href = "https://www.mydomain.com/path/?key=value"; |
+a.searchParams.delete("key"); |
+shouldBeFalse("a.searchParams.has('key')"); |
+shouldBeEqualToString("a.search", ""); |
+shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?"); |
+ |
+debug("Have searchParams reflect removed name-value pairs"); |
+a.href = "https://www.mydomain.com/path/?key=value"; |
+var searchParams = a.searchParams; |
+shouldBeTrue("searchParams.has('key')"); |
+a.search = ""; |
+shouldBeFalse("searchParams.has('key')"); |
+shouldBeEqualToString("a.href", "https://www.mydomain.com/path/?"); |