Skip to content
Permalink
Browse files
[SOUP] REGRESSION(r192761): Broke resource URIs for applications that…
… use g_resource_load in a web extension

https://bugs.webkit.org/show_bug.cgi?id=152634

Reviewed by Carlos Garcia Campos.

Source/WebKit2:

Load GResource URIs locally, not in the network process. Applications expect calling
g_resource_load in a web extension to make it possible to load resource URIs, but that
doesn't work now that the network process is in use. Loading them locally solves this.

* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad):

Tools:

* TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
(testLoadFromGResource): Added test.
(beforeAll):
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
(registerGResource): Added.
(webkit_web_extension_initialize_with_user_data): Load the test gresource.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/boring.html: Added.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml: Add an HTML file.


Canonical link: https://commits.webkit.org/170718@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194480 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Michael Catanzaro committed Jan 1, 2016
1 parent fb6339e commit 88a5ac36ced96a6530cf7898186cbf644ac60fbf
@@ -1,3 +1,17 @@
2016-01-01 Michael Catanzaro <mcatanzaro@igalia.com>

[SOUP] REGRESSION(r192761): Broke resource URIs for applications that use g_resource_load in a web extension
https://bugs.webkit.org/show_bug.cgi?id=152634

Reviewed by Carlos Garcia Campos.

Load GResource URIs locally, not in the network process. Applications expect calling
g_resource_load in a web extension to make it possible to load resource URIs, but that
doesn't work now that the network process is in use. Loading them locally solves this.

* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad):

2016-01-01 Jeff Miller <jeffm@apple.com>

Update user-visible copyright strings to include 2016
@@ -160,6 +160,16 @@ void WebLoaderStrategy::scheduleLoad(ResourceLoader* resourceLoader, CachedResou
}
#endif

#if USE(SOUP)
// For apps that call g_resource_load in a web extension.
// https://blogs.gnome.org/alexl/2012/01/26/resources-in-glib/
if (resourceLoader->request().url().protocolIs("resource")) {
LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be handled as a GResource.", resourceLoader->url().string().utf8().data());
startLocalLoad(*resourceLoader);
return;
}
#endif

LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled with the NetworkProcess with priority %d", resourceLoader->url().string().utf8().data(), static_cast<int>(resourceLoader->request().priority()));

ContentSniffingPolicy contentSniffingPolicy = resourceLoader->shouldSniffContent() ? SniffContent : DoNotSniffContent;
@@ -1,3 +1,19 @@
2016-01-01 Michael Catanzaro <mcatanzaro@igalia.com>

[SOUP] REGRESSION(r192761): Broke resource URIs for applications that use g_resource_load in a web extension
https://bugs.webkit.org/show_bug.cgi?id=152634

Reviewed by Carlos Garcia Campos.

* TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
(testLoadFromGResource): Added test.
(beforeAll):
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
(registerGResource): Added.
(webkit_web_extension_initialize_with_user_data): Load the test gresource.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/boring.html: Added.
* TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml: Add an HTML file.

2015-12-31 David Kilzer <ddkilzer@apple.com>

REGRESSION (r194470): Fix warnings uncovered by migrating to WTF_MOVE
@@ -116,6 +116,14 @@ static void testLoadRequest(LoadTrackingTest* test, gconstpointer)
assertNormalLoadHappened(test->m_loadEvents);
}

static void testLoadFromGResource(LoadTrackingTest* test, gconstpointer)
{
GRefPtr<WebKitURIRequest> request(webkit_uri_request_new("resource:///org/webkit/webkit2gtk/tests/boring.html"));
test->loadRequest(request.get());
test->waitUntilLoadFinished();
assertNormalLoadHappened(test->m_loadEvents);
}

class LoadStopTrackingTest : public LoadTrackingTest {
public:
MAKE_GLIB_TEST_FIXTURE(LoadStopTrackingTest);
@@ -517,6 +525,7 @@ void beforeAll()
LoadTrackingTest::add("WebKitWebView", "load-plain-text", testLoadPlainText);
LoadTrackingTest::add("WebKitWebView", "load-bytes", testLoadBytes);
LoadTrackingTest::add("WebKitWebView", "load-request", testLoadRequest);
LoadTrackingTest::add("WebKitWebView", "load-gresource", testLoadFromGResource);
LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled);
LoadTrackingTest::add("WebKitWebView", "title", testWebViewTitle);
LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress);
@@ -375,11 +375,23 @@ static void busAcquiredCallback(GDBusConnection* connection, const char* name, g
}
}

static void registerGResource(void)
{
GUniquePtr<char> resourcesPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", "resources", "webkit2gtk-tests-resources.gresource", nullptr));
GResource* resource = g_resource_load(resourcesPath.get(), nullptr);
g_assert(resource);

g_resources_register(resource);
g_resource_unref(resource);
}

extern "C" void webkit_web_extension_initialize_with_user_data(WebKitWebExtension* extension, GVariant* userData)
{
g_signal_connect(extension, "page-created", G_CALLBACK(pageCreatedCallback), extension);
g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(windowObjectCleared), 0);

registerGResource();

g_assert(userData);
g_assert(g_variant_is_of_type(userData, G_VARIANT_TYPE_UINT32));
GUniquePtr<char> busName(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", g_variant_get_uint32(userData)));
@@ -0,0 +1 @@
<p>This is a boring HTML file.</p>
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/webkit/webkit2gtk/tests/">
<file alias="boring.html">Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/boring.html</file>
<file alias="link-title.js">Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js</file>
</gresource>
</gresources>

0 comments on commit 88a5ac3

Please sign in to comment.