Changeset 183992 in webkit
- Timestamp:
- May 8, 2015, 4:53:56 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
Source/WebKit2/ChangeLog (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp (modified) (5 diffs)
-
Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (modified) (1 diff)
-
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r183988 r183992 1 2015-05-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Expose allowFileAccessFromFileURLs setting to WebKit2 GTK+ API 4 https://bugs.webkit.org/show_bug.cgi?id=144748 5 6 Reviewed by Sergio Villar Senin. 7 8 This is needed by local applications loaded as a file URI that do XMLHttpRequests. 9 10 * UIProcess/API/gtk/WebKitSettings.cpp: 11 (webKitSettingsSetProperty): 12 (webKitSettingsGetProperty): 13 (webkit_settings_class_init): 14 (webkit_settings_get_allow_file_access_from_file_urls): 15 (webkit_settings_set_allow_file_access_from_file_urls): 16 * UIProcess/API/gtk/WebKitSettings.h: 17 * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: 18 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: 19 1 20 2015-05-08 Andreas Kling <akling@apple.com> 2 21 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
r178095 r183992 144 144 PROP_ENABLE_MEDIA_STREAM, 145 145 PROP_ENABLE_SPATIAL_NAVIGATION, 146 PROP_ENABLE_MEDIASOURCE 146 PROP_ENABLE_MEDIASOURCE, 147 PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS 147 148 }; 148 149 … … 310 311 webkit_settings_set_enable_mediasource(settings, g_value_get_boolean(value)); 311 312 break; 313 case PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS: 314 webkit_settings_set_allow_file_access_from_file_urls(settings, g_value_get_boolean(value)); 315 break; 312 316 default: 313 317 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); … … 465 469 g_value_set_boolean(value, webkit_settings_get_enable_mediasource(settings)); 466 470 break; 467 471 case PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS: 472 g_value_set_boolean(value, webkit_settings_get_allow_file_access_from_file_urls(settings)); 473 break; 468 474 default: 469 475 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); … … 1218 1224 FALSE, 1219 1225 readWriteConstructParamFlags)); 1226 1227 /** 1228 * WebKitSettings:allow-file-access-from-file-urls: 1229 * 1230 * Whether file access is allowed from file URLs. By default, when 1231 * something is loaded in a #WebKitWebView using a file URI, cross 1232 * origin requests to other file resources are not allowed. This 1233 * setting allows you to change that behaviour, so that it would be 1234 * possible to do a XMLHttpRequest of a local file, for example. 1235 * 1236 * Since: 2.10 1237 */ 1238 g_object_class_install_property(gObjectClass, 1239 PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS, 1240 g_param_spec_boolean("allow-file-access-from-file-urls", 1241 _("Allow file access from file URLs"), 1242 _("Whether file access is allowed from file URLs."), 1243 FALSE, 1244 readWriteConstructParamFlags)); 1220 1245 } 1221 1246 … … 3000 3025 g_object_notify(G_OBJECT(settings), "enable-mediasource"); 3001 3026 } 3027 3028 /** 3029 * webkit_settings_get_allow_file_access_from_file_urls: 3030 * @settings: a #WebKitSettings 3031 * 3032 * Get the #WebKitSettings:allow-file-access-from-file-urls property. 3033 * 3034 * Returns: %TRUE If file access from file URLs is allowed or %FALSE otherwise. 3035 * 3036 * Since: 2.10 3037 */ 3038 gboolean webkit_settings_get_allow_file_access_from_file_urls(WebKitSettings* settings) 3039 { 3040 g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); 3041 3042 return settings->priv->preferences->allowFileAccessFromFileURLs(); 3043 } 3044 3045 /** 3046 * webkit_settings_set_allow_file_access_from_file_urls: 3047 * @settings: a #WebKitSettings 3048 * @allowed: Value to be set 3049 * 3050 * Set the #WebKitSettings:allow-file-access-from-file-urls property. 3051 * 3052 * Since: 2.10 3053 */ 3054 void webkit_settings_set_allow_file_access_from_file_urls(WebKitSettings* settings, gboolean allowed) 3055 { 3056 g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); 3057 3058 WebKitSettingsPrivate* priv = settings->priv; 3059 if (priv->preferences->allowFileAccessFromFileURLs() == allowed) 3060 return; 3061 3062 priv->preferences->setAllowFileAccessFromFileURLs(allowed); 3063 g_object_notify(G_OBJECT(settings), "allow-file-access-from-file-urls"); 3064 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
r160434 r183992 415 415 gboolean enabled); 416 416 417 WEBKIT_API gboolean 418 webkit_settings_get_allow_file_access_from_file_urls (WebKitSettings *settings); 419 420 WEBKIT_API void 421 webkit_settings_set_allow_file_access_from_file_urls (WebKitSettings *settings, 422 gboolean allowed); 423 417 424 G_END_DECLS 418 425 -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
r179984 r183992 432 432 webkit_settings_get_enable_mediasource 433 433 webkit_settings_set_enable_mediasource 434 webkit_settings_get_allow_file_access_from_file_urls 435 webkit_settings_set_allow_file_access_from_file_urls 434 436 435 437 <SUBSECTION Standard> -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r181555 r183992 90 90 </index> 91 91 92 <index id="api-index-2-10" role="2.10"> 93 <title>Index of new symbols in 2.10</title> 94 <xi:include href="xml/api-index-2.10.xml"><xi:fallback /></xi:include> 95 </index> 96 92 97 <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> 93 98 </book> -
trunk/Tools/ChangeLog
r183986 r183992 1 2015-05-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Expose allowFileAccessFromFileURLs setting to WebKit2 GTK+ API 4 https://bugs.webkit.org/show_bug.cgi?id=144748 5 6 Reviewed by Sergio Villar Senin. 7 8 * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp: 9 (testWebKitSettings): Check the new setting is correctly 10 initialized and updated. 11 * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp: 12 (testWebContextSecurityFileXHR): Check XHR to local files is 13 allowed from file URLs after changing the setting. 14 (beforeAll): Add new test. 15 1 16 2015-05-08 Commit Queue <commit-queue@webkit.org> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp
r169892 r183992 274 274 g_assert(webkit_settings_get_enable_mediasource(settings)); 275 275 276 // File access from file URLs is not allowed by default. 277 g_assert(!webkit_settings_get_allow_file_access_from_file_urls(settings)); 278 webkit_settings_set_allow_file_access_from_file_urls(settings, TRUE); 279 g_assert(webkit_settings_get_allow_file_access_from_file_urls(settings)); 280 276 281 g_object_unref(G_OBJECT(settings)); 277 282 } -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp
r176512 r183992 412 412 } 413 413 414 static void testWebContextSecurityFileXHR(WebViewTest* test, gconstpointer) 415 { 416 GUniquePtr<char> fileURL(g_strdup_printf("file://%s/simple.html", Test::getResourcesDir(Test::WebKit2Resources).data())); 417 test->loadURI(fileURL.get()); 418 test->waitUntilLoadFinished(); 419 420 GUniquePtr<char> jsonURL(g_strdup_printf("file://%s/simple.json", Test::getResourcesDir().data())); 421 GUniquePtr<char> xhr(g_strdup_printf("var xhr = new XMLHttpRequest; xhr.open(\"GET\", \"%s\"); xhr.send();", jsonURL.get())); 422 423 // By default file access is not allowed, this will fail with a cross-origin error. 424 GUniqueOutPtr<GError> error; 425 WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished(xhr.get(), &error.outPtr()); 426 g_assert(!javascriptResult); 427 g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED); 428 429 // Allow file access from file URLs. 430 webkit_settings_set_allow_file_access_from_file_urls(webkit_web_view_get_settings(test->m_webView), TRUE); 431 test->loadURI(fileURL.get()); 432 test->waitUntilLoadFinished(); 433 javascriptResult = test->runJavaScriptAndWaitUntilFinished(xhr.get(), &error.outPtr()); 434 g_assert(javascriptResult); 435 g_assert(!error); 436 437 // It isn't still possible to load file from an HTTP URL. 438 test->loadURI(kServer->getURIForPath("/").data()); 439 test->waitUntilLoadFinished(); 440 javascriptResult = test->runJavaScriptAndWaitUntilFinished(xhr.get(), &error.outPtr()); 441 g_assert(!javascriptResult); 442 g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED); 443 444 webkit_settings_set_allow_file_access_from_file_urls(webkit_web_view_get_settings(test->m_webView), FALSE); 445 } 446 414 447 void beforeAll() 415 448 { … … 424 457 WebViewTest::add("WebKitWebContext", "languages", testWebContextLanguages); 425 458 SecurityPolicyTest::add("WebKitSecurityManager", "security-policy", testWebContextSecurityPolicy); 459 WebViewTest::add("WebKitSecurityManager", "file-xhr", testWebContextSecurityFileXHR); 426 460 } 427 461
Note:
See TracChangeset
for help on using the changeset viewer.