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

Use RangeError for TextEncoder/TextDecoder #5620

Closed
Ms2ger opened this issue Apr 9, 2015 · 18 comments
Closed

Use RangeError for TextEncoder/TextDecoder #5620

Ms2ger opened this issue Apr 9, 2015 · 18 comments

Comments

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Apr 9, 2015

Blocks #5601.

To fix this bug, you'll first need to implement RangeError exceptions. This should be analogous to the TypeError implementation that already exists in components/script/dom/bindings/error.rs. I'd extend get_error_message to accept one error number for TypeError and one for RangeError, and create a second static like ERROR_FORMAT_STRING that uses JSEXN_RANGEERR.

Then you'll need to return Err(Error::Range) in the places that currently have TODO/FIXME comments mentioning "RangeError".

Bonus point for writing additional tests for the case where the encoding argument is not an encoding at all.

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 9, 2015

I'd like to give this a try.

@jdm
Copy link
Member

@jdm jdm commented Apr 9, 2015

Go for it!

@jdm jdm added the C-assigned label Apr 9, 2015
aneeshusa added a commit to aneeshusa/servo that referenced this issue Apr 10, 2015
Fix the TODOs and FIXMEs to comply with the spec. Fixes servo#5620.
@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 10, 2015

A few questions about the tests.

  • Test naming: I had to change some of the test description strings in order to get the tests to pass. The test logic itself in the functions passed to test() is fine, but for some reason the test name seems to be affecting the test results.
    • Is changing the test names the correct way to fix this, or is there a better way to do it? The test logic looks fine as is, and changing the name was not intuitive for me and took me a long time to guess. The function passed to test() should encode all of the necessary information, so I don't see why the test name should be a factor.
    • Out of curiousity, why/how does this work? I think that having a 'not' present in the name is setting whether or not the test is expected to PASS or FAIL, but I'm not sure - I couldn't find the name field being accessed in any meaningful way in the test runner.
  • GBK Encoding: This is a special case, and it's the only test that doesn't work after twiddling test names.
    • The spec says that the gbk decoder is the gb18030 decoder.
    • The encoding crate we use lumps them together and says that the gbk labels map to gb18030, which I think is reasonable.
    • Our tests say that each encoding should map to itself, which is also reasonable. This implies gbk should map to the gbk decoder, which happens to be the gbk18030 decoder under the hood.
    • Firefox reports a gbk decoder for gbk, as does Chromium.
    • Should I change the test case or should we consider this an upstream bug?

I'll look into writing the not-even-an-encoding test cases once I get the current set to pass.

@jdm
Copy link
Member

@jdm jdm commented Apr 10, 2015

@aneeshusa: Expected test result come from the ini files under tests/wpt/meta, like http://mxr.mozilla.org/servo/source/tests/wpt/metadata/encoding/api-replacement-encodings.html.ini . If you're seeing output like "PASS expected FAIL", that means that your changes are causing the checks to succeed, but the ini files currently record an expected failure instead. Does that clear it up?

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 10, 2015

OK, thanks, that's a much better explanation than name-changing voodoo. I've gotten the rest of the tests to pass, what should I do about the gbk test (see my previous comment)?

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 10, 2015

Also, is there an official way to only run certain wpt tests via mach? I've been using a hacky solution, but if there's a better way that would be much appreciated.

@Ms2ger
Copy link
Contributor Author

@Ms2ger Ms2ger commented Apr 10, 2015

./mach test-wpt --include ...; I'll need to investigate what's up with gbk

@jdm
Copy link
Member

@jdm jdm commented Apr 10, 2015

You can also just run ./mach test tests/wpt/web-platform-tests/subdir or even ./mach test tests/wpt/web-platform-tests/path/to/file.html.

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 10, 2015

Also, as far as I can tell the rust-encoding crate is wrong about the whatwg name for utf-16le and utf-16, so I'll put in a PR upstream.

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 10, 2015

Perfect, the --include option is what I was looking for. Thanks!

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 10, 2015

Btw, my thoughts on gbk are that gbk should map to gbk instead of gbk18030, as per the spec, implying a fix would be needed upstream.

@Ms2ger
Copy link
Contributor Author

@Ms2ger Ms2ger commented Apr 12, 2015

Gbk looks like it needs an upstream fix, yeah.

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 12, 2015

Just put in the PR for utf-16le. Working on one for gbk right now, and investigating a potential issue with hz-gb-2312.

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 13, 2015

The utf-16le PR just got merged, and I also just put in a PR to fix GBK encoding.

@lifthrasiir
Copy link

@lifthrasiir lifthrasiir commented Apr 13, 2015

cc me

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 13, 2015

I just tried to bump the components/script crate's version dependency on the encoding crate to 0.2.30, which includes the utf-16le changes so I could test if they worked. Unfortunately, something is limiting the version number to 0.2.25, and I haven't been able to figure out which crate is the cause; the error message isn't very informative and grep isn't helping either. Does anyone know which crate is the impediment?

@aneeshusa
Copy link
Member

@aneeshusa aneeshusa commented Apr 13, 2015

Also, I opened an issue for a deviation from the spec for hz-gb-2312; if the current implementation is kept it isn't too hard to work around in servo (just an extra pattern in a match statement), so I'm not too worried about which way that goes.

@Ms2ger
Copy link
Contributor Author

@Ms2ger Ms2ger commented Apr 13, 2015

I would suggest just fixing the RangeError issue, and your upstream changes will be pulled in at some point later.

bors-servo pushed a commit that referenced this issue Apr 14, 2015
…textdecoder, r=Ms2ger

Fixes #5620, and adds a few extra test cases.

Currently waiting on a few upstream PRs in rust-encoding to land.
aneeshusa added a commit to aneeshusa/servo that referenced this issue Apr 14, 2015
Fixes servo#5620.
Fix the TODOs and FIXMEs to comply with the spec.
Add test case for passing invalid invalid labels.
Update test metadata; three test cases have been resolved upstream and
will be fixed whenever the rust-encoding dependency is sufficiently upgraded.
bors-servo pushed a commit that referenced this issue Apr 14, 2015
…textdecoder, r=jdm

Fixes #5620, and adds a few extra test cases.

Currently waiting on a few upstream PRs in rust-encoding to land.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5659)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.