Title: [141090] trunk/Source/WebCore
Revision
141090
Author
[email protected]
Date
2013-01-29 03:06:00 -0800 (Tue, 29 Jan 2013)

Log Message

IDBFactory::webkitGetDatabaseNames should raise DOMExceptions.
https://bugs.webkit.org/show_bug.cgi?id=108154

Reviewed by Jochen Eisinger.

In order to properly support blocking third-party IndexedDB usage,
open(), getDatabaseNames(), and deleteDatabase() should all throw
SECURITY_ERR when used in a blocked third-party context. That's possible
now for open() and deleteDatabase(), but getDatabaseNames() can't
currently raise exceptions.

This patch adjusts the IDL file and implementation. No exceptions are
currently thrown, but that will change as soon as wkbug.com/94171 lands.

* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::getDatabaseNames):
* Modules/indexeddb/IDBFactory.h:
(IDBFactory):
* Modules/indexeddb/IDBFactory.idl:
    Add "raises (DOMException)" to getDatabaseNames, and adjust the
    implementation to match.
* inspector/InspectorIndexedDBAgent.cpp:
(WebCore::InspectorIndexedDBAgent::requestDatabaseNamesForFrame):
    Pass in an ExceptionCode when calling getDatabaseNames, and handle
    possible exceptions.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141089 => 141090)


--- trunk/Source/WebCore/ChangeLog	2013-01-29 10:51:39 UTC (rev 141089)
+++ trunk/Source/WebCore/ChangeLog	2013-01-29 11:06:00 UTC (rev 141090)
@@ -1,3 +1,31 @@
+2013-01-29  Mike West  <[email protected]>
+
+        IDBFactory::webkitGetDatabaseNames should raise DOMExceptions.
+        https://bugs.webkit.org/show_bug.cgi?id=108154
+
+        Reviewed by Jochen Eisinger.
+
+        In order to properly support blocking third-party IndexedDB usage,
+        open(), getDatabaseNames(), and deleteDatabase() should all throw
+        SECURITY_ERR when used in a blocked third-party context. That's possible
+        now for open() and deleteDatabase(), but getDatabaseNames() can't
+        currently raise exceptions.
+
+        This patch adjusts the IDL file and implementation. No exceptions are
+        currently thrown, but that will change as soon as wkbug.com/94171 lands.
+
+        * Modules/indexeddb/IDBFactory.cpp:
+        (WebCore::IDBFactory::getDatabaseNames):
+        * Modules/indexeddb/IDBFactory.h:
+        (IDBFactory):
+        * Modules/indexeddb/IDBFactory.idl:
+            Add "raises (DOMException)" to getDatabaseNames, and adjust the
+            implementation to match.
+        * inspector/InspectorIndexedDBAgent.cpp:
+        (WebCore::InspectorIndexedDBAgent::requestDatabaseNamesForFrame):
+            Pass in an ExceptionCode when calling getDatabaseNames, and handle
+            possible exceptions.
+
 2013-01-29  Hayato Ito  <[email protected]>
 
         Revert an accidentally changed line of EventHander::handleMousePressEvent(PlatformMouseEvent&) in r135650.

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (141089 => 141090)


--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp	2013-01-29 10:51:39 UTC (rev 141089)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp	2013-01-29 11:06:00 UTC (rev 141090)
@@ -95,7 +95,7 @@
 }
 }
 
-PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* context)
+PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* context, ExceptionCode&)
 {
     if (!isContextValid(context))
         return 0;

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h (141089 => 141090)


--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h	2013-01-29 10:51:39 UTC (rev 141089)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h	2013-01-29 11:06:00 UTC (rev 141090)
@@ -55,7 +55,7 @@
     }
     ~IDBFactory();
 
-    PassRefPtr<IDBRequest> getDatabaseNames(ScriptExecutionContext*);
+    PassRefPtr<IDBRequest> getDatabaseNames(ScriptExecutionContext*, ExceptionCode&);
 
     PassRefPtr<IDBOpenDBRequest> open(ScriptExecutionContext*, const String& name, ExceptionCode&);
     PassRefPtr<IDBOpenDBRequest> open(ScriptExecutionContext*, const String& name, int64_t version, ExceptionCode&);

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl (141089 => 141090)


--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl	2013-01-29 10:51:39 UTC (rev 141089)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl	2013-01-29 11:06:00 UTC (rev 141090)
@@ -28,7 +28,8 @@
     JSNoStaticTables,
     ImplementationLacksVTable
 ] interface IDBFactory {
-    [CallWith=ScriptExecutionContext, ImplementedAs=getDatabaseNames] IDBRequest webkitGetDatabaseNames();
+    [CallWith=ScriptExecutionContext, ImplementedAs=getDatabaseNames] IDBRequest webkitGetDatabaseNames()
+        raises (DOMException);
 
     // FIXME: Make this [EnforceRange] unsigned long long once webkit.org/b/96798 lands.
     [CallWith=ScriptExecutionContext] IDBOpenDBRequest open(in DOMString name, in [Optional] long long version)

Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (141089 => 141090)


--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2013-01-29 10:51:39 UTC (rev 141089)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2013-01-29 11:06:00 UTC (rev 141090)
@@ -652,7 +652,12 @@
     v8::Context::Scope contextScope(context);
 #endif
 
-    RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document);
+    ExceptionCode ec = 0;
+    RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document, ec);
+    if (ec) {
+        requestCallback->sendFailure("Could not obtain database names.");
+        return;
+    }
     idbRequest->addEventListener(eventNames().successEvent, GetDatabaseNamesCallback::create(requestCallback, document->securityOrigin()->toString()), false);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to