Title: [130395] trunk
Revision
130395
Author
[email protected]
Date
2012-10-04 08:52:29 -0700 (Thu, 04 Oct 2012)

Log Message

[EFL][WK2] Add setting to allow file access from file:// URLs
https://bugs.webkit.org/show_bug.cgi?id=98121

Patch by Christophe Dumez <[email protected]> on 2012-10-04
Reviewed by Laszlo Gombos.

Source/WebKit2:

Add Ewk setting to set / query permission to access
files from file:// URLs.

* UIProcess/API/efl/ewk_settings.cpp:
(ewk_settings_file_access_from_file_urls_allowed_set):
(ewk_settings_file_access_from_file_urls_allowed_get):
* UIProcess/API/efl/ewk_settings.h:
* UIProcess/API/efl/tests/resources/local_file_access.html: Added.
* UIProcess/API/efl/tests/test_ewk2_settings.cpp:
(TEST_F): Add unit tests for new ewk setting.

Tools:

Allow file access from file:// URLs by default in Minibrowser
to facilitate testing.

* MiniBrowser/efl/main.c:
(browserCreate):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (130394 => 130395)


--- trunk/Source/WebKit2/ChangeLog	2012-10-04 15:47:13 UTC (rev 130394)
+++ trunk/Source/WebKit2/ChangeLog	2012-10-04 15:52:29 UTC (rev 130395)
@@ -1,5 +1,23 @@
 2012-10-04  Christophe Dumez  <[email protected]>
 
+        [EFL][WK2] Add setting to allow file access from file:// URLs
+        https://bugs.webkit.org/show_bug.cgi?id=98121
+
+        Reviewed by Laszlo Gombos.
+
+        Add Ewk setting to set / query permission to access
+        files from file:// URLs.
+
+        * UIProcess/API/efl/ewk_settings.cpp:
+        (ewk_settings_file_access_from_file_urls_allowed_set):
+        (ewk_settings_file_access_from_file_urls_allowed_get):
+        * UIProcess/API/efl/ewk_settings.h:
+        * UIProcess/API/efl/tests/resources/local_file_access.html: Added.
+        * UIProcess/API/efl/tests/test_ewk2_settings.cpp:
+        (TEST_F): Add unit tests for new ewk setting.
+
+2012-10-04  Christophe Dumez  <[email protected]>
+
         [EFL] Run unit tests with Xvfb
         https://bugs.webkit.org/show_bug.cgi?id=98389
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp (130394 => 130395)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp	2012-10-04 15:47:13 UTC (rev 130394)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp	2012-10-04 15:52:29 UTC (rev 130395)
@@ -28,6 +28,7 @@
 
 #include "ewk_settings_private.h"
 #include <WebKit2/WKPreferences.h>
+#include <WebKit2/WKPreferencesPrivate.h>
 
 using namespace WebKit;
 
@@ -99,3 +100,19 @@
 
     return WKPreferencesGetDeveloperExtrasEnabled(settings->preferences.get());
 }
+
+Eina_Bool ewk_settings_file_access_from_file_urls_allowed_set(Ewk_Settings* settings, Eina_Bool enable)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+
+    WKPreferencesSetFileAccessFromFileURLsAllowed(settings->preferences.get(), enable);
+
+    return true;
+}
+
+Eina_Bool ewk_settings_file_access_from_file_urls_allowed_get(const Ewk_Settings* settings)
+{
+    EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+
+    return WKPreferencesGetFileAccessFromFileURLsAllowed(settings->preferences.get());
+}

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h (130394 => 130395)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h	2012-10-04 15:47:13 UTC (rev 130394)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h	2012-10-04 15:52:29 UTC (rev 130395)
@@ -134,6 +134,29 @@
  */
 EAPI Eina_Bool ewk_settings_developer_extras_enabled_get(const Ewk_Settings *settings);
 
+/**
+ * Allow / Disallow file access from file:// URLs.
+ *
+ * By default, file access from file:// URLs is not allowed.
+ *
+ * @param settings settings object to set file access permission
+ *
+ * @return @c EINA_TRUE on success or @EINA_FALSE on failure
+ */
+EAPI Eina_Bool ewk_settings_file_access_from_file_urls_allowed_set(Ewk_Settings *settings, Eina_Bool enable);
+
+/**
+ * Queries if  file access from file:// URLs is allowed.
+ *
+ * By default, file access from file:// URLs is not allowed.
+ *
+ * @param settings settings object to query file access permission
+ *
+ * @return @c EINA_TRUE if file access from file:// URLs is allowed
+           @c EINA_FALSE if not or on failure
+ */
+EAPI Eina_Bool ewk_settings_file_access_from_file_urls_allowed_get(const Ewk_Settings *settings);
+
 #ifdef __cplusplus
 }
 #endif

