mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Auto merge of #11632 - achals:master, r=KiChjang
Implement URL.domainToUnicode Fixes #11629 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11629 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes: Some expected test failures have been removed. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11632) <!-- Reviewable:end -->
This commit is contained in:
commit
21687b0f30
5 changed files with 37 additions and 10 deletions
|
@ -13,6 +13,7 @@ use dom::urlhelper::UrlHelper;
|
||||||
use dom::urlsearchparams::URLSearchParams;
|
use dom::urlsearchparams::URLSearchParams;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
use url::quirks::domain_to_unicode;
|
||||||
use url::{Host, Url};
|
use url::{Host, Url};
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#url
|
// https://url.spec.whatwg.org/#url
|
||||||
|
@ -100,6 +101,10 @@ impl URL {
|
||||||
USVString("".to_owned())
|
USVString("".to_owned())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn DomainToUnicode(_: GlobalRef, origin: USVString) -> USVString {
|
||||||
|
USVString(domain_to_unicode(&origin.0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl URLMethods for URL {
|
impl URLMethods for URL {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
Exposed=(Window,Worker)*/]
|
Exposed=(Window,Worker)*/]
|
||||||
interface URL {
|
interface URL {
|
||||||
static USVString domainToASCII(USVString domain);
|
static USVString domainToASCII(USVString domain);
|
||||||
// static USVString domainToUnicode(USVString domain);
|
static USVString domainToUnicode(USVString domain);
|
||||||
|
|
||||||
[SetterThrows]
|
[SetterThrows]
|
||||||
/*stringifier*/ attribute USVString href;
|
/*stringifier*/ attribute USVString href;
|
||||||
|
|
|
@ -36028,7 +36028,16 @@
|
||||||
"local_changes": {
|
"local_changes": {
|
||||||
"deleted": [],
|
"deleted": [],
|
||||||
"deleted_reftests": {},
|
"deleted_reftests": {},
|
||||||
"items": {},
|
"items": {
|
||||||
|
"testharness": {
|
||||||
|
"url/url-domainToUnicode.html": [
|
||||||
|
{
|
||||||
|
"path": "url/url-domainToUnicode.html",
|
||||||
|
"url": "/url/url-domainToUnicode.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"reftest_nodes": {}
|
"reftest_nodes": {}
|
||||||
},
|
},
|
||||||
"reftest_nodes": {
|
"reftest_nodes": {
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
[interfaces.html]
|
|
||||||
type: testharness
|
|
||||||
[URL interface: operation domainToUnicode(ScalarValueString)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[URL interface: operation domainToUnicode(USVString)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
21
tests/wpt/web-platform-tests/url/url-domainToUnicode.html
Normal file
21
tests/wpt/web-platform-tests/url/url-domainToUnicode.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title></title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script>
|
||||||
|
test(function() {
|
||||||
|
var domain = 'example.org'
|
||||||
|
assert_true(URL.domainToUnicode(domain) === domain, 'Ascii domain should be parsed correctly.')
|
||||||
|
}, 'URL.domainToUnicode valid input')
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var domain = 'xn--maana-pta.com'
|
||||||
|
assert_true(URL.domainToUnicode(domain) === 'mañana.com', ' Ascii encoded domain should be parsed correctly.')
|
||||||
|
}, 'URL.domainToUnicode valid encoded input')
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var domain = 'http://not.a.domain'
|
||||||
|
assert_true(URL.domainToUnicode(domain) === "", 'Invalid domain should be return an empty string.')
|
||||||
|
}, 'URL.domainToUnicode invalid input')
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue