diff --git a/dom/url/URL.h b/dom/url/URL.h
index 9d40ca9cf03c..9080bca79471 100644
--- a/dom/url/URL.h
+++ b/dom/url/URL.h
@@ -151,6 +151,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 533a79f402ec..73e75667d8db 100644
--- a/dom/url/tests/test_url.html
+++ b/dom/url/tests/test_url.html
@@ -450,5 +450,11 @@
url = new URL("data:text/html,Link");
is(url.href, "data:text/html,Link");
+
+