Bug 92560

Summary: IndexedDB: integer version layout tests
Product: WebKit Reporter: David Grogan <dgrogan>
Component: New BugsAssignee: David Grogan <dgrogan>
Status: RESOLVED FIXED    
Severity: Normal CC: alecflett, japhet, jsbell, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 92674, 92897    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Description David Grogan 2012-07-27 16:29:38 PDT
IndexedDB: integer version layout tests
Comment 1 David Grogan 2012-07-27 16:30:06 PDT
Created attachment 155086 [details]
Patch
Comment 2 David Grogan 2012-07-27 16:34:22 PDT
Created attachment 155087 [details]
Patch
Comment 3 David Grogan 2012-07-27 16:39:45 PDT
Created attachment 155088 [details]
Patch
Comment 4 David Grogan 2012-07-27 16:41:13 PDT
Josh and Alec, could you take a look at this?
Comment 5 Joshua Bell 2012-07-29 19:44:54 PDT
Comment on attachment 155088 [details]
Patch

Didn't finish going through, but initial feedback.

View in context: https://bugs.webkit.org/attachment.cgi?id=155088&action=review

> LayoutTests/storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js:11
> +    dbname = self.location.pathname.substring(1 + self.location.pathname.lastIndexOf("/"));

This is getting a bit long to type and fragile to copy/paste, how about a helper in shared.js, e.g. setDBNameFromTestPath() ? It could log something pretty to the output.

> LayoutTests/storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js:21
> +    request.onupgradeneeded = upgradeNeeded;

Add onblocked handler? (Your suggestion elsewhere - I think we want to do that in general going forward so we get TEXT fail w/ diff rather than TIMEOUT.)

Ditto for the other tests.

> LayoutTests/storage/indexeddb/resources/intversion-and-setversion.js:49
> +    db = trans.db;

Is this line needed?

> LayoutTests/storage/indexeddb/resources/intversion-and-setversion.js:59
> +    db = event.target.db;

Or this one? If I understand things correctly, db should have remained the same object the whole time.

> LayoutTests/storage/indexeddb/resources/intversion-blocked.js:25
> +      event = evt;

Should be indented 2 more spaces.

> LayoutTests/storage/indexeddb/resources/intversion-blocked.js:71
> +    evalAndLog("gotBlockedEvent = true");

I don't know if we do anywhere else, but in one of these tests it wouldn't hurt to say: shouldBe("event.target", "connection1");

> LayoutTests/storage/indexeddb/resources/intversion-close-between-events.js:37
> +    transaction.oncomplete = function(e)

In other tests, we don't include the e parameter if not used, and { on the same line as function keyword for anonymous functions. I'm not sure we're totally consistent, though.

> LayoutTests/storage/indexeddb/resources/intversion-close-between-events.js:56
> +function openSuccess(evt)

Do we know what the state of db should be here? To test if db is closed we can call db.transaction() on it (it will raise if db is closed).

> LayoutTests/storage/indexeddb/resources/intversion-close-between-events.js:66
> +      finishJSTest();

Should be indented two more spaces.

> LayoutTests/storage/indexeddb/resources/intversion-close-in-oncomplete.js:33
> +    evalAndLog("db.createObjectStore(\"os\")");

For readability, use single quotes instead of escaped quotes?
Comment 6 Joshua Bell 2012-07-29 20:34:54 PDT
Comment on attachment 155088 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=155088&action=review

> LayoutTests/storage/indexeddb/resources/intversion-high-version-first.js:6
> +description("Test that if two open requests are waiting at the same time, the one with the higher version gets called first");

Wow... the consequences of this are non-intuitive!

> LayoutTests/storage/indexeddb/resources/intversion-high-version-first.js:45
> +    request2.onsuccess = successCallback2;

... so 2 succeeds because 1 closes promptly, but 3 and 4 get queued and 4 wins, 3 is blocked?

I would have expected that all 3 are treated equally, 4 wins, and 2 and 3 get VersionError.

> LayoutTests/storage/indexeddb/resources/intversion-open-with-version.js:26
> +    shouldBeEqualToString("Object.prototype.toString.apply(request)", "[object IDBOpenDBRequest]");

Other tests use String(foo) rather than the ...apply() call. While I'm a pedantic fan of the latter, the former is easier to read. :)
Comment 7 David Grogan 2012-07-30 12:28:46 PDT
Comment on attachment 155088 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=155088&action=review

>> LayoutTests/storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js:11
>> +    dbname = self.location.pathname.substring(1 + self.location.pathname.lastIndexOf("/"));
> 
> This is getting a bit long to type and fragile to copy/paste, how about a helper in shared.js, e.g. setDBNameFromTestPath() ? It could log something pretty to the output.

Added.  Also added preamble() to shared.js.

>> LayoutTests/storage/indexeddb/resources/intversion-abort-in-initial-upgradeneeded.js:21
>> +    request.onupgradeneeded = upgradeNeeded;
> 
> Add onblocked handler? (Your suggestion elsewhere - I think we want to do that in general going forward so we get TEXT fail w/ diff rather than TIMEOUT.)
> 
> Ditto for the other tests.

Done, I think everywhere.

>> LayoutTests/storage/indexeddb/resources/intversion-and-setversion.js:49
>> +    db = trans.db;
> 
> Is this line needed?