Added: trunk/Source/WebKit2/UIProcess/API/efl/tests/resources/local_file_access.html (0 => 130395)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/resources/local_file_access.html	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/resources/local_file_access.html	2012-10-04 15:52:29 UTC (rev 130395)
@@ -0,0 +1,31 @@
+<html>
+<head>
+<script>
+function checkFrameLoaded()
+{
+    var myframe = document.getElementById('myframe');
+    var testWindow = myframe.contentWindow;
+    var state = null;
+    try { 
+        var state = testWindow.document.readyState;
+        if (state == "complete") {
+            document.title = "Frame loaded";
+            return;
+        }
+    } catch(e) {}
+    document.title = "Frame NOT loaded";
+}
+
+function loadFrame()
+{
+    var myframe = document.getElementById('myframe');
+    myframe.src = ""
+
+    setTimeout("checkFrameLoaded()", 300);
+}
+</script>
+</head>
+<body _onload_="loadFrame()">
+<iframe id="myframe"></iframe>
+</body>
+</html>

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp (130394 => 130395)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp	2012-10-04 15:47:13 UTC (rev 130394)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_settings.cpp	2012-10-04 15:52:29 UTC (rev 130395)
@@ -26,11 +26,14 @@
 #include "config.h"
 
 #include "UnitTestUtils/EWK2UnitTestBase.h"
+#include "UnitTestUtils/EWK2UnitTestEnvironment.h"
 #include <EWebKit2.h>
 #include <Eina.h>
 
 using namespace EWK2UnitTest;
 
+extern EWK2UnitTestEnvironment* environment;
+
 TEST_F(EWK2UnitTestBase, ewk_settings_fullscreen_enabled)
 {
     Ewk_Settings* settings = ewk_view_settings_get(webView());
@@ -95,3 +98,25 @@
     ASSERT_TRUE(ewk_settings_developer_extras_enabled_set(settings, EINA_FALSE));
     ASSERT_FALSE(ewk_settings_developer_extras_enabled_get(settings));
 }
+
+TEST_F(EWK2UnitTestBase, ewk_settings_file_access_from_file_urls_allowed)
+{
+    CString testURL = environment->urlForResource("local_file_access.html");
+    Ewk_Settings* settings = ewk_view_settings_get(webView());
+
+    ASSERT_FALSE(ewk_settings_file_access_from_file_urls_allowed_get(settings));
+
+    ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_set(settings, true));
+    ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_get(settings));
+
+    // Check that file access from file:// URLs is allowed.
+    ewk_view_uri_set(webView(), testURL.data());
+    ASSERT_TRUE(waitUntilTitleChangedTo("Frame loaded"));
+
+    ASSERT_TRUE(ewk_settings_file_access_from_file_urls_allowed_set(settings, false));
+    ASSERT_FALSE(ewk_settings_file_access_from_file_urls_allowed_get(settings));
+
+    // Check that file access from file:// URLs is NOT allowed.
+    ewk_view_uri_set(webView(), testURL.data());
+    ASSERT_TRUE(waitUntilTitleChangedTo("Frame NOT loaded"));
+}

Modified: trunk/Tools/ChangeLog (130394 => 130395)


--- trunk/Tools/ChangeLog	2012-10-04 15:47:13 UTC (rev 130394)
+++ trunk/Tools/ChangeLog	2012-10-04 15:52:29 UTC (rev 130395)
@@ -1,5 +1,18 @@
 2012-10-04  Christophe Dumez  <[email protected]>
 
+        [EFL][WK2] Add setting to allow file access from file:// URLs
+        https://bugs.webkit.org/show_bug.cgi?id=98121
+
+        Reviewed by Laszlo Gombos.
+
+        Allow file access from file:// URLs by default in Minibrowser
+        to facilitate testing.
+
+        * MiniBrowser/efl/main.c:
+        (browserCreate):
+
+2012-10-04  Christophe Dumez  <[email protected]>
+
         [EFL] Run unit tests with Xvfb
         https://bugs.webkit.org/show_bug.cgi?id=98389
 

Modified: trunk/Tools/MiniBrowser/efl/main.c (130394 => 130395)


--- trunk/Tools/MiniBrowser/efl/main.c	2012-10-04 15:47:13 UTC (rev 130394)
+++ trunk/Tools/MiniBrowser/efl/main.c	2012-10-04 15:52:29 UTC (rev 130395)
@@ -232,6 +232,9 @@
     ewk_view_theme_set(app->browser, THEME_DIR"/default.edj");
     evas_object_name_set(app->browser, "browser");
 
+    Ewk_Settings *settings = ewk_view_settings_get(app->browser);
+    ewk_settings_file_access_from_file_urls_allowed_set(settings, EINA_TRUE);
+
     evas_object_smart_callback_add(app->browser, "load,error", on_error, app);
     evas_object_smart_callback_add(app->browser, "load,progress", on_progress, app);
     evas_object_smart_callback_add(app->browser, "title,changed", on_title_changed, app);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to