[Webkit-unassigned] [Bug 125032] New: Web SQL: changeVersion cannot be used in openDatabase creationCallback

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Nov 30 14:28:41 PST 2013


https://bugs.webkit.org/show_bug.cgi?id=125032

           Summary: Web SQL: changeVersion cannot be used in openDatabase
                    creationCallback
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: New Bugs
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: luke at lukestebbing.com


In WebKit 537.71 (Safari 7.0 (9537.71)), I'm seeing the following Web SQL bug. I suspect it affects all WebKit versions with Web SQL support.


Navigate to a domain where you wouldn't mind creating a Web SQL database with a random name, and run the following snippet in the JS console:

db = openDatabase('' + Math.random(), '1', '', 1, function(db) {
    console.log('creationCallback with version "' + db.version + '"');
    db.changeVersion('', '1', function() {
        console.log('changeVersion callback with version "' + db.version + '"');
    }, function(e) {
        console.log('changeVersion error with version "' + db.version + '"');
        console.log(e.message);
    }, function() {
        console.log('changeVersion success with version "' + db.version + '"')
    });
});


Expected:
    creationCallback with version ""
    changeVersion callback with version ""
    changeVersion success with version "1"

Actual:
    creationCallback with version ""
    changeVersion error with version ""
    current version of the database and `oldVersion` argument do not match


I looked at the WebKit source and I'm pretty sure I know what's going wrong. (I'm pinning these urls to a recent revision so they'll be stable, but the problem exists at head.)


Since a creationCallback was provided, DatabaseBackendBase::performOpenAndVerify will be passed false in for shouldSetVersionInNewDatabase, which means it won't call DatabaseBackendBase::setVersionInDatabase:
https://trac.webkit.org/browser/trunk/Source/WebCore/Modules/webdatabase/DatabaseBackendBase.cpp?rev=159890#L363

(Sure enough, I closed the browser and checked the corresponding sqlite3 database on disk, and it had an empty __WebKitDatabaseInfoTable__.)


When DatabaseBackendBase::getVersionFromDatabase calls retrieveTextResultFromDatabase, there are no results and it returns a String(), which constructs a NULL String:
https://trac.webkit.org/browser/trunk/Source/WebCore/Modules/webdatabase/DatabaseBackendBase.cpp?rev=159890#L104


The version is checked in ChangeVersionWrapper::performPreflight, which fails because actualVersion is a NULL String and compares unequal to any String:
https://trac.webkit.org/browser/trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.cpp?rev=159890#L53

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list