Closed Bug 420230 Opened 16 years ago Closed 16 years ago

unable to save data urls to disk

Categories

(Toolkit :: Downloads API, defect, P2)

x86
Windows XP
defect

Tracking

()

VERIFIED FIXED
mozilla1.9beta5

People

(Reporter: sspitzer, Assigned: jimm)

References

()

Details

Attachments

(2 files, 4 obsolete files)

unable to save data urls to disk

steps to reproduce

1)  load the data url above
2)  attempt to save to disk

I get the download manager, but the file is never saved.

first spotted this with dolske's APNG Editor addon

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b4pre) Gecko/2008022704 Minefield/3.0b4pre
Hmm, with APNG edit's "Save Animation" and a current nightly on OS X (Gecko/2008022804), these both WFM. Windows-specific bug?
I updated to make sure it wasn't fixed recently, and Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b4pre) Gecko/2008022806 Minefield/3.0b4pre has the same problem.
ugh - edward - didn't we fix this once already?
Component: General → Download Manager
QA Contact: general → download.manager
Works for me with the provided data uri and data:text/html,Hello World!
the hello world data url from edward works for me, but the png data url does not.

edward, when you save that data url to disk, what do you see in the download manager?

I'm attempting to save it as "test.png", so I see

test.png
2.2 KB - data resource
an interesting data point:  entries for the files that I'm saving are showing up in "My Recent Documents" under the Start menu (on Windows XP), which makes me think that I am saving them, but then they are getting deleted?
So you /do/ see the file show up as 

image.png  <time>
2.2 KB - data resource

?

If you double click the row from the download manager, does it open?
> If you double click the row from the download manager, does it open?

"Open" is disabled, and "Open In Containing Folder" gives me the windows explorer alert that the file does not exist or is not a directory.
I noticed this when trying to save the data uri from bug 163971.
If I have a previously saved file with the same name (using a branch build), then that file is being deleted, but the new file is not saved.
It seems as if the download manager is trying to create a directory, instead of a file or something and when that doesn't work, it bails out completely.
This seems to be windows only. I wonder if it's related to bug 416683. Because when I toggle browser.download.manager.scanWhenDone to false, I can save okay on windows.
Depends on: 416683
Assignee: nobody → jmathies
bug 422920 was marked as blocking / P2.
Flags: blocking-firefox3?
Priority: -- → P2
Flags: blocking-firefox3? → blocking-firefox3+
Attached patch download scanner patch v.1 (obsolete) — Splinter Review
This patch skips off providing the source uri in cases where the source is a data scheme. Scanning though will still take place on the resulting local file.
Attachment #311103 - Flags: review?(tellrob)
Comment on attachment 311103 [details] [diff] [review]
download scanner patch v.1

Looks pretty straightforward to me. No threading issues.
Attachment #311103 - Flags: review?(tellrob) → review+
Flags: in-testsuite?
Flags: in-litmus?
Attachment #311103 - Flags: superreview?(sdwilsh)
I'll add a test for this as well.
I can do the test.
Well, depends on what kind of test you want ;) Shawn might want an xpcshell one :p I was just doing to take one of the mochitests that adds a download and hits space to retry the download. You can continue. :p
actuall I'd kinda like to do it myself. :) working on one now based on your suggested approach. I'll post a new patch here in a bit.
Attached patch download scanner patch v.3 (obsolete) — Splinter Review
added mochitest test case. I made it a platform independent test since this seems like a good general test to have.
Attachment #311103 - Attachment is obsolete: true
Attachment #311103 - Flags: superreview?(sdwilsh)
Attachment #311162 - Flags: superreview?(benjamin)
Attachment #311162 - Flags: review?(edilee)
I'm not complaining since more eye's looking at the code is a good thing, but toolkit doesn't require superreview.

Edward - can you make sure this testcase follows the form you've been going along with (minimizes dependency on setTimeout).  Thanks!
Comment on attachment 311162 [details] [diff] [review]
download scanner patch v.3

>+++ toolkit/mozapps/downloads/tests/browser/browser_bug_420230.js
>+  window.setTimeout(finishUp, 500);
Could you base the testcase on either browser_bug_406857 or browser_bug_412360. They start downloads by creating a download in the canceled state and simulating an enter to restart the download.. So we don't need to explicitly set up our own nsIWBP object and all.

Also, those tests don't use a setTimeout(.., 500) which is frowned upon.

Additionally, you want to check if the file exists. Not just that it got to the finished state. Because currently, downloads _are_ finishing but the file disappears.
Attachment #311162 - Flags: review?(edilee) → review-
> I'm not complaining since more eye's looking at the code is a good thing, but
> toolkit doesn't require superreview.

Isn't it going to need sr+ if I'm planning on asking for approval1.9b5? 

> Could you base the testcase on either browser_bug_406857...

I think that's the one I started with, but took most of that stuff out. :/ Will get it cleaned up and repost.
(In reply to comment #23)
> Isn't it going to need sr+ if I'm planning on asking for approval1.9b5? 
Nope, normal rules apply.  Drivers look for proper review, and really like to see tests ;)
Attached patch download scanner patch v.4 (obsolete) — Splinter Review
Attachment #311162 - Attachment is obsolete: true
Attachment #311184 - Flags: review?(edilee)
Attachment #311162 - Flags: superreview?(benjamin)
Attachment #311184 - Flags: approval1.9b5?
Comment on attachment 311184 [details] [diff] [review]
download scanner patch v.4

Typically you request approval after reviews are done.

r=Mardak

>+++ toolkit/mozapps/downloads/tests/browser/browser_bug_420230.js
>+        case dm.DOWNLOAD_FINISHED:
>+          ok(true, "data: scheme uri successfully downloaded");
>+          if (!aDownload.targetFile.exists())
>+            ok(false, "data: scheme uri target does not exist");
>+          else
>+            ok(true, "data: scheme uri target file exists");
No need for the if/else. Just do..

ok(aDownload.targetFile.exists(), "data: uri target file exists");

And just checking, you were able to pass this test on a windows box only after applying the rest of the patch?
Attachment #311184 - Flags: review?(edilee) → review+
> Typically you request approval after reviews are done.

sorry, jumpd the gun.

> And just checking, you were able to pass this test on a windows box only after
> applying the rest of the patch?

Hmm, good question, I didn't check that. Will test that now.
Yes it fails. I get a timeout though, I wonder if I've not finished up right - 

chrome://mochikit/content/browser/../browser/toolkit/mozapps/downloads/tests/browser/browser_bug_420230.js
	PASS - data: uri successfully downloaded
	FAIL - data: uri target file exists - chrome://mochikit/content/browser/../browser/toolkit/mozapps/downloads/tests/browser/browser_bug_420230.js
	FAIL - Timed out - chrome://mochikit/content/browser/../browser/toolkit/mozapps/downloads/tests/browser/browser_bug_420230.js

here's the new code:

case dm.DOWNLOAD_FINISHED:
  ok(true, "data: uri successfully downloaded");
  ok(aDownload.targetFile.exists(), "data: uri target file exists");
  aDownload.targetFile.remove(false);
  dm.removeListener(listener);
  finish();
  break;

Comment on attachment 311184 [details] [diff] [review]
download scanner patch v.4

a1.9b5=beltzner, I can see the merit in having this for beta, also: tests, yay!
Attachment #311184 - Flags: approval1.9b5?
Attachment #311184 - Flags: approval1.9b5+
Attachment #311184 - Flags: approval1.9+
Attached patch download scanner patch v.5 (obsolete) — Splinter Review
updated
Attachment #311184 - Attachment is obsolete: true
Attachment #311413 - Flags: approval1.9b5?
Attachment #311413 - Flags: approval1.9b5?
Comment on attachment 311413 [details] [diff] [review]
download scanner patch v.5

>+        case dm.DOWNLOAD_FINISHED:
>+          ok(true, "data: uri successfully downloaded");
>+          ok(aDownload.targetFile.exists(), "data: uri target file exists");
>+          aDownload.targetFile.remove(false);
Ah. You'll need a try/catch around the remove because it'll throw if it can't delete the file. Shawn, that's an issue on windows, yeah? But in any case, with the patch, the test wouldn't hit the timeout anyway.
Hold on, do you have your patch from the dependent bug 416683 applied as well? The data uri should be hitting the BLOCKED_POLICY case -- not the FINISHED case with bug 416683 applied. no?
Just to clarify:

