summaryrefslogtreecommitdiff
path: root/dom/url
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-08-10 17:47:40 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-21 19:51:21 +0100
commit2e1e954eac00c69c76a6fbbcc343a82516275ca2 (patch)
treeb85e3837e0c32cfec88b704f903cae40796d3ec4 /dom/url
parentc023a51e604fb16f64f93a9ffb59bf18515d9033 (diff)
downloaduxp-2e1e954eac00c69c76a6fbbcc343a82516275ca2.tar.gz
JS - URL - add toJSON support
Diffstat (limited to 'dom/url')
-rw-r--r--dom/url/URL.h6
-rw-r--r--dom/url/tests/test_url.html6
2 files changed, 12 insertions, 0 deletions
diff --git a/dom/url/URL.h b/dom/url/URL.h
index 16b4678baf..45e4dd2894 100644
--- a/dom/url/URL.h
+++ b/dom/url/URL.h
@@ -155,6 +155,12 @@ public:
GetHref(aRetval, aRv);
}
+ void
+ ToJSON(nsAString& aResult, ErrorResult& aRv) const
+ {
+ GetHref(aResult, aRv);
+ }
+
// URLSearchParamsObserver
void
URLSearchParamsUpdated(URLSearchParams* aSearchParams) override;
diff --git a/dom/url/tests/test_url.html b/dom/url/tests/test_url.html
index 3f3f727d63..d07a752bb4 100644
--- a/dom/url/tests/test_url.html
+++ b/dom/url/tests/test_url.html
@@ -438,5 +438,11 @@
url = new URL("data:text/html,<a href=\"http://example.org/?q\">Link</a>");
is(url.href, "data:text/html,<a%20href=\"http://example.org/?q\">Link</a>");
</script>
+
+ <script>
+ var u = new URL('http://www.example.org');
+ ok(u.toJSON(), 'http://www.example.org', "URL.toJSON()");
+ is(JSON.stringify(u), "\"http://www.example.org/\"", "JSON.stringify(u) works");
+ </script>
</body>
</html>