Changeset 194480 in webkit


Ignore:
Timestamp:
Jan 1, 2016 1:22:22 PM (8 years ago)
Author:
Michael Catanzaro
Message:

[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.
Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r194479 r194480  
     12016-01-01  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [SOUP] REGRESSION(r192761): Broke resource URIs for applications that use g_resource_load in a web extension
     4        https://bugs.webkit.org/show_bug.cgi?id=152634
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Load GResource URIs locally, not in the network process. Applications expect calling
     9        g_resource_load in a web extension to make it possible to load resource URIs, but that
     10        doesn't work now that the network process is in use. Loading them locally solves this.
     11
     12        * WebProcess/Network/WebLoaderStrategy.cpp:
     13        (WebKit::WebLoaderStrategy::scheduleLoad):
     14
    1152016-01-01  Jeff Miller  <jeffm@apple.com>
    216
  • trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp

    r193752 r194480  
    161161#endif
    162162
     163#if USE(SOUP)
     164    // For apps that call g_resource_load in a web extension.
     165    // https://blogs.gnome.org/alexl/2012/01/26/resources-in-glib/
     166    if (resourceLoader->request().url().protocolIs("resource")) {
     167        LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be handled as a GResource.", resourceLoader->url().string().utf8().data());
     168        startLocalLoad(*resourceLoader);
     169        return;
     170    }
     171#endif
     172
    163173    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()));
    164174
  • trunk/Tools/ChangeLog

    r194473 r194480  
     12016-01-01  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [SOUP] REGRESSION(r192761): Broke resource URIs for applications that use g_resource_load in a web extension
     4        https://bugs.webkit.org/show_bug.cgi?id=152634
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp:
     9        (testLoadFromGResource): Added test.
     10        (beforeAll):
     11        * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
     12        (registerGResource): Added.
     13        (webkit_web_extension_initialize_with_user_data): Load the test gresource.
     14        * TestWebKitAPI/Tests/WebKit2Gtk/resources/boring.html: Added.
     15        * TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml: Add an HTML file.
     16
    1172015-12-31  David Kilzer  <ddkilzer@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestLoaderClient.cpp

    r193622 r194480  
    112112{
    113113    GRefPtr<WebKitURIRequest> request(webkit_uri_request_new(kServer->getURIForPath("/normal").data()));
     114    test->loadRequest(request.get());
     115    test->waitUntilLoadFinished();
     116    assertNormalLoadHappened(test->m_loadEvents);
     117}
     118
     119static void testLoadFromGResource(LoadTrackingTest* test, gconstpointer)
     120{
     121    GRefPtr<WebKitURIRequest> request(webkit_uri_request_new("resource:///org/webkit/webkit2gtk/tests/boring.html"));
    114122    test->loadRequest(request.get());
    115123    test->waitUntilLoadFinished();
     
    518526    LoadTrackingTest::add("WebKitWebView", "load-bytes", testLoadBytes);
    519527    LoadTrackingTest::add("WebKitWebView", "load-request", testLoadRequest);
     528    LoadTrackingTest::add("WebKitWebView", "load-gresource", testLoadFromGResource);
    520529    LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled);
    521530    LoadTrackingTest::add("WebKitWebView", "title", testWebViewTitle);
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp

    r193622 r194480  
    376376}
    377377
     378static void registerGResource(void)
     379{
     380    GUniquePtr<char> resourcesPath(g_build_filename(WEBKIT_EXEC_PATH, "TestWebKitAPI", "WebKit2Gtk", "resources", "webkit2gtk-tests-resources.gresource", nullptr));
     381    GResource* resource = g_resource_load(resourcesPath.get(), nullptr);
     382    g_assert(resource);
     383
     384    g_resources_register(resource);
     385    g_resource_unref(resource);
     386}
     387
    378388extern "C" void webkit_web_extension_initialize_with_user_data(WebKitWebExtension* extension, GVariant* userData)
    379389{
    380390    g_signal_connect(extension, "page-created", G_CALLBACK(pageCreatedCallback), extension);
    381391    g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(windowObjectCleared), 0);
     392
     393    registerGResource();
    382394
    383395    g_assert(userData);
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/webkit2gtk-tests.gresource.xml

    r161366 r194480  
    22<gresources>
    33  <gresource prefix="/org/webkit/webkit2gtk/tests/">
     4    <file alias="boring.html">Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/boring.html</file>
    45    <file alias="link-title.js">Tools/TestWebKitAPI/Tests/WebKit2Gtk/resources/link-title.js</file>
    56  </gresource>
Note: See TracChangeset for help on using the changeset viewer.