wpt icon indicating copy to clipboard operation
wpt copied to clipboard

url: Added test cases for IDN-encoded input, valid and invalid.

Open mgiuca opened this issue 7 years ago • 5 comments

In particular, exposes implementation bugs around URLs with "xn--" prefix but containing non-ASCII characters (https://crbug.com/804688).

Tested against:

  • https://jsdom.github.io (all tests pass)
  • Google Chrome 70. These tests fail:
    • sc://xn--fa-hia.ExAmPlE/ and sc://xn--abcd.com/ (due to unrelated issue)
    • https://xn--abcd.com/ (expected to throw)
    • https://ab--abcdé.com/ (throws, due to https://crbug.com/804688)
  • Firefox 62. These tests fail:
    • sc://xn--fa-hia.ExAmPlE/ and sc://xn--abcd.com/ (due to unrelated issue)
    • https://xn--abcd.com/ (expected to throw)
    • https://xn--abcdé.com/ (expected to throw)

Re the case https://xn--abcd.com/: Given that both Chrome and Firefox agree that an invalid IDN-encoded domain should pass through unmodified, it's possible the spec should be updated to allow this. This would probably entail modifying domain to ASCII, replacing "If result is a failure value, validation error, return failure." with "If result is a failure value, validation error, then if result is an ASCII string, return result, else return failure."

But for the time being, I think we should land a test matching the specified text.

Edit: Updated with Firefox results and paragraph about changing the spec.

mgiuca avatar Sep 10 '18 03:09 mgiuca

w3c-test:mirror

GPHemsley avatar Sep 10 '18 04:09 GPHemsley

As I commented on the crbug, there’s a lot of history in this. See https://github.com/whatwg/url/commit/dc9d83106cada9af507bf37dee3973de97b020fd and the linked tickets. For this PR, you might want to dedupe the tests against the existing ones in https://github.com/web-platform-tests/wpt/blob/master/url/resources/toascii.json, and add the tests to that file.

TimothyGu avatar Sep 10 '18 05:09 TimothyGu

@TimothyGu Thanks. I didn't realise there were tests for this in toascii.json. Looks like the right place to have these (though maybe there should be at least one end-to-end test in url-constructor as well).

However, I can't find any way to run the toascii tests in a browser. It doesn't seem to have an associated .html file like url-constructor.html. How do you run these tests?

FYI I've updated the PR description with some more analysis including Firefox.

mgiuca avatar Sep 10 '18 05:09 mgiuca

toascii.window.js can be run as toascii.window.html. See https://web-platform-tests.org/writing-tests/testharness.html#auto-generated-test-boilerplate for documentation.

annevk avatar Sep 10 '18 08:09 annevk

w3c-test:mirror

GPHemsley avatar Jan 12 '19 03:01 GPHemsley

I think we have sufficient IDN coverage at this point.

annevk avatar Mar 03 '25 11:03 annevk