Changeset 157874 in webkit


Ignore:
Timestamp:
Oct 23, 2013 11:33:20 AM (11 years ago)
Author:
mark.lam@apple.com
Message:

Re-instate ProposedDatabases needed by detailsForNameAndOrigin().
https://bugs.webkit.org/show_bug.cgi?id=123131.

Reviewed by Geoffrey Garen.

Source/WebCore:

Test: storage/websql/open-database-expand-quota.html

If a webpage tries to create a database that exceeds the database size
quota for that security origin, the WebKit1 quota request mechanism
uses detailsForNameAndOrigin() to get the requested size of the database
(that the webpage is attempting to open) in order to determine whether
to increase the quota or not.

Previously, detailsForNameAndOrigin() relies on the ProposedDatabase
mechanism to provide this size information. This change re-instates the
ProposedDatabase mechanism so that WebKit1 client code that relies on
this behavior will continue to work.

  • Modules/webdatabase/DatabaseManager.cpp:

(WebCore::DatabaseManager::ProposedDatabase::ProposedDatabase):
(WebCore::DatabaseManager::ProposedDatabase::~ProposedDatabase):
(WebCore::DatabaseManager::DatabaseManager):
(WebCore::DatabaseManager::openDatabaseBackend):
(WebCore::DatabaseManager::fullPathForDatabase):
(WebCore::DatabaseManager::detailsForNameAndOrigin):

  • Modules/webdatabase/DatabaseManager.h:

(WebCore::DatabaseManager::ProposedDatabase::origin):
(WebCore::DatabaseManager::ProposedDatabase::details):

Tools:

Updated these files to allow database quotas to grow within a limit for
testing purposes.

  • DumpRenderTree/blackberry/DumpRenderTree.cpp:

(BlackBerry::WebKit::DumpRenderTree::exceededDatabaseQuota):

  • DumpRenderTree/efl/DumpRenderTreeView.cpp:

(onExceededDatabaseQuota):

  • DumpRenderTree/mac/UIDelegate.mm:

(-[UIDelegate webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:]):

  • DumpRenderTree/win/UIDelegate.cpp:

(UIDelegate::exceededDatabaseQuota):

  • WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:

(WTR::InjectedBundlePage::didExceedDatabaseQuota):

  • WebKitTestRunner/TestController.cpp:

(WTR::exceededDatabaseQuota):

LayoutTests:

