Skip to content

Truly independent web browser

WebContent+test-web: Clear the user style between tests

Andreas Klingb15fa8689434
diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp
index 1d0415f0de9..d80d3324a6f 100644
--- a/Services/WebContent/ConnectionFromClient.cpp
+++ b/Services/WebContent/ConnectionFromClient.cpp
@@ -1122,6 +1122,11 @@ void ConnectionFromClient::debug_request(Web::PageId page_id, ByteString request
return;
}
+ if (request == "clear-user-style") {
+ page->page().set_user_style({});
+ return;
+ }
+
if (request == "spoof-user-agent") {
Web::ResourceLoader::the().set_user_agent(MUST(String::from_byte_string(argument)));
return;
diff --git a/Tests/LibWeb/Text/input/HTML/align-presentational-hint.html b/Tests/LibWeb/Text/input/HTML/align-presentational-hint.html
index 151cf7bf95c..25d16f2e122 100644
--- a/Tests/LibWeb/Text/input/HTML/align-presentational-hint.html
+++ b/Tests/LibWeb/Text/input/HTML/align-presentational-hint.html
@@ -31,5 +31,6 @@
internals.setUserStyle("embed, iframe, img, input, object { vertical-align: top; }");
println("With a user style:");
printVerticalAlign();
+ internals.setUserStyle("");
});
</script>
diff --git a/Tests/LibWeb/test-web/TestWebView.cpp b/Tests/LibWeb/test-web/TestWebView.cpp
index c2a20f1938a..8258ecbba43 100644
--- a/Tests/LibWeb/test-web/TestWebView.cpp
+++ b/Tests/LibWeb/test-web/TestWebView.cpp
@@ -45,6 +45,12 @@ void TestWebView::reset_line_box_borders()
debug_request("set-line-box-borders"sv, "off"sv);
}
+// The user style lives on the page too, so one that a test sets would otherwise style every test after it in this view.
+void TestWebView::reset_user_style()
+{
+ debug_request("clear-user-style"sv);
+}
+
// The emulated position lives on the page, so a test that moves it would otherwise hand its position to the next test.
void TestWebView::reset_geolocation_emulated_position()
{
diff --git a/Tests/LibWeb/test-web/TestWebView.h b/Tests/LibWeb/test-web/TestWebView.h
index 5babdb54a81..b27012aa291 100644
--- a/Tests/LibWeb/test-web/TestWebView.h
+++ b/Tests/LibWeb/test-web/TestWebView.h
@@ -25,6 +25,7 @@ public:
void clear_content_blockers();
void reset_force_dark();
void reset_line_box_borders();
+ void reset_user_style();
void reset_geolocation_emulated_position();
NonnullRefPtr<Core::Promise<Empty>> reset_session_history();
diff --git a/Tests/LibWeb/test-web/main.cpp b/Tests/LibWeb/test-web/main.cpp
index 645fc6b86bf..fa88786edc6 100644
--- a/Tests/LibWeb/test-web/main.cpp
+++ b/Tests/LibWeb/test-web/main.cpp
@@ -1259,6 +1259,7 @@ static ErrorOr<int> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePix
view->reset_zoom();
view->reset_force_dark();
view->reset_line_box_borders();
+ view->reset_user_style();
view->reset_geolocation_emulated_position();
view->reset_viewport_size(window_size);
}