⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 125736 in webkit


Ignore:
Timestamp:
Aug 15, 2012, 7:14:16 PM (14 years ago)
Author:
jpfau@apple.com
Message:

Allow blocking of Web SQL databases in third-party documents
https://bugs.webkit.org/show_bug.cgi?id=94057

Reviewed by Adam Barth.

Source/WebCore:

Add a check for pages in third-party pages to allow third-party storage blocking of Web SQL databases.

Tests: http/tests/security/cross-origin-websql-allowed.html

http/tests/security/cross-origin-websql.html

  • Modules/webdatabase/DOMWindowWebDatabase.cpp:

(WebCore::DOMWindowWebDatabase::openDatabase): Pass top origin to canAccessDatabase

  • page/SecurityOrigin.cpp:

(WebCore::SecurityOrigin::canAccessStorage): Common method for various types of storage that use the same criteria

  • page/SecurityOrigin.h:

(WebCore::SecurityOrigin::canAccessDatabase): Use canAccessStorage
(WebCore::SecurityOrigin::canAccessLocalStorage): Change to using canAccessStorage
(SecurityOrigin):

LayoutTests:

Created tests for accessing openDatabase from a third party and first party context when third-party blocking is on and off.

  • http/tests/security/cross-origin-websql-allowed-expected.txt: Added.
  • http/tests/security/cross-origin-websql-allowed.html: Added.
  • http/tests/security/cross-origin-websql-expected.txt: Added.
  • http/tests/security/cross-origin-websql.html: Added.
  • http/tests/security/resources/cross-origin-iframe-for-websql.html: Added.
Location:
trunk
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125735 r125736  
     12012-08-14  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        Allow blocking of Web SQL databases in third-party documents
     4        https://bugs.webkit.org/show_bug.cgi?id=94057
     5
     6        Reviewed by Adam Barth.
     7
     8        Created tests for accessing openDatabase from a third party and first party context when third-party blocking is on and off.
     9
     10        * http/tests/security/cross-origin-websql-allowed-expected.txt: Added.
     11        * http/tests/security/cross-origin-websql-allowed.html: Added.
     12        * http/tests/security/cross-origin-websql-expected.txt: Added.
     13        * http/tests/security/cross-origin-websql.html: Added.
     14        * http/tests/security/resources/cross-origin-iframe-for-websql.html: Added.
     15
    1162012-08-15  Kiran Muppala  <cmuppala@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r125734 r125736  
     12012-08-14  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        Allow blocking of Web SQL databases in third-party documents
     4        https://bugs.webkit.org/show_bug.cgi?id=94057
     5
     6        Reviewed by Adam Barth.
     7
     8        Add a check for pages in third-party pages to allow third-party storage blocking of Web SQL databases.
     9
     10        Tests: http/tests/security/cross-origin-websql-allowed.html
     11               http/tests/security/cross-origin-websql.html
     12
     13        * Modules/webdatabase/DOMWindowWebDatabase.cpp:
     14        (WebCore::DOMWindowWebDatabase::openDatabase): Pass top origin to canAccessDatabase
     15        * page/SecurityOrigin.cpp:
     16        (WebCore::SecurityOrigin::canAccessStorage): Common method for various types of storage that use the same criteria
     17        * page/SecurityOrigin.h:
     18        (WebCore::SecurityOrigin::canAccessDatabase): Use canAccessStorage
     19        (WebCore::SecurityOrigin::canAccessLocalStorage): Change to using canAccessStorage
     20        (SecurityOrigin):
     21
    1222012-08-15  Nikhil Bhargava  <nbhargava@google.com>
    223
  • trunk/Source/WebCore/Modules/webdatabase/DOMWindowWebDatabase.cpp

    r112035 r125736  
    4747
    4848    RefPtr<Database> database = 0;
    49     if (AbstractDatabase::isAvailable() && window->document()->securityOrigin()->canAccessDatabase())
     49    if (AbstractDatabase::isAvailable() && window->document()->securityOrigin()->canAccessDatabase(window->document()->topDocument()->securityOrigin()))
    5050        database = Database::openDatabase(window->document(), name, version, displayName, estimatedSize, creationCallback, ec);
    5151
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r125335 r125736  
    392392}
    393393
    394 bool SecurityOrigin::canAccessLocalStorage(const SecurityOrigin* topOrigin) const
     394bool SecurityOrigin::canAccessStorage(const SecurityOrigin* topOrigin) const
    395395{
    396396    if (isUnique())
    397397        return false;
     398
     399    // FIXME: This check should be replaced with an ASSERT once we can guarantee that topOrigin is not null.
     400    if (!topOrigin)
     401        return true;
    398402
    399403    if (m_blockThirdPartyStorage && topOrigin->isThirdParty(this))
  • trunk/Source/WebCore/page/SecurityOrigin.h

    r125335 r125736  
    124124    void blockThirdPartyStorage() { m_blockThirdPartyStorage = true; }
    125125
    126     bool canAccessDatabase() const { return !isUnique(); }
    127     bool canAccessLocalStorage(const SecurityOrigin* topOrigin) const;
     126    bool canAccessDatabase(const SecurityOrigin* topOrigin = 0) const { return canAccessStorage(topOrigin); };
     127    bool canAccessLocalStorage(const SecurityOrigin* topOrigin) const { return canAccessStorage(topOrigin); };
    128128    bool canAccessCookies() const { return !isUnique(); }
    129129    bool canAccessPasswordManager() const { return !isUnique(); }
     
    193193    bool passesFileCheck(const SecurityOrigin*) const;
    194194    bool isThirdParty(const SecurityOrigin*) const;
     195    bool canAccessStorage(const SecurityOrigin*) const;
    195196
    196197    String m_protocol;
Note: See TracChangeset for help on using the changeset viewer.