DeviceStorage.enumerate() doesn't work

RESOLVED FIXED in mozilla15

Status

()

Core
DOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: djf, Assigned: dougt)

Tracking

Trunk
mozilla15
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
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 = e.target.result;
  console.log("cursor success:", r, r?r.name:"");
  if (cursor.result)
    e.target.continue();
};

There are files in ~/Pictures/test/ (including one created with the Device storage API) but the onsuccess handler is never called.
(Assignee)

Comment 1

5 years ago
i can look next week.

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

http://mxr.mozilla.org/mozilla-central/source/dom/tests/mochitest/devicestorage/test_enumerate.html?force=1

It must be something w/ the pictures directory...
Assignee: nobody → doug.turner
(Assignee)

Comment 2

5 years ago
 please add a onerror handler.  e.target.error.name will tell you a bunch.
(Reporter)

Comment 3

5 years ago
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: 

https://github.com/davidflanagan/gaia/blob/ds/apps/gallery/js/gallery.js#L138
(Assignee)

Comment 4

5 years ago
cursor.onerror = function(e) {
  console.log("enumerate error", cursor.error.name);
}

cursor.error.name will probably throw, right?
(Reporter)

Comment 5

5 years ago
(In reply to Doug Turner (:dougt) from comment #4)
> cursor.onerror = function(e) {
>   console.log("enumerate error", cursor.error.name);
> }
> 
> cursor.error.name will probably throw, right?

You told me to look at e.target.error.name.  Given that the event target is the cursor, isn't e.target 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!")
(Assignee)

Comment 6

5 years ago
Created attachment 628107 [details] [diff] [review]
patch v.1
(Reporter)

Comment 7

5 years ago
With that attachment applied, enumerate() now works for me.
(Assignee)

Comment 8

5 years ago
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.
Attachment #628107 - Flags: review?(jonas)
Attachment #628107 - Flags: review?(jonas) → review+
(Assignee)

Comment 9

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/2b16fea69517
https://hg.mozilla.org/mozilla-central/rev/2b16fea69517
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla15
You need to log in before you can comment on or make changes to this bug.