without bug 416683, without bug 420230: data uri -> finished but deleted
with bug 416683, without bug 420230: data uri -> blocked and deleted
with bug 416683, with bug 420230: data uri -> finished and not deleted
yeah I'm looking at it....
ahh, we start off in state cancelled, skipping the use of AddDownload which is where the check takes place. This should be ok. new try/catch patch forthcoming..
actually, I _should_ be using AddDownload to test this!
Yeah you should be testing with AddDownload. Sorry about leading you to RetryDownload. (Should we be checking policy on retry?)

Instead of adding a canceled download then retrying, do something similar to the first test which adds the download.

1) add a listener
2) add the download
3) check for state changes with the listener

you don't actually need the download UI for this either. Shawn, should this be an xpcshell test or is that a SoC thing converting mochi tests to litmus tests if possible! ;)
argh. mochi -> xpcshell not litmus :p
> Yeah you should be testing with AddDownload. Sorry about leading you to
> RetryDownload. (Should we be checking policy on retry?)

Hmm, searching LXR, it looks like we always inject downloads via Add. Retry looks to be tied to the UI only.
we should use xpcshell whenever it's possible.
Ok, converted the whole thing over to a unit test, and confirmed failure on trunk, success with this patch applied.
Attachment #311413 - Attachment is obsolete: true
Attachment #311474 - Flags: review?(edilee)
Attachment #311474 - Flags: review?(edilee) → review+
Comment on attachment 311474 [details] [diff] [review]
download scanner patch v.6

let works in xpcshell now?  sweeet.

drivers: this fixes a nasty little regression on windows.  patch has tests - yay!  This also got a for 1.9 and for 1.9b5 already, but some reworking was done.
Attachment #311474 - Flags: approval1.9b5?
Attachment #311474 - Flags: approval1.9?
Whiteboard: [has patch][has review][needs approval]
(Note the changes were to the test and not the patch, which remains unchange.)
Comment on attachment 311474 [details] [diff] [review]
download scanner patch v.6

No need to get approval again. I'll land this shortly.
Attachment #311474 - Flags: approval1.9b5?
Attachment #311474 - Flags: approval1.9?
Keywords: checkin-needed
Checking in toolkit/components/downloads/src/nsDownloadManager.cpp;
/cvsroot/mozilla/toolkit/components/downloads/src/nsDownloadManager.cpp,v  <--  nsDownloadManager.cpp
new revision: 1.178; previous revision: 1.177
done
Checking in toolkit/components/downloads/src/nsDownloadScanner.cpp;
/cvsroot/mozilla/toolkit/components/downloads/src/nsDownloadScanner.cpp,v  <--  nsDownloadScanner.cpp
new revision: 1.17; previous revision: 1.16
done
Checking in toolkit/components/downloads/src/nsDownloadScanner.h;
/cvsroot/mozilla/toolkit/components/downloads/src/nsDownloadScanner.h,v  <--  nsDownloadScanner.h
new revision: 1.10; previous revision: 1.9
done
RCS file: /cvsroot/mozilla/toolkit/components/downloads/test/unit/test_bug_420230.js,v
done
Checking in toolkit/components/downloads/test/unit/test_bug_420230.js;
/cvsroot/mozilla/toolkit/components/downloads/test/unit/test_bug_420230.js,v  <--  test_bug_420230.js
initial revision: 1.1
done
Status: NEW → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: [has patch][has review][needs approval]
Target Milestone: --- → Firefox 3 beta5
There were two |case dm.DOWNLOAD_FAILED:| lines pointing at the same failure code in the test here.

I checked in a fix, rs=gavin for that just now.

Checking in toolkit/components/downloads/test/unit/test_bug_420230.js;
/cvsroot/mozilla/toolkit/components/downloads/test/unit/test_bug_420230.js,v  <--  test_bug_420230.js
new revision: 1.2; previous revision: 1.1
Oops. Thanks Justin.
verified fixed using Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5pre) Gecko/2008032505 Minefield/3.0b5pre and Win Vista nightly as well. I verified using the data URL and the testcase in the bug.
Status: RESOLVED → VERIFIED
Product: Firefox → Toolkit
(In reply to comment #0)
> unable to save data urls to disk
> 
> steps to reproduce
> 
> 1)  load the data url above
> 2)  attempt to save to disk
> 
> I get the download manager, but the file is never saved.
> 
> first spotted this with dolske's APNG Editor addon
> 
> Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b4pre) Gecko/2008022704
> Minefield/3.0b4pre


You can only download the image,because there is only an image.An web page does not exist.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: