Changeset 141621 in webkit


Ignore:
Timestamp:
Feb 1, 2013 11:58:47 AM (11 years ago)
Author:
mkwst@chromium.org
Message:

Remove call to SecurityOrigin::canAccessDatabase from IDB constructor.
https://bugs.webkit.org/show_bug.cgi?id=108477

Reviewed by Adam Barth.

Source/WebCore:

This change removes the 'SecurityOrigin::canAccessDatabase' check from
the constructor for the 'indexedDB' property on both DOMWindow and
WorkerContext. After the patch for http://wkbug.com/94171 this check
is redundant, as all the entry points to IDB are now gated on access
being granted.

As a side-effect, dropping the check in WorkerContextIndexedDatabase
allows us to stop holding a pointer to the ScriptExecutionContext we're
extending, which can only be a good thing.

The tests in storage/indexeddb should continue to pass.

  • Modules/indexeddb/DOMWindowIndexedDatabase.cpp:

(WebCore::DOMWindowIndexedDatabase::indexedDB):

Drop the SecurityOrigin::canAccessDatabase check.

  • Modules/indexeddb/WorkerContextIndexedDatabase.cpp:

(WebCore::WorkerContextIndexedDatabase::WorkerContextIndexedDatabase):
(WebCore::WorkerContextIndexedDatabase::from):

Drop the ScriptExecutionContext parameter from the class's
constructor and callsites.

(WebCore::WorkerContextIndexedDatabase::indexedDB):

Drop the SecurityOrigin::canAccessDatabase check.

  • Modules/indexeddb/WorkerContextIndexedDatabase.h:

(WorkerContextIndexedDatabase):

Drop the stored pointer to ScriptExecutionContext, as we no longer
need it in ::indexedDB.

LayoutTests:

  • http/tests/security/no-indexeddb-from-sandbox-expected.txt:
  • http/tests/security/no-indexeddb-from-sandbox.html:

This test expected the 'webkitIndexedDB' property to be missing
entirely inside a sandbox. The expectation has been updated to
expect 'webkitIndexedDB.open()' to throw a SECURITY_ERR.

  • platform/efl/TestExpectations:
  • platform/mac-snowleopard/TestExpectations:
  • platform/mac/TestExpectations:
  • platform/qt/TestExpectations:
  • platform/win/TestExpectations:
  • platform/wincairo/TestExpectations:

