Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement URL.domainToUnicode #11632

Merged
merged 1 commit into from Jun 6, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Implement URL.domainToUnicode

  • Loading branch information
achals committed Jun 6, 2016
commit a727fd2d6207fc9cf1215d0031b2c904f396590c
@@ -13,6 +13,7 @@ use dom::urlhelper::UrlHelper;
use dom::urlsearchparams::URLSearchParams;
use std::borrow::ToOwned;
use std::default::Default;
use url::quirks::domain_to_unicode;
use url::{Host, Url};

// https://url.spec.whatwg.org/#url
@@ -100,6 +101,10 @@ impl URL {
USVString("".to_owned())
}
}

pub fn DomainToUnicode(_: GlobalRef, origin: USVString) -> USVString {
USVString(domain_to_unicode(&origin.0))
}
}

impl URLMethods for URL {
@@ -7,7 +7,7 @@
Exposed=(Window,Worker)*/]
interface URL {
static USVString domainToASCII(USVString domain);
// static USVString domainToUnicode(USVString domain);
static USVString domainToUnicode(USVString domain);

[SetterThrows]
/*stringifier*/ attribute USVString href;
"local_changes": {
"deleted": [],
"deleted_reftests": {},
"items": {},
"items": {
"testharness": {
"url/url-domainToUnicode.html": [
{
"path": "url/url-domainToUnicode.html",
"url": "/url/url-domainToUnicode.html"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {

This file was deleted.

@@ -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>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.