Bug 136155

Summary: indexeddb versionchange event not fired
Product: WebKit Reporter: Jake Archibald <jaffathecake>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, nolan, raymondcamden, simon.fraser, sroussey, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jsbin.com/velolu/1/quiet

Description Jake Archibald 2014-08-22 06:20:32 PDT
Visit http://jsbin.com/velolu/1/quiet
Open http://jsbin.com/pucegu/1/quiet in another tab
First tab should have versionchange event (compare to Firefox & Chrome).

Also getting some weird "unknownerror"s if I run this test a few times.
Comment 1 Raymond Camden 2014-09-26 07:20:17 PDT
I can confirm this is a bug, but I want to add a bit of context. The bug is that if you have 2 tabs open using the same DB, and the second tab has upgraded the db, the first tab is not getting the event.

If, however, you use one tab, load the page, edit the code to change the version, and reload the page, the event is fired properly.

So this is more an issue of someone using the same DB concurrently. Probably a bit more rare, but should still be fixed.
Comment 2 Radar WebKit Bug Importer 2015-04-25 14:51:47 PDT
<rdar://problem/20699757>
Comment 3 Brady Eidson 2016-03-21 21:33:34 PDT
This works great in Modern IDB: Confirmed in the latest WebKit Nightly (r198511)
Comment 4 Nolan Lawson 2016-03-30 10:40:16 PDT
I'm still able to reproduce the bug in WebKit Nightly r198834 - is that because I'm on Yosemite?

In the second tab, I don't see "Upgrading from version 1 / Connected to DB - you win!" Instead I just see "Database closed - go back to the other tab.", indicating the versionchange event wasn't fired.

I reproduced the correct behavior in both Chrome 49 and Firefox 47 for comparison. I also tested several times with different origins between each test.
Comment 5 Brady Eidson 2016-03-30 10:59:30 PDT
(In reply to comment #4)
> I'm still able to reproduce the bug in WebKit Nightly r198834 - is that
> because I'm on Yosemite?

Nope - In fact Yosemite definitely wouldn't have the nightly issues that El Cap has been having.

> In the second tab, I don't see "Upgrading from version 1 / Connected to DB -
> you win!" Instead I just see "Database closed - go back to the other tab.",
> indicating the versionchange event wasn't fired.
> 
> I reproduced the correct behavior in both Chrome 49 and Firefox 47 for
> comparison. I also tested several times with different origins between each
> test.

Can you "remove all website data" then try again?

Or, more directly, with Safari/Nightly *not* running, do:
`rm -rf ~/Library/Safari/Databases/___IndexedDB/`
...then try again.

I can reproduce the correct behavior in a nightly at-will.
Comment 6 Nolan Lawson 2016-03-30 11:05:31 PDT
I actually downloaded Jake's examples and ran them on localhost on multiple ports, so there ought to be no need to clear data. I tried five times and still couldn't reproduce the correct behavior.

I'm downloading El Cap and will try again...
Comment 7 Brady Eidson 2016-03-30 11:16:52 PDT
(In reply to comment #6)
> I actually downloaded Jake's examples and ran them on localhost on multiple
> ports, so there ought to be no need to clear data. I tried five times and
> still couldn't reproduce the correct behavior.
> 
> I'm downloading El Cap and will try again...

There's no expected reason why this would be a Yosemite vs El Cap difference.

One other (stretch) thought - You're not trying in private browsing mode, are you?
Comment 8 Nolan Lawson 2016-03-30 11:37:11 PDT
Nope, I wasn't in private browsing.

After upgrading to El Cap, I can confirm working in both WebKit Nightly r198834 and Safari Technology Preview 9.1.1 (11601.6.10, 11602.1.25). Not sure why it wasn't working in Yosemite (or if that was even my issue), but nice work! :)