-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Yves,
On 09/29/2015 03:25 PM, Yves Lafon wrote: > Hi, In XHR [1], setRequestHeader is defined by this: [[ void > setRequestHeader(ByteString name, ByteString value); ]] It has a > note: [[ Throws a SyntaxError exception if name is not a header > name or if value is not a header value. ]] > > In WebIDL [2], ByteString is defined by the algorithm [[ • Let x be > ToString(V). • If the value of any element of x is greater than > 255, then throw a TypeError. • Return an IDL ByteString value whose > length is the length of x, and where the value of each element is > the value of the corresponding element of x. ]] So what should be > thrown when one does > > var client = new XMLHttpRequest(); client.open('GET', '/glop'); > client.setRequestHeader('X-Test', '小'); > > TypeError per WebIDL or SyntaxError per XHR? I think it should be > TypeError, and SyntaxError for code <256 that are not allowed, but > implementations currently use SyntaxError only. > > [1] https://xhr.spec.whatwg.org/ [2] > https://heycam.github.io/webidl/#es-ByteString > This is perfectly explicit from the WebIDL specification. It defines that `setRequestHeader` is a JavaScript function that does argument conversion and validation (using the quoted algorithm in this case), and only after that succeeded, invokes the algorithm defined in the relevant specification (in this case XHR). This implies in particular that a TypeError will be thrown here. Indeed, the Firefox Nightly I'm running right now implements this behaviour. HTH Ms2ger -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJWCqLDAAoJEOXgvIL+s8n26GQH/RPt+Nxxnmg0BXfIOySWeunn 2FHMlGiydCT5eek7oLvMhH3o2wyfgExEJrQyc9/emR+08sAlBZRRf5XkS+s+A8gQ XMcHhv054bJ5zd1EV6t2V6E01PSIgQ0dUp5XtKF8xJR/J6opUodvm25jPGvomg7H W4KelDI7LleeIAgKP7TLzLSsSmGS4/3QkjmleEB04Tso81IR3nXmpU75fYcsoDDg ODJaNAtzauE9cMX6lXf9aEV2bnPGlgy9Ke5/Q8xYdadqy0xD44NFSGJNdQGzL/7P Iy5ImE6uipky/O8vUUMCG7jdMYOJRGv3TiGyEMijAEsJOjpoN9ay3xdo1SHXO0A= =U0HA -----END PGP SIGNATURE-----