This test was accidentally passing on a variety of platforms that
don't yet implement IndexedDB. Now that failure is distinguishable
we should skip it on a variety of platforms.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141618 r141621  
     12013-02-01  Mike West  <mkwst@chromium.org>
     2
     3        Remove call to SecurityOrigin::canAccessDatabase from IDB constructor.
     4        https://bugs.webkit.org/show_bug.cgi?id=108477
     5
     6        Reviewed by Adam Barth.
     7
     8        * http/tests/security/no-indexeddb-from-sandbox-expected.txt:
     9        * http/tests/security/no-indexeddb-from-sandbox.html:
     10            This test expected the 'webkitIndexedDB' property to be missing
     11            entirely inside a sandbox. The expectation has been updated to
     12            expect 'webkitIndexedDB.open()' to throw a SECURITY_ERR.
     13        * platform/efl/TestExpectations:
     14        * platform/mac-snowleopard/TestExpectations:
     15        * platform/mac/TestExpectations:
     16        * platform/qt/TestExpectations:
     17        * platform/win/TestExpectations:
     18        * platform/wincairo/TestExpectations:
     19            This test was accidentally passing on a variety of platforms that
     20            don't yet implement IndexedDB. Now that failure is distinguishable
     21            we should skip it on a variety of platforms.
     22
    1232013-02-01  Ryosuke Niwa  <rniwa@webkit.org>
    224
  • trunk/LayoutTests/http/tests/security/no-indexeddb-from-sandbox-expected.txt

    r86458 r141621  
    1 ALERT: PASS
     1ALERT: PASS: db.open() threw a SECURITY_ERR!
    22
  • trunk/LayoutTests/http/tests/security/no-indexeddb-from-sandbox.html

    r120174 r141621  
    66    src="data:text/html,
    77         <script>
    8          var db = window.webkitIndexedDB;
    9          alert(db ? 'FAIL' : 'PASS');
     8             var db = window.webkitIndexedDB;
     9             try {
     10                 db.open('test');
     11                 alert('FAIL: db.open() should throw a SECURITY_ERR in a sandbox.');
     12             } catch (e) {
     13                 if (e.code === DOMException.SECURITY_ERR)
     14                     alert('PASS: db.open() threw a SECURITY_ERR!');
     15                 else
     16                     alert('FAIL: db.open() threw a ' + e.name);
     17             }
    1018         </script>"
    1119     ></iframe>
  • trunk/LayoutTests/platform/efl/TestExpectations

    r141584 r141621  
    11261126Bug(EFL) http/tests/security/cross-origin-worker-indexeddb-allowed.html
    11271127Bug(EFL) http/tests/security/cross-origin-worker-indexeddb.html
     1128Bug(EFL) http/tests/security/no-indexeddb-from-sandbox.html
    11281129
    11291130# Quota API is not supported.
  • trunk/LayoutTests/platform/mac-snowleopard/TestExpectations

    r141418 r141621  
    139139http/tests/security/cross-origin-worker-indexeddb-allowed.html
    140140http/tests/security/cross-origin-worker-indexeddb.html
     141http/tests/security/no-indexeddb-from-sandbox.html
    141142
    142143# Philip's canvas tests that fail on SnowLeopard only
  • trunk/LayoutTests/platform/mac/TestExpectations

    r141615 r141621  
    140140http/tests/security/cross-origin-worker-indexeddb-allowed.html
    141141http/tests/security/cross-origin-worker-indexeddb.html
     142http/tests/security/no-indexeddb-from-sandbox.html
    142143
    143144# Remove from list after enabling CANVAS_PATH
  • trunk/LayoutTests/platform/qt/TestExpectations

    r141576 r141621  
    122122http/tests/security/cross-origin-worker-indexeddb-allowed.html
    123123http/tests/security/cross-origin-worker-indexeddb.html
     124http/tests/security/no-indexeddb-from-sandbox.html
    124125
    125126inspector/timeline/timeline-animation-frame.html
  • trunk/LayoutTests/platform/win/TestExpectations

    r141456 r141621  
    11011101http/tests/security/cross-origin-worker-indexeddb-allowed.html
    11021102http/tests/security/cross-origin-worker-indexeddb.html
     1103http/tests/security/no-indexeddb-from-sandbox.html
    11031104
    11041105# StorageTracker is not enabled.
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r141418 r141621  
    16231623http/tests/security/cross-origin-worker-indexeddb-allowed.html
    16241624http/tests/security/cross-origin-worker-indexeddb.html
     1625http/tests/security/no-indexeddb-from-sandbox.html
    16251626
    16261627# StorageTracker is not enabled.
  • trunk/Source/WebCore/ChangeLog

    r141620 r141621  
     12013-02-01  Mike West  <mkwst@chromium.org>
     2
     3        Remove call to SecurityOrigin::canAccessDatabase from IDB constructor.
     4        https://bugs.webkit.org/show_bug.cgi?id=108477
     5
     6        Reviewed by Adam Barth.
     7
     8        This change removes the 'SecurityOrigin::canAccessDatabase' check from
     9        the constructor for the 'indexedDB' property on both DOMWindow and
     10        WorkerContext. After the patch for http://wkbug.com/94171 this check
     11        is redundant, as all the entry points to IDB are now gated on access
     12        being granted.
     13
     14        As a side-effect, dropping the check in WorkerContextIndexedDatabase
     15        allows us to stop holding a pointer to the ScriptExecutionContext we're
     16        extending, which can only be a good thing.
     17
     18        The tests in storage/indexeddb should continue to pass.
     19
     20        * Modules/indexeddb/DOMWindowIndexedDatabase.cpp:
     21        (WebCore::DOMWindowIndexedDatabase::indexedDB):
     22            Drop the SecurityOrigin::canAccessDatabase check.
     23        * Modules/indexeddb/WorkerContextIndexedDatabase.cpp:
     24        (WebCore::WorkerContextIndexedDatabase::WorkerContextIndexedDatabase):
     25        (WebCore::WorkerContextIndexedDatabase::from):
     26            Drop the ScriptExecutionContext parameter from the class's
     27            constructor and callsites.
     28        (WebCore::WorkerContextIndexedDatabase::indexedDB):
     29            Drop the SecurityOrigin::canAccessDatabase check.
     30        * Modules/indexeddb/WorkerContextIndexedDatabase.h:
     31        (WorkerContextIndexedDatabase):
     32            Drop the stored pointer to ScriptExecutionContext, as we no longer
     33            need it in ::indexedDB.
     34
    1352013-02-01  Beth Dakin  <bdakin@apple.com>
    236
  • trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp

    r140509 r141621  
    108108        return 0;
    109109
    110     if (!document->securityOrigin()->canAccessDatabase())
    111         return 0;
    112 
    113110    if (!m_window->isCurrentlyDisplayedInFrame())
    114111        return 0;
  • trunk/Source/WebCore/Modules/indexeddb/WorkerContextIndexedDatabase.cpp

    r140509 r141621  
    3939namespace WebCore {
    4040
    41 WorkerContextIndexedDatabase::WorkerContextIndexedDatabase(ScriptExecutionContext* context)
    42     : m_context(context)
     41WorkerContextIndexedDatabase::WorkerContextIndexedDatabase()
    4342{
    4443}
     
    5756    WorkerContextIndexedDatabase* supplement = static_cast<WorkerContextIndexedDatabase*>(Supplement<ScriptExecutionContext>::from(context, supplementName()));
    5857    if (!supplement) {
    59         supplement = new WorkerContextIndexedDatabase(context);
     58        supplement = new WorkerContextIndexedDatabase();
    6059        provideTo(context, supplementName(), adoptPtr(supplement));
    6160    }
     
    7069IDBFactory* WorkerContextIndexedDatabase::indexedDB()
    7170{
    72     if (!m_context->securityOrigin()->canAccessDatabase())
    73         return 0;
    7471    if (!m_factoryBackend)
    7572        m_factoryBackend = IDBFactoryBackendInterface::create();
  • trunk/Source/WebCore/Modules/indexeddb/WorkerContextIndexedDatabase.h

    r140509 r141621  
    4646
    4747private:
    48     explicit WorkerContextIndexedDatabase(ScriptExecutionContext*);
     48    WorkerContextIndexedDatabase();
    4949
    5050    IDBFactory* indexedDB();
    5151    static const char* supplementName();
    5252
    53     ScriptExecutionContext* m_context;
    5453    RefPtr<IDBFactoryBackendInterface> m_factoryBackend;
    5554    RefPtr<IDBFactory> m_idbFactory;
Note: See TracChangeset for help on using the changeset viewer.