Last Comment Bug 758838 - DeviceStorage.enumerate() doesn't work
: DeviceStorage.enumerate() doesn't work
Product: Core
Classification: Components
Component: DOM (show other bugs)
: Trunk
: x86 Mac OS X
-- normal (vote)
: mozilla15
Assigned To: Doug Turner (:dougt)
: Andrew Overholt [:overholt]
Depends on:
  Show dependency treegraph
Reported: 2012-05-25 17:17 PDT by David Flanagan [:djf]
Modified: 2012-05-30 07:39 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

patch v.1 (5.10 KB, patch)
2012-05-29 14:16 PDT, Doug Turner (:dougt)
jonas: review+
Details | Diff | Splinter Review

Description User image David Flanagan [:djf] 2012-05-25 17:17:58 PDT
I can use the new DeviceStorage API to add files to ~/Pictures on my mac, but I cannot enumerate the files in ~/Pictures or its subdirectories.

I'm testing this in a Gaia app in the b2g desktop client on MacOS.

My test code looks like this:

var storage = navigator.getDeviceStorage("pictures")[0];
var cursor = storage.enumerate("test");
cursor.onsuccess = function(e) {
  var r =;
  console.log("cursor success:", r, r?"");
  if (cursor.result);

There are files in ~/Pictures/test/ (including one created with the Device storage API) but the onsuccess handler is never called.
Comment 1 User image Doug Turner (:dougt) 2012-05-25 21:49:24 PDT
i can look next week.

in the mean time, we know that enumeration does work cross platform -

It must be something w/ the pictures directory...
Comment 2 User image Doug Turner (:dougt) 2012-05-25 23:55:08 PDT
 please add a onerror handler. will tell you a bunch.
Comment 3 User image David Flanagan [:djf] 2012-05-26 11:28:24 PDT
I've been using an onerror, but took it out in the code I quoted above.  It never gets called.  See the code in context here:
Comment 4 User image Doug Turner (:dougt) 2012-05-26 21:14:02 PDT
cursor.onerror = function(e) {
  console.log("enumerate error",;
} will probably throw, right?
Comment 5 User image David Flanagan [:djf] 2012-05-28 14:33:08 PDT
(In reply to Doug Turner (:dougt) from comment #4)
> cursor.onerror = function(e) {
>   console.log("enumerate error",;
> }
> will probably throw, right?

You told me to look at  Given that the event target is the cursor, isn't always the same as cursor?

In any case, I've never seen the onerror event fire, even when all I do is console.log("error!")
Comment 6 User image Doug Turner (:dougt) 2012-05-29 14:16:39 PDT
Created attachment 628107 [details] [diff] [review]
patch v.1
Comment 7 User image David Flanagan [:djf] 2012-05-29 14:42:39 PDT
With that attachment applied, enumerate() now works for me.
Comment 8 User image Doug Turner (:dougt) 2012-05-29 14:53:50 PDT
Comment on attachment 628107 [details] [diff] [review]
patch v.1

Review of attachment 628107 [details] [diff] [review]:

I probably just move all of the prompt bits into this new class.  but I can do that later, i suppose.
Comment 10 User image Ed Morley [:emorley] 2012-05-30 07:39:39 PDT

Note You need to log in before you can comment on or make changes to this bug.