Giter VIP home page Giter VIP logo

Comments (7)

GuilleW avatar GuilleW commented on May 31, 2024

With extension, a way to test all error when opening database, open transaction, etc ... will be useful too.

from fakeindexeddb.

GuilleW avatar GuilleW commented on May 31, 2024

Something like :

indexedDB.__simulate = QUOTA_EXCEEDED_ERROR
// unit test ...

indexedDB.__simulate = CLOSE_EVENT
// unit test ...

Not API breaker and help unit testing.

from fakeindexeddb.

Quelklef avatar Quelklef commented on May 31, 2024

Is the idea with __simulateQuotaExceeded = true to have fakeindexeddb throw an exception on the real-world quota amount?

Seems to me like it would be more useful to set the quota amount for testing (indexedDB.__quota = 50; // mb, default Infinity) or to have some way to manually throw the error (indexedDB.__throwQuotaExceeded()).

from fakeindexeddb.

nolanlawson avatar nolanlawson commented on May 31, 2024

@Quelklef This would require fakeindexeddb to actually calculate how much "storage" it's using, which would be computationally expensive and inaccurate since it's all in-memory.

The problem with throwQuotaExceeded() as a function is that, to truly simulate what a browser does, the error should be thrown during a readwrite transaction (if the quota is exceeded after opening) or in the indexedDB.open request (if the quota is already exceeded before even opening the database).

from fakeindexeddb.

Quelklef avatar Quelklef commented on May 31, 2024

@nolanlawson Okay, that all makes sense. What is the intended behaviour of indexedDB.__simulateQuotaExceeded = true;, then? To throw on the next open request?

from fakeindexeddb.

nolanlawson avatar nolanlawson commented on May 31, 2024

That's what I was thinking – that way, you could test throwing both on open() and on a readwrite transaction, by just setting that flag right before you do the transaction.

from fakeindexeddb.

Quelklef avatar Quelklef commented on May 31, 2024

Got it. IMO, it reads a little like setting a config option rather than setting up for imminent behaviour. Compare it to something like .__prepareExceedQuota() or another name of the likes.

from fakeindexeddb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.