Closed
Bug 1115275
Opened 10 years ago
Closed 10 years ago
window.indexedDB can't be overwritten and replace with a mock
Categories
(Core :: Storage: IndexedDB, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: timdream, Unassigned)
References
Details
STR:
1. window.indexedDB = {}
2. console.log(window.indexedDB);
Expected:
1. Object { }
Actual:
1. IDBFactory { }
Note:
In Gaia we have mock (and mock helpers) for us to mock many of the APIs in unit tests. Because of this bug, we have to create special rules for window.indexedDB by replacing it's method instead (e.g. [1]). It would be better if this can be fixed and we could simply replace the instance.
[1] https://github.com/mozilla-b2g/gaia/blob/d55d1d5f39bd338ab2d298823aab1121e3d73fef/apps/keyboard/test/unit/mock_indexeddb.js#L210-L215
Comment 1•10 years ago
|
||
Workaround:
1. delete window.indexedDB
2. window.indexedDB = {}
Comment 2•10 years ago
|
||
According to the indexedDB spec [1], the indexedDB property is read only. So this is expected.
But the property descriptor
Object { configurable: true, enumerable: true, get: indexedDB(), set: undefined }
was different from what I expected:
Object { configurable: true, enumerable: true, value: IDBFactory, writable: true }
[1] http://www.w3.org/TR/IndexedDB/#idl-def-IDBEnvironment
Comment 3•10 years ago
|
||
> Object { configurable: true, enumerable: true, value: IDBFactory, writable: true }
Correction:
Object { configurable: true, enumerable: true, value: IDBFactory, writable: false }
Comment 4•10 years ago
|
||
> Object { configurable: true, enumerable: true, get: indexedDB(), set:
This was also expected:
https://heycam.github.io/webidl/#es-attributes
So comment #1 was a proper way to replace the indexedDB property rather than a workaround.
If you think the indexedDB property should be [Replaceable], please file a spec bug.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 5•10 years ago
|
||
Thanks, bug 1118648 filed against Gaia instead.
You need to log in
before you can comment on or make changes to this bug.
Description
•