Closed Bug 1250030 Opened 8 years ago Closed 8 years ago

Don't throw in PromiseStorage if indexedDB is not available

Categories

(Firefox OS Graveyard :: Gaia::Keyboard, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: timdream, Assigned: ralin)

Details

Attachments

(1 file)

In use cases outside of Firefox OS, Indexed DB might not be available because

- We are being launched in the iOS full screen mode.
- We are being embedded in a 3rd-party iframe (see bug 1147821)

The choices available for us would be (a) fake a IndexedDB interface for PromiseStorage, or (b) stop PromiseStorage from throwing and have it gracefully degraded. (a) is harder (even though we have some mock available in Gaia), so I am asking for (b) here.

Ray, do you agree this is a good idea? If so could you implement this? Thanks.
Flags: needinfo?(ralin)
I was thinking about replacing "TypeError: window.indexedDB is not defined" to a simple console.error() that does not block code execution.
Sure, I could deal with it.

I agree that (a) is harder and is not a permanent solution. Replacing throwing error with console could be done first, then see what can do further.

It seems about 7 files are using PromiseStorage, and I'm wondering how these functions go on if IndexedDB/PromiseStorage is unavailable?  Thanks.
Flags: needinfo?(ralin)
(In reply to Ray Lin[:ralin] from comment #2)
> It seems about 7 files are using PromiseStorage, and I'm wondering how these
> functions go on if IndexedDB/PromiseStorage is unavailable?  Thanks.

PromiseStorage should continue to "function" with

* Return undefined when get().
* Produce a console.warn and throw away data for set().

I assume this will not cause any troubles. Tell me if it's not the case. Thanks!
Besides avoiding throw error when PromisStorage start(), I was thinking if we could add a check at beginning of "_getTxn()" since it's used in every queries. 

It is like when _openPromise is null, then return resolved promise(with undefined) directly.

Do you think it is good idea to do this? Thanks.
Flags: needinfo?(timdream)
Comment on attachment 8722392 [details] [review]
[gaia] raylin:dont-throw-when-no-indexeddb > mozilla-b2g:master

Hi, Tim

Could you help me to review this patch?  Thanks. 
It appears that everyone's test get stuck now on treeherder...
Flags: needinfo?(timdream)
Attachment #8722392 - Flags: review?(timdream)
Comment on attachment 8722392 [details] [review]
[gaia] raylin:dont-throw-when-no-indexeddb > mozilla-b2g:master

Let's talk about this offline, I have a better idea.
Attachment #8722392 - Flags: review?(timdream)
Comment on attachment 8722392 [details] [review]
[gaia] raylin:dont-throw-when-no-indexeddb > mozilla-b2g:master

Tim,

Could you help me to review again? Thanks!
Attachment #8722392 - Flags: review?(timdream)
Comment on attachment 8722392 [details] [review]
[gaia] raylin:dont-throw-when-no-indexeddb > mozilla-b2g:master

Thanks for helping out!
Attachment #8722392 - Flags: review?(timdream) → review+
PR:     https://github.com/mozilla-b2g/gaia/pull/34083
Commit: https://github.com/mozilla-b2g/gaia/commit/62d71379ae7e22189829fd00d1cbb378a24e449a
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: