Title: [186225] trunk
Revision
186225
Author
carlo...@webkit.org
Date
2015-07-02 06:00:35 -0700 (Thu, 02 Jul 2015)

Log Message

[GTK] WebSQL doesn't work because openDatabase always fails with DOM Exception 18
https://bugs.webkit.org/show_bug.cgi?id=146234

Reviewed by Sergio Villar Senin.

Source/WebKit2:

This is because we don't provide any quota, and 0 is used by
default, so there's never enough quota and openDatabase fails. We
should expose this in the API, but for now, we could use a default
quota of 5MB like WTR does.

* UIProcess/API/gtk/WebKitUIClient.cpp: Override
exceededDatabaseQuota and return always the default quota.
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::exceededDatabaseQuota): Return the quota based on the
expected usage and current database usabe like mac does.
(WebKit::WebInspectorProxy::platformCreateInspectorPage): Add
custom UI client to implement exceededDatabaseQuota.

Tools:

Enable the WebSQL directory test that was disabled because of this bug.

* TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
(testWebContextConfiguration):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (186224 => 186225)


--- trunk/Source/WebKit2/ChangeLog	2015-07-02 12:13:58 UTC (rev 186224)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-02 13:00:35 UTC (rev 186225)
@@ -1,3 +1,23 @@
+2015-07-02  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] WebSQL doesn't work because openDatabase always fails with DOM Exception 18
+        https://bugs.webkit.org/show_bug.cgi?id=146234
+
+        Reviewed by Sergio Villar Senin.
+
+        This is because we don't provide any quota, and 0 is used by
+        default, so there's never enough quota and openDatabase fails. We
+        should expose this in the API, but for now, we could use a default
+        quota of 5MB like WTR does.
+
+        * UIProcess/API/gtk/WebKitUIClient.cpp: Override
+        exceededDatabaseQuota and return always the default quota.
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::exceededDatabaseQuota): Return the quota based on the
+        expected usage and current database usabe like mac does.
+        (WebKit::WebInspectorProxy::platformCreateInspectorPage): Add
+        custom UI client to implement exceededDatabaseQuota.
+
 2015-07-02  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r185704.

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp (186224 => 186225)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp	2015-07-02 12:13:58 UTC (rev 186224)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp	2015-07-02 13:00:35 UTC (rev 186225)
@@ -146,6 +146,13 @@
         return WebCore::FloatRect(geometry);
     }
 
+    virtual void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const String&, const String&, unsigned long long /*currentQuota*/, unsigned long long /*currentOriginUsage*/, unsigned long long /*currentDatabaseUsage*/, unsigned long long /*expectedUsage*/, std::function<void (unsigned long long)> completionHandler) override
+    {
+        static const unsigned long long defaultQuota = 5 * 1024 * 1204; // 5 MB
+        // FIXME: Provide API for this.
+        completionHandler(defaultQuota);
+    }
+
     virtual bool runOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) override
     {
         GRefPtr<WebKitFileChooserRequest> request = adoptGRef(webkitFileChooserRequestCreate(parameters, listener));

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (186224 => 186225)


--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2015-07-02 12:13:58 UTC (rev 186224)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2015-07-02 13:00:35 UTC (rev 186225)
@@ -52,6 +52,11 @@
     inspectorProxy->close();
 }
 
+static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, WKStringRef, unsigned long long, unsigned long long, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void*)
+{
+    return std::max<unsigned long long>(expectedUsage, currentDatabaseUsage * 1.25);
+}
+
 void WebInspectorProxy::initializeInspectorClientGtk(const WKInspectorClientGtkBase* inspectorClient)
 {
     m_client.initialize(inspectorClient);
@@ -75,7 +80,61 @@
     m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorProcessPool(), preferences.get(), pageGroup.get(), nullptr, nullptr));
     g_object_add_weak_pointer(G_OBJECT(m_inspectorView), reinterpret_cast<void**>(&m_inspectorView));
 
-    return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
+    WKPageUIClientV2 uiClient = {
+        { 2, this },
+        nullptr, // createNewPage_deprecatedForUseWithV0
+        nullptr, // showPage
+        nullptr, // closePage
+        nullptr, // takeFocus
+        nullptr, // focus
+        nullptr, // unfocus
+        nullptr, // runJavaScriptAlert
+        nullptr, // runJavaScriptConfirm
+        nullptr, // runJavaScriptPrompt
+        nullptr, // setStatusText
+        nullptr, // mouseDidMoveOverElement_deprecatedForUseWithV0
+        nullptr, // missingPluginButtonClicked_deprecatedForUseWithV0
+        nullptr, // didNotHandleKeyEvent
+        nullptr, // didNotHandleWheelEvent
+        nullptr, // areToolbarsVisible
+        nullptr, // setToolbarsVisible
+        nullptr, // isMenuBarVisible
+        nullptr, // setMenuBarVisible
+        nullptr, // isStatusBarVisible
+        nullptr, // setStatusBarVisible
+        nullptr, // isResizable
+        nullptr, // setResizable
+        nullptr, // getWindowFrame,
+        nullptr, // setWindowFrame,
+        nullptr, // runBeforeUnloadConfirmPanel
+        nullptr, // didDraw
+        nullptr, // pageDidScroll
+        exceededDatabaseQuota,
+        nullptr, // runOpenPanel,
+        nullptr, // decidePolicyForGeolocationPermissionRequest
+        nullptr, // headerHeight
+        nullptr, // footerHeight
+        nullptr, // drawHeader
+        nullptr, // drawFooter
+        nullptr, // printFrame
+        nullptr, // runModal
+        nullptr, // unused
+        nullptr, // saveDataToFileInDownloadsFolder
+        nullptr, // shouldInterruptJavaScript
+        nullptr, // createPage
+        nullptr, // mouseDidMoveOverElement
+        nullptr, // decidePolicyForNotificationPermissionRequest
+        nullptr, // unavailablePluginButtonClicked_deprecatedForUseWithV1
+        nullptr, // showColorPicker
+        nullptr, // hideColorPicker
+        nullptr, // unavailablePluginButtonClicked
+    };
+
+    WebPageProxy* inspectorPage = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
+    ASSERT(inspectorPage);
+    WKPageSetPageUIClient(toAPI(inspectorPage), &uiClient.base);
+
+    return inspectorPage;
 }
 
 void WebInspectorProxy::createInspectorWindow()

Modified: trunk/Tools/ChangeLog (186224 => 186225)


--- trunk/Tools/ChangeLog	2015-07-02 12:13:58 UTC (rev 186224)
+++ trunk/Tools/ChangeLog	2015-07-02 13:00:35 UTC (rev 186225)
@@ -1,3 +1,15 @@
+2015-07-02  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] WebSQL doesn't work because openDatabase always fails with DOM Exception 18
+        https://bugs.webkit.org/show_bug.cgi?id=146234
+
+        Reviewed by Sergio Villar Senin.
+
+        Enable the WebSQL directory test that was disabled because of this bug.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp:
+        (testWebContextConfiguration):
+
 2015-07-01  Matthew Daiter  <mdai...@apple.com>
 
         Enabled MEDIA_STREAM flag

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp (186224 => 186225)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp	2015-07-02 12:13:58 UTC (rev 186224)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp	2015-07-02 13:00:35 UTC (rev 186225)
@@ -71,10 +71,8 @@
 
     GUniquePtr<char> webSQLDirectory(g_build_filename(Test::dataDirectory(), "websql", nullptr));
     g_assert_cmpstr(webSQLDirectory.get(), ==, webkit_website_data_manager_get_websql_directory(manager));
-#if 0 // FIXME: We need API to set the database quota for an origin to be able to test this.
-    test->runJavaScriptAndWaitUntilFinished("db = openDatabase(\"TestDatabase\", \"1.0\", \"TestDatabase\", 1);", &error);
+    test->runJavaScriptAndWaitUntilFinished("db = openDatabase(\"TestDatabase\", \"1.0\", \"TestDatabase\", 1);", nullptr);
     g_assert(g_file_test(webSQLDirectory.get(), G_FILE_TEST_IS_DIR));
-#endif
 
     GUniquePtr<char> diskCacheDirectory(g_build_filename(Test::dataDirectory(), "disk-cache", nullptr));
     g_assert_cmpstr(diskCacheDirectory.get(), ==, webkit_website_data_manager_get_disk_cache_directory(manager));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to