From 66e3d545eb5363cac94e64e4e57e931ef0218494 Mon Sep 17 00:00:00 2001 From: CYBAI Date: Mon, 24 Dec 2018 15:06:30 +0800 Subject: [PATCH] Implement URL's toJSON() --- components/script/dom/url.rs | 5 +++++ components/script/dom/webidls/URL.webidl | 2 ++ tests/wpt/metadata/url/idlharness.any.js.ini | 18 ------------------ tests/wpt/metadata/url/url-tojson.any.js.ini | 9 --------- tests/wpt/metadata/url/url-tojson.html.ini | 5 ----- 5 files changed, 7 insertions(+), 32 deletions(-) delete mode 100644 tests/wpt/metadata/url/url-tojson.any.js.ini delete mode 100644 tests/wpt/metadata/url/url-tojson.html.ini diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 40dda69f3cf..8f489902747 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -279,4 +279,9 @@ impl URLMethods for URL { fn SetUsername(&self, value: USVString) { UrlHelper::SetUsername(&mut self.url.borrow_mut(), value); } + + // https://url.spec.whatwg.org/#dom-url-tojson + fn ToJSON(&self) -> USVString { + self.Href() + } } diff --git a/components/script/dom/webidls/URL.webidl b/components/script/dom/webidls/URL.webidl index c78185cafeb..334100a3bfe 100644 --- a/components/script/dom/webidls/URL.webidl +++ b/components/script/dom/webidls/URL.webidl @@ -24,6 +24,8 @@ interface URL { // static DOMString createFor(Blob blob); static void revokeObjectURL(DOMString url); + USVString toJSON(); + // This is only doing as well as gecko right now. // https://github.com/servo/servo/issues/7590 is on file for // adding attribute stringifier support. diff --git a/tests/wpt/metadata/url/idlharness.any.js.ini b/tests/wpt/metadata/url/idlharness.any.js.ini index 0d20ab439f2..e643f436ad8 100644 --- a/tests/wpt/metadata/url/idlharness.any.js.ini +++ b/tests/wpt/metadata/url/idlharness.any.js.ini @@ -2,18 +2,9 @@ [idlharness] expected: FAIL - [URL interface: operation toJSON()] - expected: FAIL - [URLSearchParams interface: operation sort()] expected: FAIL - [Test toJSON operation of URL] - expected: FAIL - - [URL interface: new URL("http://foo") must inherit property "toJSON()" with the proper type] - expected: FAIL - [Testing Symbol.iterator property of iterable interface URLSearchParams] expected: FAIL @@ -28,18 +19,9 @@ [idlharness] expected: FAIL - [URL interface: operation toJSON()] - expected: FAIL - [URLSearchParams interface: operation sort()] expected: FAIL - [Test toJSON operation of URL] - expected: FAIL - - [URL interface: new URL("http://foo") must inherit property "toJSON()" with the proper type] - expected: FAIL - [Testing Symbol.iterator property of iterable interface URLSearchParams] expected: FAIL diff --git a/tests/wpt/metadata/url/url-tojson.any.js.ini b/tests/wpt/metadata/url/url-tojson.any.js.ini deleted file mode 100644 index 9dc331d5844..00000000000 --- a/tests/wpt/metadata/url/url-tojson.any.js.ini +++ /dev/null @@ -1,9 +0,0 @@ -[url-tojson.any.html] - [url-tojson] - expected: FAIL - - -[url-tojson.any.worker.html] - [url-tojson] - expected: FAIL - diff --git a/tests/wpt/metadata/url/url-tojson.html.ini b/tests/wpt/metadata/url/url-tojson.html.ini deleted file mode 100644 index fcc7e20caa5..00000000000 --- a/tests/wpt/metadata/url/url-tojson.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[url-tojson.html] - type: testharness - [URL's toJSON()] - expected: FAIL -