Changeset 214309 in webkit


Ignore:
Timestamp:
Mar 23, 2017 12:06:31 PM (7 years ago)
Author:
beidson@apple.com
Message:

WebSQL databases should not openable in private browsing.
<rdar://problem/30383335> and https://bugs.webkit.org/show_bug.cgi?id=170013

Reviewed by Alex Christensen.

Source/WebCore:

Test: storage/websql/private-browsing-open-disabled.html

  • Modules/webdatabase/DatabaseManager.cpp:

(WebCore::DatabaseManager::openDatabaseBackend):
(WebCore::DatabaseManager::tryToOpenDatabaseBackend): Throw an exception if in private browsing.

  • Modules/webdatabase/DatabaseManager.h:

LayoutTests:

  • storage/websql/private-browsing-open-disabled-expected.txt: Added.
  • storage/websql/private-browsing-open-disabled.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214307 r214309  
     12017-03-23  Brady Eidson  <beidson@apple.com>
     2
     3        WebSQL databases should not openable in private browsing.
     4        <rdar://problem/30383335> and https://bugs.webkit.org/show_bug.cgi?id=170013
     5
     6        Reviewed by Alex Christensen.
     7
     8        * storage/websql/private-browsing-open-disabled-expected.txt: Added.
     9        * storage/websql/private-browsing-open-disabled.html: Added.
     10
    1112017-03-23  Ryan Haddad  <ryanhaddad@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r214305 r214309  
     12017-03-23  Brady Eidson  <beidson@apple.com>
     2
     3        WebSQL databases should not openable in private browsing.
     4        <rdar://problem/30383335> and https://bugs.webkit.org/show_bug.cgi?id=170013
     5
     6        Reviewed by Alex Christensen.
     7
     8        Test: storage/websql/private-browsing-open-disabled.html
     9
     10        * Modules/webdatabase/DatabaseManager.cpp:
     11        (WebCore::DatabaseManager::openDatabaseBackend):
     12        (WebCore::DatabaseManager::tryToOpenDatabaseBackend): Throw an exception if in private browsing.
     13        * Modules/webdatabase/DatabaseManager.h:
     14
    1152017-03-22  Dean Jackson  <dino@apple.com>
    216
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp

    r210292 r214309  
    122122ExceptionOr<Ref<Database>> DatabaseManager::openDatabaseBackend(ScriptExecutionContext& context, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase)
    123123{
    124     auto databaseContext = this->databaseContext(context);
    125 
    126     auto backend = tryToOpenDatabaseBackend(databaseContext, name, expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, FirstTryToOpenDatabase);
     124    auto backend = tryToOpenDatabaseBackend(context, name, expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, FirstTryToOpenDatabase);
    127125
    128126    if (backend.hasException()) {
     
    134132                // FIXME: What guarantees context.securityOrigin() is non-null?
    135133                ProposedDatabase proposedDatabase { *this, *context.securityOrigin(), name, displayName, estimatedSize };
    136                 databaseContext->databaseExceededQuota(name, proposedDatabase.details());
     134                this->databaseContext(context)->databaseExceededQuota(name, proposedDatabase.details());
    137135            }
    138             backend = tryToOpenDatabaseBackend(databaseContext, name, expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, RetryOpenDatabase);
     136            backend = tryToOpenDatabaseBackend(context, name, expectedVersion, displayName, estimatedSize, setVersionInNewDatabase, RetryOpenDatabase);
    139137        }
    140138    }
     
    150148}
    151149
    152 ExceptionOr<Ref<Database>> DatabaseManager::tryToOpenDatabaseBackend(DatabaseContext& backendContext, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase,
     150ExceptionOr<Ref<Database>> DatabaseManager::tryToOpenDatabaseBackend(ScriptExecutionContext& scriptContext, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase,
    153151    OpenAttempt attempt)
    154152{
     153    if (is<Document>(&scriptContext)) {
     154        auto* page = downcast<Document>(scriptContext).page();
     155        if (!page || page->usesEphemeralSession())
     156            return Exception { SECURITY_ERR };
     157    }
     158
     159    if (scriptContext.isWorkerGlobalScope()) {
     160        ASSERT_NOT_REACHED();
     161        return Exception { SECURITY_ERR };
     162    }
     163
     164    auto backendContext = this->databaseContext(scriptContext);
     165
    155166    ExceptionOr<void> preflightResult;
    156167    switch (attempt) {
     
    172183
    173184    // FIXME: What guarantees backendContext.securityOrigin() is non-null?
    174     DatabaseTracker::singleton().setDatabaseDetails(backendContext.securityOrigin(), name, displayName, estimatedSize);
     185    DatabaseTracker::singleton().setDatabaseDetails(backendContext->securityOrigin(), name, displayName, estimatedSize);
    175186    return WTFMove(database);
    176187}
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.h

    r208727 r214309  
    7777    enum OpenAttempt { FirstTryToOpenDatabase, RetryOpenDatabase };
    7878    ExceptionOr<Ref<Database>> openDatabaseBackend(ScriptExecutionContext&, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase);
    79     static ExceptionOr<Ref<Database>> tryToOpenDatabaseBackend(DatabaseContext&, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase, OpenAttempt);
     79    ExceptionOr<Ref<Database>> tryToOpenDatabaseBackend(ScriptExecutionContext&, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase, OpenAttempt);
    8080
    8181    class ProposedDatabase;
Note: See TracChangeset for help on using the changeset viewer.