Remove call to SecurityOrigin::canAccessDatabase from IDB constructor.
authormkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 19:58:47 +0000 (19:58 +0000)
committermkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Feb 2013 19:58:47 +0000 (19:58 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141621 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/security/no-indexeddb-from-sandbox-expected.txt
LayoutTests/http/tests/security/no-indexeddb-from-sandbox.html
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/mac-snowleopard/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wincairo/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp
Source/WebCore/Modules/indexeddb/WorkerContextIndexedDatabase.cpp
Source/WebCore/Modules/indexeddb/WorkerContextIndexedDatabase.h

index a5e5c34..f8f57a7 100644 (file)
@@ -1,3 +1,25 @@
+2013-02-01  Mike West  <mkwst@chromium.org>
+
+        Remove call to SecurityOrigin::canAccessDatabase from IDB constructor.
+        https://bugs.webkit.org/show_bug.cgi?id=108477
+
+        Reviewed by Adam Barth.
+
+        * 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.
+
 2013-02-01  Ryosuke Niwa  <rniwa@webkit.org>
 
         Smart link can erroneously move caret after an URL when typing immediately before it
index 405d34e..dbf833b 100644 (file)
@@ -5,7 +5,15 @@ if (window.testRunner)
 <iframe sandbox="allow-scripts"
     src="data:text/html,
          <script>
-         var db = window.webkitIndexedDB;
-         alert(db ? 'FAIL' : 'PASS');
+             var db = window.webkitIndexedDB;
+             try {
+                 db.open('test');
+                 alert('FAIL: db.open() should throw a SECURITY_ERR in a sandbox.');
+             } catch (e) {
+                 if (e.code === DOMException.SECURITY_ERR)
+                     alert('PASS: db.open() threw a SECURITY_ERR!');
+                 else
+                     alert('FAIL: db.open() threw a ' + e.name);
+             }
          </script>"
      ></iframe>
index 24c76c1..8870981 100644 (file)
@@ -1125,6 +1125,7 @@ Bug(EFL) http/tests/security/cross-origin-indexeddb-allowed.html
 Bug(EFL) http/tests/security/cross-origin-indexeddb.html
 Bug(EFL) http/tests/security/cross-origin-worker-indexeddb-allowed.html
 Bug(EFL) http/tests/security/cross-origin-worker-indexeddb.html
+Bug(EFL) http/tests/security/no-indexeddb-from-sandbox.html
 
 # Quota API is not supported.
 Bug(EFL) storage/storageinfo-missing-arguments.html
index 8c0a166..552fa55 100644 (file)
@@ -138,6 +138,7 @@ http/tests/security/cross-origin-indexeddb-allowed.html
 http/tests/security/cross-origin-indexeddb.html
 http/tests/security/cross-origin-worker-indexeddb-allowed.html
 http/tests/security/cross-origin-worker-indexeddb.html
+http/tests/security/no-indexeddb-from-sandbox.html
 
 # Philip's canvas tests that fail on SnowLeopard only
 canvas/philip/tests/2d.gradient.interpolate.overlap.html
index 3d32336..c7fcbee 100644 (file)
@@ -139,6 +139,7 @@ http/tests/security/cross-origin-indexeddb-allowed.html
 http/tests/security/cross-origin-indexeddb.html
 http/tests/security/cross-origin-worker-indexeddb-allowed.html
 http/tests/security/cross-origin-worker-indexeddb.html
+http/tests/security/no-indexeddb-from-sandbox.html
 
 # Remove from list after enabling CANVAS_PATH
 fast/canvas/canvas-currentPath.html
index 898459d..a131aa5 100644 (file)
@@ -121,6 +121,7 @@ http/tests/security/cross-origin-indexeddb-allowed.html
 http/tests/security/cross-origin-indexeddb.html
 http/tests/security/cross-origin-worker-indexeddb-allowed.html
 http/tests/security/cross-origin-worker-indexeddb.html
+http/tests/security/no-indexeddb-from-sandbox.html
 
 inspector/timeline/timeline-animation-frame.html
 
index fbd8d28..77379c7 100644 (file)
@@ -1100,6 +1100,7 @@ http/tests/security/cross-origin-indexeddb-allowed.html
 http/tests/security/cross-origin-indexeddb.html
 http/tests/security/cross-origin-worker-indexeddb-allowed.html
 http/tests/security/cross-origin-worker-indexeddb.html
+http/tests/security/no-indexeddb-from-sandbox.html
 
 # StorageTracker is not enabled.
 storage/domstorage/localstorage/storagetracker
index a570afe..2c4eb89 100644 (file)
@@ -1622,6 +1622,7 @@ http/tests/security/cross-origin-indexeddb-allowed.html
 http/tests/security/cross-origin-indexeddb.html
 http/tests/security/cross-origin-worker-indexeddb-allowed.html
 http/tests/security/cross-origin-worker-indexeddb.html
+http/tests/security/no-indexeddb-from-sandbox.html
 
 # StorageTracker is not enabled.
 storage/domstorage/localstorage/storagetracker
index b68c72a..74cfe6a 100644 (file)
@@ -1,3 +1,37 @@
+2013-02-01  Mike West  <mkwst@chromium.org>
+
+        Remove call to SecurityOrigin::canAccessDatabase from IDB constructor.
+        https://bugs.webkit.org/show_bug.cgi?id=108477
+
+        Reviewed by Adam Barth.
+
+        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.
+
 2013-02-01  Beth Dakin  <bdakin@apple.com>
 
         Speculative Windows build fix. 
index a616913..75e7a66 100644 (file)
@@ -107,9 +107,6 @@ IDBFactory* DOMWindowIndexedDatabase::indexedDB()
     if (!page)
         return 0;
 
-    if (!document->securityOrigin()->canAccessDatabase())
-        return 0;
-
     if (!m_window->isCurrentlyDisplayedInFrame())
         return 0;
 
index 4048a79..fee90b3 100644 (file)
@@ -38,8 +38,7 @@
 
 namespace WebCore {
 
-WorkerContextIndexedDatabase::WorkerContextIndexedDatabase(ScriptExecutionContext* context)
-    : m_context(context)
+WorkerContextIndexedDatabase::WorkerContextIndexedDatabase()
 {
 }
 
@@ -56,7 +55,7 @@ WorkerContextIndexedDatabase* WorkerContextIndexedDatabase::from(ScriptExecution
 {
     WorkerContextIndexedDatabase* supplement = static_cast<WorkerContextIndexedDatabase*>(Supplement<ScriptExecutionContext>::from(context, supplementName()));
     if (!supplement) {
-        supplement = new WorkerContextIndexedDatabase(context);
+        supplement = new WorkerContextIndexedDatabase();
         provideTo(context, supplementName(), adoptPtr(supplement));
     }
     return supplement;
@@ -69,8 +68,6 @@ IDBFactory* WorkerContextIndexedDatabase::indexedDB(ScriptExecutionContext* cont
 
 IDBFactory* WorkerContextIndexedDatabase::indexedDB()
 {
-    if (!m_context->securityOrigin()->canAccessDatabase())
-        return 0;
     if (!m_factoryBackend)
         m_factoryBackend = IDBFactoryBackendInterface::create();
     if (!m_idbFactory)
index 30bbe0a..11268f1 100644 (file)
@@ -45,12 +45,11 @@ public:
     static IDBFactory* indexedDB(ScriptExecutionContext*);
 
 private:
-    explicit WorkerContextIndexedDatabase(ScriptExecutionContext*);
+    WorkerContextIndexedDatabase();
 
     IDBFactory* indexedDB();
     static const char* supplementName();
 
-    ScriptExecutionContext* m_context;
     RefPtr<IDBFactoryBackendInterface> m_factoryBackend;
     RefPtr<IDBFactory> m_idbFactory;
 };