XMLHttpRequest.send() should use JS coercion rules

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
7 years ago
6 years ago

People

(Reporter: sicking, Unassigned)

Tracking

(Blocks: 1 bug)

Trunk
mozilla14
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

Per the spec, if XHR.send is called with a type of argument it does not recognize (Blob, ArrayBuffer, Document, FormData) it should use normal JS coercion rules to convert any other value to a string. Obviously we should additionally support the set of additional types that we support internally (nsISupportsString?, nsIInputStream).

That means that for the following calls, we should get the following results:

xhr.send(2)  ->  "2"
xhr.send(false)  ->  "false"
xhr.send(new XMLHttpRequest)  ->  "[Object XMLHttpRequest]"
xhr.send({ toString: function() { return "foo" } })  ->  "foo"

This is what the "[AllowAny]" extended parameter on the .send(DOMString) signature means.
Perhaps we should just fix XPCVariant::GetAsWStringWithSize to do the right thing.
Or Send could take jsval as parameter.
Ccing mrbkap to see if changing GetWStringWithSize is feasible.

Changing to jsval would work, though we have lots of C++ callers that we need to keep in mind somehow.

I also think you can get the jsval out of the nsIVariant
Component: DOM → DOM: Mozilla Extensions
OS: Mac OS X → All
Hardware: x86 → ARM
Hardware: ARM → All

Updated

7 years ago
Blocks: 704444
Depends on: 580070
This is WFM with the Paris bindings, right?
Indeed.
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Depends on: 740069
No longer depends on: 580070
Flags: in-testsuite?
Resolution: --- → WORKSFORME
Target Milestone: --- → mozilla14
Component: DOM: Mozilla Extensions → DOM
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.