Bug 149107 - IndexedDB does not throw ConstraintErrors for unique keys
Summary: IndexedDB does not throw ConstraintErrors for unique keys
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac OS X 10.10
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 149117
  Show dependency treegraph
 
Reported: 2015-09-13 12:45 PDT by Nolan Lawson
Modified: 2016-03-21 13:57 PDT (History)
2 users (show)

See Also:


Attachments
Reproducible test case (1.86 KB, text/html)
2015-09-13 12:45 PDT, Nolan Lawson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nolan Lawson 2015-09-13 12:45:50 PDT
Created attachment 261088 [details]
Reproducible test case

(May be a dup of https://bugs.webkit.org/show_bug.cgi?id=60720, but it was marked as invalid because they didn't have a good reproducible test case.)

In WebKit Nightly 600.8.9 (as well as Safari 8.0.8), it is possible to put() two documents with the same key, even if that key is defined as a unique index.

I have a reproducible test case to demonstrate: http://bl.ocks.org/nolanlawson/28ff2db3f3cb386c8ecb. The same test is also attached to this bug.

If the bug has been successfully reproduced, then this HTML page will print "There is a bug." Note that openKeyCursor() also returns the same key twice.

This bug cannot be reproduced in either Firefox or Chrome.
Comment 1 Dmitry Sorin 2016-03-04 14:24:57 PST
+1 for this bug. Reproducable.
Comment 2 Brady Eidson 2016-03-04 14:42:52 PST
Good thing this is fixed in Modern IDB!

Works great in ToT/WebKit nightly.
Comment 3 Dmitry Sorin 2016-03-04 14:43:58 PST
Will Safari9 in OSX 10.11 get this update?
Comment 4 Brady Eidson 2016-03-04 14:46:45 PST
(In reply to comment #3)
> Will Safari9 in OSX 10.11 get this update?

This is the WebKit open source project.

Safari is an Apple product, and Apple generally does not comment on their future products.
Comment 5 Dmitry Sorin 2016-03-04 14:50:53 PST
Generally !== always, huh? :)
Not in this Safari version, right?
Comment 6 Brady Eidson 2016-03-04 14:58:20 PST
(In reply to comment #5)
> Generally !== always, huh? :)
> Not in this Safari version, right?

I'm not sure what you're trying to clarify.

This should be working for you in whatever relatively modern Safari version you have + a WebKit nightly.
Comment 7 Dmitry Sorin 2016-03-04 15:29:48 PST
Okay, thank you
Comment 8 Nolan Lawson 2016-03-21 08:29:57 PDT
Nice to see progress getting made on this! :)

Unfortunately I tested my demo site (http://bl.ocks.org/nolanlawson/28ff2db3f3cb386c8ecb) on WebKit Nightly (10601.5.17.1.1, r195011) and it seems to still be broken. (It says "there is a bug.") Was this closed too early or is there some other reason the test case is failing?
Comment 9 Brady Eidson 2016-03-21 09:30:35 PDT
(In reply to comment #8)
> Was this closed too early or is there some other reason the test
> case is failing?

Unclear. I see the same with the attached test case (but did not on 3/4)
I'll poke around using the attached test case.
Comment 10 Brady Eidson 2016-03-21 11:21:43 PDT
Odd.

I reproduced this in the latest WebKit nightly, but it works fine in my local build of ToT.
Comment 11 Brady Eidson 2016-03-21 11:27:02 PDT
(In reply to comment #10)
> Odd.
> 
> I reproduced this in the latest WebKit nightly, but it works fine in my
> local build of ToT.

Nope, bonehead - I did *not* reproduce with a WebKit nightly. I was using stock Safari.

So, to clarify - I cannot reproduce this being broken.

In nightly 198484 (r198484.dmg">http://builds.nightly.webkit.org/files/trunk/mac/WebKit-SVN-r198484.dmg) and a ToT debug build, the attached test case works fine.

----

If you see the text There is a bug, then there's a bug.

Got a ConstraintError when we tried to put() the same key twice

Found keys: a
Found primaryKeys: 1
Comment 12 Brady Eidson 2016-03-21 11:30:37 PDT
(In reply to comment #8)

Oh I see:

> Unfortunately I tested my demo site
> (http://bl.ocks.org/nolanlawson/28ff2db3f3cb386c8ecb) on WebKit Nightly
> (10601.5.17.1.1, r195011) and it seems to still be broken. (It says "there
> is a bug.") Was this closed too early or is there some other reason the test
> case is failing?

Nightly 195011 is ancient.

January 14th was well before the new engine was enabled in WebKit2, which is what Safari (and therefore WebKit nightlies) uses.

Try with the latest nightly, please.
Comment 13 Brady Eidson 2016-03-21 11:32:00 PDT
(In reply to comment #12)
> (In reply to comment #8)
> 
> Oh I see:
> 
> > Unfortunately I tested my demo site
> > (http://bl.ocks.org/nolanlawson/28ff2db3f3cb386c8ecb) on WebKit Nightly
> > (10601.5.17.1.1, r195011) and it seems to still be broken. (It says "there
> > is a bug.") Was this closed too early or is there some other reason the test
> > case is failing?
> 
> Nightly 195011 is ancient.
> 
> January 14th was well before the new engine was enabled in WebKit2, which is
> what Safari (and therefore WebKit nightlies) uses.
> 
> Try with the latest nightly, please.

For the historical record: Modern IDB wasn't enabled in WK2 until http://trac.webkit.org/changeset/197122, and there were still some pretty bad bugs with it for another ~1 week after that.
Comment 14 Nolan Lawson 2016-03-21 13:57:41 PDT
My bad! It is indeed fixed. Somehow I got stuck with an old version of WebKit Nightly, but re-downloading worked. :) I'm on r198490.

Also a big thank-you for your work on "modern IDB"! Love seeing all these IDB bugs slowly getting knocked down.