Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: third_party/WebKit/Source/web/tests/WebDocumentTest.cpp

Issue 2835183002: Provide a method to remove inserted style sheet (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/WebDocument.cpp ('k') | third_party/WebKit/public/web/WebDocument.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WebDocumentTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebDocumentTest.cpp b/third_party/WebKit/Source/web/tests/WebDocumentTest.cpp
index efa3c2171fb45a0f32c206efcdfc021fdde42221..31dccb8ac7f4025630d78f97f805ab25fd15f71d 100644
--- a/third_party/WebKit/Source/web/tests/WebDocumentTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebDocumentTest.cpp
@@ -60,7 +60,7 @@ WebDocument WebDocumentTest::TopWebDocument() const {
return web_view_helper_.WebView()->MainFrame()->GetDocument();
}
-TEST_F(WebDocumentTest, InsertStyleSheet) {
+TEST_F(WebDocumentTest, InsertAndRemoveStyleSheet) {
LoadURL("about:blank");
WebDocument web_doc = TopWebDocument();
@@ -68,7 +68,8 @@ TEST_F(WebDocumentTest, InsertStyleSheet) {
unsigned start_count = core_doc->GetStyleEngine().StyleForElementCount();
- web_doc.InsertStyleSheet("body { color: green }");
+ WebStyleSheetId stylesheet_id =
+ web_doc.InsertStyleSheet("body { color: green }");
// Check insertStyleSheet did not cause a synchronous style recalc.
unsigned element_count =
@@ -93,6 +94,27 @@ TEST_F(WebDocumentTest, InsertStyleSheet) {
// Inserted stylesheet applied.
ASSERT_EQ(Color(0, 128, 0),
style_after_insertion.VisitedDependentColor(CSSPropertyColor));
+
+ start_count = core_doc->GetStyleEngine().StyleForElementCount();
+
+ // Check RemoveInsertedStyleSheet did not cause a synchronous style recalc.
+ web_doc.RemoveInsertedStyleSheet(stylesheet_id);
+ element_count =
+ core_doc->GetStyleEngine().StyleForElementCount() - start_count;
+ ASSERT_EQ(0U, element_count);
+
+ const ComputedStyle& style_before_removing = body_element->ComputedStyleRef();
+
+ // Removed stylesheet not yet applied.
+ ASSERT_EQ(Color(0, 128, 0),
+ style_before_removing.VisitedDependentColor(CSSPropertyColor));
+
+ // Apply removed stylesheet.
+ core_doc->UpdateStyleAndLayoutTree();
+
+ const ComputedStyle& style_after_removing = body_element->ComputedStyleRef();
+ ASSERT_EQ(Color(0, 0, 0),
+ style_after_removing.VisitedDependentColor(CSSPropertyColor));
}
TEST_F(WebDocumentTest, ManifestURL) {
« no previous file with comments | « third_party/WebKit/Source/web/WebDocument.cpp ('k') | third_party/WebKit/public/web/WebDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698