Not strictly needed, but I like to retrieve all the genericly named objects in the function so as to be resilient against changes in the other earlier function.  If I intend to reuse an object later in a different function I try to either declare it in the global scope or give it an explicit name, a la connection1.

What do you do?

>> LayoutTests/storage/indexeddb/resources/intversion-blocked.js:25
>> +      event = evt;
> 
> Should be indented 2 more spaces.

Moved to new function.

>> LayoutTests/storage/indexeddb/resources/intversion-blocked.js:71
>> +    evalAndLog("gotBlockedEvent = true");
> 
> I don't know if we do anywhere else, but in one of these tests it wouldn't hurt to say: shouldBe("event.target", "connection1");

Added to versionChangeHandler above.

>> LayoutTests/storage/indexeddb/resources/intversion-close-between-events.js:37
>> +    transaction.oncomplete = function(e)
> 
> In other tests, we don't include the e parameter if not used, and { on the same line as function keyword for anonymous functions. I'm not sure we're totally consistent, though.

Fixed.

>> LayoutTests/storage/indexeddb/resources/intversion-close-between-events.js:56
>> +function openSuccess(evt)
> 
> Do we know what the state of db should be here? To test if db is closed we can call db.transaction() on it (it will raise if db is closed).

It should be open, since db.close hasn't been called yet.  Added a transaction line.

>> LayoutTests/storage/indexeddb/resources/intversion-close-between-events.js:66
>> +      finishJSTest();
> 
> Should be indented two more spaces.

Thanks.  I need to get vim to autoindent 4 spaces if the file matches third_party/WebKit.

>> LayoutTests/storage/indexeddb/resources/intversion-close-in-oncomplete.js:33
>> +    evalAndLog("db.createObjectStore(\"os\")");
> 
> For readability, use single quotes instead of escaped quotes?

Done.

>> LayoutTests/storage/indexeddb/resources/intversion-high-version-first.js:6
>> +description("Test that if two open requests are waiting at the same time, the one with the higher version gets called first");
> 
> Wow... the consequences of this are non-intuitive!

Yeah, I'm not sure I'm reading the spec correctly either.  It could use some clarification on this point.  I intend to file a bug.

>> LayoutTests/storage/indexeddb/resources/intversion-high-version-first.js:45
>> +    request2.onsuccess = successCallback2;
> 
> ... so 2 succeeds because 1 closes promptly, but 3 and 4 get queued and 4 wins, 3 is blocked?
> 
> I would have expected that all 3 are treated equally, 4 wins, and 2 and 3 get VersionError.

Now that I'm re-reading this, I feel like you're right.  Either way, we don't do it right yet.  Firefox fires upgradeneeded at 2 then 3 then 4, so I don't think they have figured it out either.

>> LayoutTests/storage/indexeddb/resources/intversion-open-with-version.js:26
>> +    shouldBeEqualToString("Object.prototype.toString.apply(request)", "[object IDBOpenDBRequest]");
> 
> Other tests use String(foo) rather than the ...apply() call. While I'm a pedantic fan of the latter, the former is easier to read. :)

Ah yes, I switched to String(foo) halfway through these tests.
Comment 8 David Grogan 2012-07-30 13:03:25 PDT
Created attachment 155343 [details]
Patch
Comment 9 David Grogan 2012-07-30 14:14:19 PDT
Created attachment 155360 [details]
Patch
Comment 10 David Grogan 2012-07-31 13:26:10 PDT
Created attachment 155622 [details]
Patch
Comment 11 David Grogan 2012-07-31 13:31:51 PDT
Created attachment 155623 [details]
Patch
Comment 12 David Grogan 2012-07-31 13:33:27 PDT
Removed intversion-high-version-first (for now) because it causes the new code to permanently stay in m_runningVersionChangeTransaction, causing the next test to timeout.
Comment 13 David Grogan 2012-07-31 16:12:45 PDT
Created attachment 155662 [details]
Patch
Comment 14 David Grogan 2012-07-31 16:35:58 PDT
Created attachment 155674 [details]
Patch
Comment 15 David Grogan 2012-07-31 18:38:03 PDT
Tony, could you review this?

I'm going to land a series of patches in the coming days (hopefully by friday!) that will enable some of this functionality incrementally.  It'd be nice to land these all at once and then just include updated expected files with the code as necessary.

Josh didn't LGTM here but he did say it looked good in an offline thread.
Comment 16 David Grogan 2012-08-01 11:26:08 PDT
Nate,

Tony, our usual reviewer, is OOO the next couple of days.  Could you review this?
Comment 17 David Grogan 2012-08-01 14:28:45 PDT
Created attachment 155885 [details]
Patch for landing
Comment 18 WebKit Review Bot 2012-08-01 16:27:30 PDT
Comment on attachment 155885 [details]
Patch for landing

Clearing flags on attachment: 155885

Committed r124383: <http://trac.webkit.org/changeset/124383>
Comment 19 WebKit Review Bot 2012-08-01 16:27:34 PDT
All reviewed patches have been landed.  Closing bug.
Comment 20 David Grogan 2012-08-21 15:26:28 PDT
*** Bug 84309 has been marked as a duplicate of this bug. ***