Added a test to exercise growing the database quota within limit.

  • platform/gtk/TestExpectations:
  • storage/websql/open-database-expand-quota-expected.txt: Added.
  • storage/websql/open-database-expand-quota.html: Added.
  • storage/websql/open-database-over-quota-expected.txt:
  • storage/websql/open-database-over-quota.html:
Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r157860 r157874  
     12013-10-23  Mark Lam  <mark.lam@apple.com>
     2
     3        Re-instate ProposedDatabases needed by detailsForNameAndOrigin().
     4        https://bugs.webkit.org/show_bug.cgi?id=123131.
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Added a test to exercise growing the database quota within limit.
     9
     10        * platform/gtk/TestExpectations:
     11        * storage/websql/open-database-expand-quota-expected.txt: Added.
     12        * storage/websql/open-database-expand-quota.html: Added.
     13        * storage/websql/open-database-over-quota-expected.txt:
     14        * storage/websql/open-database-over-quota.html:
     15
    1162013-10-23  Mihai Maerean  <mmaerean@adobe.com>
    217
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r157857 r157874  
    447447webkit.org/b/107194 http/tests/security/cross-origin-worker-indexeddb.html [ Skip ]
    448448webkit.org/b/107194 http/tests/security/no-indexeddb-from-sandbox.html [ Skip ]
     449
     450# Needs to update the gtk databaseQuotaExceeded() test function to handle quota expansion requests.
     451storage/websql/open-database-expand-quota.html [ Failure ]
    449452
    450453#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/LayoutTests/storage/websql/open-database-over-quota-expected.txt

    r117816 r157874  
    1 This tests that calling openDatabase with a size over 5MB doesn't assert on debug builds.
     1This tests that calling openDatabase with a size greater or equal to the test max quota limit of 10MB doesn't assert on debug builds.
    22PASS
  • trunk/LayoutTests/storage/websql/open-database-over-quota.html

    r120516 r157874  
    99
    1010    try {
    11         var db = openDatabase('OverQuotaOpen', '', 'Test for bug 36473: missing lock in call to doneCreatingDatabase', 10000000);
     11        var db = openDatabase('OverQuotaOpen', '', 'Test for bug 36473: missing lock in call to doneCreatingDatabase', 20000000);
    1212    } catch (err) {
    1313        document.getElementById('result').innerHTML = 'PASS'
     
    1717</head>
    1818<body onload="runTest()">
    19 <div>This tests that calling openDatabase with a size over 5MB doesn't assert on debug builds.
     19<div>This tests that calling openDatabase with a size greater or equal to the test max quota limit of 10MB
     20doesn't assert on debug builds.
    2021<div id="result">
    2122FAIL: We shouldn't have been able to open the database.
  • trunk/Source/WebCore/ChangeLog

    r157870 r157874  
     12013-10-23  Mark Lam  <mark.lam@apple.com>
     2
     3        Re-instate ProposedDatabases needed by detailsForNameAndOrigin().
     4        https://bugs.webkit.org/show_bug.cgi?id=123131.
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Test: storage/websql/open-database-expand-quota.html
     9
     10        If a webpage tries to create a database that exceeds the database size
     11        quota for that security origin, the WebKit1 quota request mechanism
     12        uses detailsForNameAndOrigin() to get the requested size of the database
     13        (that the webpage is attempting to open) in order to determine whether
     14        to increase the quota or not.
     15
     16        Previously, detailsForNameAndOrigin() relies on the ProposedDatabase
     17        mechanism to provide this size information. This change re-instates the
     18        ProposedDatabase mechanism so that WebKit1 client code that relies on
     19        this behavior will continue to work.
     20
     21        * Modules/webdatabase/DatabaseManager.cpp:
     22        (WebCore::DatabaseManager::ProposedDatabase::ProposedDatabase):
     23        (WebCore::DatabaseManager::ProposedDatabase::~ProposedDatabase):
     24        (WebCore::DatabaseManager::DatabaseManager):
     25        (WebCore::DatabaseManager::openDatabaseBackend):
     26        (WebCore::DatabaseManager::fullPathForDatabase):
     27        (WebCore::DatabaseManager::detailsForNameAndOrigin):
     28        * Modules/webdatabase/DatabaseManager.h:
     29        (WebCore::DatabaseManager::ProposedDatabase::origin):
     30        (WebCore::DatabaseManager::ProposedDatabase::details):
     31
    1322013-10-23  Tim Horton  <timothy_horton@apple.com>
    233
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp

    r157653 r157874  
    5050namespace WebCore {
    5151
     52DatabaseManager::ProposedDatabase::ProposedDatabase(DatabaseManager& manager,
     53    SecurityOrigin* origin, const String& name, const String& displayName, unsigned long estimatedSize)
     54    : m_manager(manager)
     55    , m_origin(origin->isolatedCopy())
     56    , m_details(name.isolatedCopy(), displayName.isolatedCopy(), estimatedSize, 0)
     57{
     58    ASSERT(!m_manager.m_proposedDatabase);
     59    m_manager.m_proposedDatabase = this;
     60}
     61
     62DatabaseManager::ProposedDatabase::~ProposedDatabase()
     63{
     64    m_manager.m_proposedDatabase = 0;
     65}
     66
    5267DatabaseManager& DatabaseManager::manager()
    5368{
     
    6984    , m_databaseContextInstanceCount(0)
    7085#endif
     86    , m_proposedDatabase(0)
    7187{
    7288    ASSERT(m_server); // We should always have a server to work with.
     
    249265            // The client may want to increase the quota, and we'll give it
    250266            // one more try after if that is the case.
    251             databaseContext->databaseExceededQuota(name,
    252                 DatabaseDetails(name.isolatedCopy(), displayName.isolatedCopy(), estimatedSize, 0));
    253 
     267            {
     268                ProposedDatabase proposedDb(*this, context->securityOrigin(), name, displayName, estimatedSize);
     269                databaseContext->databaseExceededQuota(name,
     270                    DatabaseDetails(name.isolatedCopy(), displayName.isolatedCopy(), estimatedSize, 0));
     271            }
    254272            error = DatabaseError::None;
    255273
     
    352370String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfDoesNotExist)
    353371{
     372    ProposedDatabase* db = m_proposedDatabase;
     373    if (db && db->details().name() == name && db->origin()->equal(origin))
     374        return String();
    354375    return m_server->fullPathForDatabase(origin, name, createIfDoesNotExist);
    355376}
     
    372393DatabaseDetails DatabaseManager::detailsForNameAndOrigin(const String& name, SecurityOrigin* origin)
    373394{
     395    ProposedDatabase* db = m_proposedDatabase;
     396    if (db && db->details().name() == name && db->origin()->equal(origin)) {
     397        ASSERT(db->details().thread() == currentThread());
     398        return db->details();
     399    }
    374400    return m_server->detailsForNameAndOrigin(name, origin);
    375401}
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.h

    r157653 r157874  
    107107
    108108private:
     109    class ProposedDatabase {
     110    public:
     111        ProposedDatabase(DatabaseManager&, SecurityOrigin*,
     112            const String& name, const String& displayName, unsigned long estimatedSize);
     113        ~ProposedDatabase();
     114
     115        SecurityOrigin* origin() { return m_origin.get(); }
     116        DatabaseDetails& details() { return m_details; }
     117
     118    private:
     119        DatabaseManager& m_manager;
     120        RefPtr<SecurityOrigin> m_origin;
     121        DatabaseDetails m_details;
     122    };
     123
    109124    DatabaseManager();
    110125    ~DatabaseManager() { }
     
    132147#endif
    133148    Mutex m_contextMapLock;
     149
     150    ProposedDatabase* m_proposedDatabase;
    134151};
    135152
  • trunk/Tools/ChangeLog

    r157873 r157874  
     12013-10-23  Mark Lam  <mark.lam@apple.com>
     2
     3        Re-instate ProposedDatabases needed by detailsForNameAndOrigin().
     4        https://bugs.webkit.org/show_bug.cgi?id=123131.
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Updated these files to allow database quotas to grow within a limit for
     9        testing purposes.
     10
     11        * DumpRenderTree/blackberry/DumpRenderTree.cpp:
     12        (BlackBerry::WebKit::DumpRenderTree::exceededDatabaseQuota):
     13        * DumpRenderTree/efl/DumpRenderTreeView.cpp:
     14        (onExceededDatabaseQuota):
     15        * DumpRenderTree/mac/UIDelegate.mm:
     16        (-[UIDelegate webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:]):
     17        * DumpRenderTree/win/UIDelegate.cpp:
     18        (UIDelegate::exceededDatabaseQuota):
     19        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
     20        (WTR::InjectedBundlePage::didExceedDatabaseQuota):
     21        * WebKitTestRunner/TestController.cpp:
     22        (WTR::exceededDatabaseQuota):
     23
    1242013-10-23  Simon Fraser  <simon.fraser@apple.com>
    225
  • trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp

    r155452 r157874  
    2525#include "BackForwardListBlackBerry.h"
    2626#include "Credential.h"
    27 #include "DatabaseTracker.h"
     27#include "DatabaseManager.h"
    2828#include "DocumentLoader.h"
    2929#include "DumpRenderTree/GCController.h"
     
    784784        printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%s\n", origin->protocol().utf8().data(), origin->host().utf8().data(), origin->port(), name.utf8().data());
    785785
    786     WebCore::DatabaseTracker::tracker().setQuota(mainFrame->document()->securityOrigin(), 5 * 1024 * 1024);
     786    WebCore::DatabaseManager& manager = WebCore::DatabaseManager::manager();
     787    WebCore::DatabaseDetails details = detailsForNameAndOrigin(name, origin);
     788    static const unsigned long long defaultQuota = 5 * 1024 * 1024;
     789    static const unsigned long long maxQuota = 10 * 1024 * 1024;
     790    unsigned long long newQuota = defaultQuota;
     791    if (defaultQuota < expectedSize && expectedSize <= maxQuota) {
     792        newQuota = expectedSize;
     793        printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
     794    }
     795    manager.setQuota(origin, newQuota);
    787796}
    788797
  • trunk/Tools/DumpRenderTree/efl/DumpRenderTreeView.cpp

    r155308 r157874  
    135135    ewk_security_origin_free(origin);
    136136
    137     return 5 * 1024 * 1024;
     137    static const uint64_t defaultQuota = 5 * 1024 * 1024;
     138    static const uint64_t maxQuota = 10 * 1024 * 1024;
     139    if (defaultQuota < expectedSize && expectedSize <= maxQuota) {
     140        printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", expectedSize);
     141        return expectedSize;
     142    }
     143    return defaultQuota;
    138144}
    139145
  • trunk/Tools/DumpRenderTree/mac/UIDelegate.mm

    r156522 r157874  
    3535#import "MockWebNotificationProvider.h"
    3636#import "TestRunner.h"
     37
    3738#import <WebKit/WebApplicationCache.h>
    3839#import <WebKit/WebFramePrivate.h>
    3940#import <WebKit/WebHTMLViewPrivate.h>
     41#import <WebKit/WebDatabaseManagerPrivate.h>
    4042#import <WebKit/WebQuotaManager.h>
    4143#import <WebKit/WebSecurityOriginPrivate.h>
     
    173175    }
    174176
    175     static const unsigned long long defaultQuota = 5 * 1024 * 1024;   
    176     [[origin databaseQuotaManager] setQuota:defaultQuota];
     177    NSDictionary *databaseDetails = [[WebDatabaseManager sharedWebDatabaseManager] detailsForDatabase:databaseIdentifier withOrigin:origin];
     178    ASSERT(databaseDetails);
     179    unsigned long long expectedSize = [[databaseDetails objectForKey:WebDatabaseExpectedSizeKey] unsignedLongLongValue];
     180    static const unsigned long long defaultQuota = 5 * 1024 * 1024;
     181    static const unsigned long long maxQuota = 10 * 1024 * 1024;
     182    unsigned long long newQuota = defaultQuota;
     183    if (defaultQuota < expectedSize && expectedSize <= maxQuota) {
     184        newQuota = expectedSize;
     185        printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
     186    }
     187    [[origin databaseQuotaManager] setQuota:newQuota];
    177188}
    178189
  • trunk/Tools/DumpRenderTree/win/UIDelegate.cpp

    r157387 r157874  
    4242#include <JavaScriptCore/JavaScriptCore.h>
    4343#include <WebKit/WebKit.h>
     44#include <WebKit/WebKitCOMAPI.h>
    4445#include <stdio.h>
    4546
     
    596597
    597598    static const unsigned long long defaultQuota = 5 * 1024 * 1024;
    598     origin->setQuota(defaultQuota);
     599    static const unsigned long long maxQuota = 10 * 1024 * 1024;
     600
     601    COMPtr<IWebDatabaseManager> databaseManager;
     602    COMPtr<IWebDatabaseManager> tmpDatabaseManager;
     603
     604    if (FAILED(WebKitCreateInstance(CLSID_WebDatabaseManager, 0, IID_IWebDatabaseManager, (void**)&tmpDatabaseManager))) {
     605        origin->setQuota(defaultQuota);
     606        return S_OK;
     607    }
     608    if (FAILED(tmpDatabaseManager->sharedWebDatabaseManager(&databaseManager))) {
     609        origin->setQuota(defaultQuota);
     610        return S_OK;
     611    }
     612    IPropertyBag* detailsBag;
     613    if (FAILED(databaseManager->detailsForDatabase(databaseIdentifier, origin, &detailsBag))) {
     614        origin->setQuota(defaultQuota);
     615        return S_OK;
     616    }
     617    VARIANT var;
     618    detailsBag->Read(WebDatabaseUsageKey, &var, 0);
     619    unsigned long long expectedSize = V_UI8(&var);
     620    unsigned long long newQuota = defaultQuota;
     621    if (defaultQuota < expectedSize && expectedSize <= maxQuota) {
     622        newQuota = expectedSize;
     623        printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
     624    }
     625    origin->setQuota(newQuota);
    599626
    600627    return S_OK;
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

    r156797 r157874  
    14501450
    14511451    static const uint64_t defaultQuota = 5 * 1024 * 1024;
    1452     return defaultQuota;
     1452    static const uint64_t maxQuota = 10 * 1024 * 1024;
     1453    uint64_t newQuota = defaultQuota;
     1454    if (defaultQuota < expectedUsageBytes && expectedUsageBytes <= maxQuota) {
     1455        newQuota = expectedUsageBytes;
     1456
     1457        StringBuilder stringBuilder;
     1458        stringBuilder.appendLiteral("UI DELEGATE DATABASE CALLBACK: increased quota to ");
     1459        stringBuilder.appendNumber(newQuota);
     1460        stringBuilder.append('\n');
     1461        InjectedBundle::shared().outputText(stringBuilder.toString());
     1462    }
     1463    return newQuota;
    14531464}
    14541465
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r157323 r157874  
    144144}
    145145
    146 static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, WKStringRef, unsigned long long, unsigned long long, unsigned long long, unsigned long long, const void*)
     146static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, WKStringRef, unsigned long long, unsigned long long, unsigned long long, unsigned long long expectedUsage, const void*)
    147147{
    148148    static const unsigned long long defaultQuota = 5 * 1024 * 1024;
    149     return defaultQuota;
     149    static const unsigned long long maxQuota = 10 * 1024 * 1024;
     150    unsigned long long newQuota = defaultQuota;
     151    if (defaultQuota < expectedUsage && expectedUsage <= maxQuota) {
     152        newQuota = expectedUsage;
     153        printf("UI DELEGATE DATABASE CALLBACK: increased quota to %llu\n", newQuota);
     154    }
     155    return newQuota;
    150156}
    151157
Note: See TracChangeset for help on using the changeset viewer.