Closed Bug 1146585 Opened 10 years ago Closed 10 years ago

Add a test for Cache.delete

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

References

Details

Attachments

(1 file)

No description provided.
Attachment #8581903 - Flags: review?(bkelly)
Assignee: nobody → ehsan
Blocks: cachetests
Comment on attachment 8581903 [details] [diff] [review] Add a test for Cache.delete Review of attachment 8581903 [details] [diff] [review]: ----------------------------------------------------------------- r=me with the race addressed. Thanks! ::: dom/cache/test/mochitest/test_cache_delete.js @@ +78,5 @@ > + var cache; > + return setupTest(tests) > + .then(function(c) { > + cache = c; > + // Simultaneously add an delete a request nit: add and delete @@ +81,5 @@ > + cache = c; > + // Simultaneously add an delete a request > + return Promise.all([ > + cache.add(newURL), > + cache.delete(newURL), I'm not sure the behavior of this is strictly defined. The `cache.add()` is started first. It could in theory complete before the `cache.delete()` runs. I think you are testing a race here. Now, if you put the delete() first in the Promise.all(), then you are guaranteed that it should always fail.
Attachment #8581903 - Flags: review?(bkelly) → review+
(In reply to Ben Kelly [:bkelly] from comment #2) > @@ +81,5 @@ > > + cache = c; > > + // Simultaneously add an delete a request > > + return Promise.all([ > > + cache.add(newURL), > > + cache.delete(newURL), > > I'm not sure the behavior of this is strictly defined. The `cache.add()` is > started first. It could in theory complete before the `cache.delete()` > runs. I think you are testing a race here. > > Now, if you put the delete() first in the Promise.all(), then you are > guaranteed that it should always fail. Hmm, yeah my reading of the spec was incorrect here. But I don't understand why reversing the order of add and delete would make the race go away. This is basically a race between fetch and the parallel steps of Batch Cache Operation, right? What am I missing?
Flags: needinfo?(bkelly)
(In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #3) > Hmm, yeah my reading of the spec was incorrect here. But I don't understand > why reversing the order of add and delete would make the race go away. This > is basically a race between fetch and the parallel steps of Batch Cache > Operation, right? What am I missing? I believe it would make them go away because delete() would enter Batch Cache Operation before add() would enter it. When dealing with just meta data (not body data), those steps are essentially synchronous. So it implies to me which ever starts adjusting meta data first wins. And currently its not just a race with the fetch part of add. If you fetch'd first and used put, the race would still exist because we don't write the put() meta data till the body is fully loaded. This particular race, though, will go away once we implement committing the put when headers are available.
Flags: needinfo?(bkelly)
OK, I see. Thanks!
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: