Closed Bug 1109574 Opened 5 years ago Closed 5 years ago

[Fetch] Passing Request object (whose body is null) to Request() constructor shouldn't set used flag for passing Request object

Categories

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

36 Branch
x86_64
Windows 7
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: crimsteam, Assigned: nsm)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0
Build ID: 20141125180439

Steps to reproduce:

When we use Request() constructor and not set 'body' member in second argument, then request's body for new Request object is null (initial value).

Passing this new Request object to Request() constructor shouldn't set his used flag (because body is null), what we see in first step in algo:
https://fetch.spec.whatwg.org/#dom-request
The same applies to fetch() method when we pass Request object where request's body for this object is null, because this algorithm used Request() constructor algorithm (step 2.):
https://fetch.spec.whatwg.org/#dom-global-fetch

Now Firefox, for both case: Request() constructor and fetch() method, set used flag for passing Request object. Looks like there is no null for body and probably using empty byte sequence.

Small test:

<script type = "text/javascript">

 var request1 = new Request("");
 document.write("request1.bodyUsed: " + request1.bodyUsed + "<br>"); // false

 // This set used flag for request1  (it's not correct per spec)
 var request2 = new Request(request1);
 document.write("request1.bodyUsed: " + request1.bodyUsed + "<br>"); // true

 // This throw because used flag for request1 is set
 try{
	new Request(request1);
 }
 catch(e){
 	document.write(e); // TypeError: Request body has already been consumed.
 } 
 
</script>
Thanks.  This was a change to the spec and we need to catch up to it.  The code in our project branch, maple, is here:

  https://hg.mozilla.org/projects/maple/file/ba71ba81175f/dom/fetch/Request.cpp#l66

We'll fix it there first and merge to m-c in the coming weeks.  (We have a lot of changes over on maple.)

Incidentally, if you want to test with maple, you can grab a build from one of these dirs:

  http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/maple-win32/latest/
  http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/maple-macosx64/latest/  
  http://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/maple-linux/latest/
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → nsm.nikhil
Hmm I check this maple version but get a lot of crash when try use fetch() method (win32). Which version contains the latest changes for Fetch, standard nightly or nightly-maple?
Attachment #8540622 - Flags: review?(bkelly) → review+
(In reply to Arkadiusz Michalski (Spirit) from comment #3)
> Hmm I check this maple version but get a lot of crash when try use fetch()
> method (win32). Which version contains the latest changes for Fetch,
> standard nightly or nightly-maple?

Maple has the latest patches applied, I believe.  Can you write a new bug with the crash information?  CC :nsm, :bkelly, and :baku.  Thanks!
https://hg.mozilla.org/mozilla-central/rev/beacba1d431a
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.