Closed Bug 1503760 Opened 4 years ago Closed 4 years ago

browser.downloads.search doesn't return 0 byte downloads

Categories

(WebExtensions :: General, defect, P5)

63 Branch
defect

Tracking

(firefox65 verified, firefox66 verified)

VERIFIED FIXED
mozilla65
Tracking Status
firefox65 --- verified
firefox66 --- verified

People

(Reporter: jwensley2, Assigned: ben.armstrong22, Mentored)

References

Details

(Keywords: good-first-bug)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0

Steps to reproduce:

I generated a 0 byte file using the following code

<?php
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="test.bin"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . 0);
die;

And then tried to query for the download using browser.downloads.search({})



Actual results:

No results were returned


Expected results:

The download should have been returned
Does this actually get created on the filesystem and is it shown in the download section of the library?
Flags: needinfo?(jwensley2)
(In reply to David Durst [:ddurst] (Regression Engineering Owner for 63) from comment #1)
> Does this actually get created on the filesystem and is it shown in the
> download section of the library?

Yes, the files are created on the filesystem and they show up in the library.
Flags: needinfo?(jwensley2)
The issue is here:
https://searchfox.org/mozilla-central/rev/007b66c1f5f7a1b9a900a2038652a16a020f010c/toolkit/components/extensions/parent/ext-downloads.js#269

If the totalBytesGreater query property isn't specified we default to 0 which means search() only returns those with a size > 0.  Changing the default there to -1 should fix this.  It could also use a test.
Mentor: aswan
Keywords: good-first-bug
Priority: -- → P5
If this is your first contribution, please see https://wiki.mozilla.org/WebExtensions/Contribution_Onramp for information on getting started.
Hi, I'll be taking a look at trying to fix this, thanks.
Welcome, Ben! If you need any help, please needinfo :aswan, the bug mentor. 

Happy bug fixing!
Assignee: nobody → ben.armstrong22
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Hi Andrew,

To test this where do I execute the code Joseph Wensley provided to reproduce?

Thanks!
Flags: needinfo?(aswan)
I don't think you need to use his specific code, just making a 0 byte file available via http (either by putting it on the filesystem where an http server can read it or by writing your own handler for your web server framework of choice) is fine.
Flags: needinfo?(aswan)
Updated the totalBytesGreater property in browser.downloads.search({}) to default to -1 so files with a byte size of 0 will be returned.
Keywords: checkin-needed
Pushed by apavel@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e990a032ac3c
Changed browser.downloads.search({}) to return 0 byte downloads. r=aswan
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/e990a032ac3c
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Attached file Bug1503760.zip
I was able to reproduce this issue on Firefox 63.0.3(20181114214635) under Win 7 64-bit and  Mac OS X 10.13.6.

This issue is verified as fixed on Firefox 66.0a1(20181211093801) and 65.0b3(20181210164452) under Win 7 64-bit and Mac OS X 10.13.6.

I used: https://github.com/mdn/webextensions-examples/tree/ec731d4ceee1df0ccdebd87ab9f95875f55eeee7/latest-download and Xampp for testing.

Please see the attached screenshots.
Status: RESOLVED → VERIFIED
Depends on: 1519762
You need to log in before you can comment on or make changes to this bug.