Skip to content

Commit

Permalink
Unreviewed, reverting 266946@main.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260262

Broke stable Linux builds.

Reverted changeset:

"[WPE][GTK] Move `WebKitWebsiteData/memory-pressure` API test to a separate binary"
https://bugs.webkit.org/show_bug.cgi?id=260256
https://commits.webkit.org/266946@main

Canonical link: https://commits.webkit.org/266948@main
  • Loading branch information
webkit-commit-queue authored and csaavedra committed Aug 16, 2023
1 parent 5c9dd47 commit cd66b91
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 109 deletions.

This file was deleted.

57 changes: 57 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,62 @@ static void testWebViewHandleCorruptedLocalStorage(WebsiteDataTest* test, gconst
g_assert_cmpstr(fooValue.get(), ==, "value");
}

class MemoryPressureTest : public WebViewTest {
public:
MAKE_GLIB_TEST_FIXTURE_WITH_SETUP_TEARDOWN(MemoryPressureTest, setup, teardown);

static void setup()
{
WebKitMemoryPressureSettings* settings = webkit_memory_pressure_settings_new();
webkit_memory_pressure_settings_set_memory_limit(settings, 1);
webkit_memory_pressure_settings_set_poll_interval(settings, 0.001);
webkit_memory_pressure_settings_set_kill_threshold(settings, 1);
webkit_memory_pressure_settings_set_strict_threshold(settings, 0.75);
webkit_memory_pressure_settings_set_conservative_threshold(settings, 0.5);
#if ENABLE(2022_GLIB_API)
webkit_network_session_set_memory_pressure_settings(settings);
#else
webkit_website_data_manager_set_memory_pressure_settings(settings);
#endif
webkit_memory_pressure_settings_free(settings);
}

static void teardown()
{
#if ENABLE(2022_GLIB_API)
webkit_network_session_set_memory_pressure_settings(nullptr);
#else
webkit_website_data_manager_set_memory_pressure_settings(nullptr);
#endif
}

static gboolean loadFailedCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError* error, MemoryPressureTest* test)
{
g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(loadFailedCallback), test);
g_main_loop_quit(test->m_mainLoop);

return TRUE;
}

void waitUntilLoadFailed()
{
g_signal_connect(m_webView, "load-failed", G_CALLBACK(MemoryPressureTest::loadFailedCallback), this);
g_main_loop_run(m_mainLoop);
}
};

static void testMemoryPressureSettings(MemoryPressureTest* test, gconstpointer)
{
// We have set a memory limit of 1MB with a kill threshold of 1 and a poll interval of 0.001.
// The network process will use around 2MB to load the test. The MemoryPressureHandler will
// kill the process as soon as it detects that it's using more than 1MB, so the network process
// won't be able to complete the resource load. This causes an internal error and the load-failed
// signal is emitted.
GUniquePtr<char> fileURL(g_strdup_printf("file://%s/simple.html", Test::getResourcesDir(Test::WebKit2Resources).data()));
test->loadURI(fileURL.get());
test->waitUntilLoadFailed();
}

void beforeAll()
{
kServer = new WebKitTestServer();
Expand All @@ -984,6 +1040,7 @@ void beforeAll()
WebsiteDataTest::add("WebKitWebsiteData", "service-worker-registrations", testWebsiteDataServiceWorkerRegistrations);
WebsiteDataTest::add("WebKitWebsiteData", "dom-cache", testWebsiteDataDOMCache);
WebsiteDataTest::add("WebKitWebsiteData", "handle-corrupted-local-storage", testWebViewHandleCorruptedLocalStorage);
MemoryPressureTest::add("WebKitWebsiteData", "memory-pressure", testMemoryPressureSettings);
WebsiteDataTest::add("WebKitWebsiteData", "origin-and-total-storage-ratio", testWebsiteDataOriginAndTotalStorageRatio);
}

Expand Down
1 change: 0 additions & 1 deletion Tools/TestWebKitAPI/glib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ ADD_WK2_TEST(TestEditor ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestEditor.c
ADD_WK2_TEST(TestFrame ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp)
ADD_WK2_TEST(TestLoaderClient ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp)
ADD_WK2_TEST(TestMultiprocess ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp)
ADD_WK2_TEST(TestNetworkProcessMemoryPressure ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestNetworkProcessMemoryPressure.cpp)
ADD_WK2_TEST(TestOptionMenu ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp)
ADD_WK2_TEST(TestResources ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestResources.cpp)
ADD_WK2_TEST(TestSSL ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp)
Expand Down

0 comments on commit cd66b91

Please sign in to comment.