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

VERIFIED FIXED in Firefox 65

Status

defect
P5
normal
VERIFIED FIXED
6 months ago
3 months ago

People

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

Tracking

({good-first-bug})

63 Branch
mozilla65

Firefox Tracking Flags

(firefox65 verified, firefox66 verified)

Details

Attachments

(2 attachments)

(Reporter)

Description

6 months ago
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)
(Reporter)

Comment 2

6 months ago
(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.
(Assignee)

Comment 5

5 months ago
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
(Assignee)

Comment 7

5 months ago
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)
(Assignee)

Comment 9

5 months ago
Updated the totalBytesGreater property in browser.downloads.search({}) to default to -1 so files with a byte size of 0 will be returned.
(Assignee)

Updated

5 months ago
Keywords: checkin-needed

Comment 10

5 months ago
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

Comment 11

5 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/e990a032ac3c
Status: ASSIGNED → RESOLVED
Last Resolved: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65

Comment 12

4 months ago
Posted 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.

Updated

4 months ago
Status: RESOLVED → VERIFIED

Updated

3 months ago
Depends on: 1519762
You need to log in before you can comment on or make changes to this bug.