Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: LayoutTests/fast/dom/HTMLAnchorElement/script-tests/set-href-attribute-searchParams.js

Issue 143313002: Implement URLSearchParams. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More tests + ref count unattached URLSearchParams objects Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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/?");

Powered by Google App Engine
This is Rietveld 408576698