Closed Bug 697271 Opened 13 years ago Closed 13 years ago

XMLHttpRequest.send() should use JS coercion rules

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME
mozilla14

People

(Reporter: sicking, Unassigned)

References

(Blocks 1 open bug)

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
Blocks: 704444
This is WFM with the Paris bindings, right?
Indeed.
Status: NEW → RESOLVED
Closed: 13 years ago
Depends on: 740069
No longer depends on: ParisBindings
Flags: in-testsuite?
Resolution: --- → WORKSFORME
Target Milestone: --- → mozilla14
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.