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

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

Issue 290563007: Defer style recalc when inserting extension stylesheets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid Android crash Created 6 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 | « Source/core/dom/StyleEngine.cpp ('k') | Source/web/web.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebDocumentTest.cpp
diff --git a/Source/web/tests/WebDocumentTest.cpp b/Source/web/tests/WebDocumentTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b30ddc63409a4577cb5e01a819d78884c978274f
--- /dev/null
+++ b/Source/web/tests/WebDocumentTest.cpp
@@ -0,0 +1,62 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "public/web/WebDocument.h"
+
+#include "CSSPropertyNames.h"
+#include "core/dom/Document.h"
+#include "core/dom/NodeRenderStyle.h"
+#include "core/frame/LocalFrame.h"
+#include "core/html/HTMLElement.h"
+#include "core/rendering/style/RenderStyle.h"
+#include "platform/graphics/Color.h"
+#include "web/tests/FrameTestHelpers.h"
+
+#include <gtest/gtest.h>
+
+using WebCore::Color;
+using WebCore::Document;
+using WebCore::HTMLElement;
+using WebCore::RenderStyle;
+using blink::FrameTestHelpers::WebViewHelper;
+using blink::WebDocument;
+
+namespace {
+
+TEST(WebDocumentTest, InsertStyleSheet)
+{
+ WebViewHelper webViewHelper;
+ webViewHelper.initializeAndLoad("about:blank");
rune 2014/05/21 12:18:18 See https://code.google.com/p/chromium/issues/deta
+
+ WebDocument webDoc = webViewHelper.webView()->mainFrame()->document();
+ Document* coreDoc = webViewHelper.webViewImpl()->page()->mainFrame()->document();
+
+ webDoc.insertStyleSheet("body { color: green }");
+
+ // Check insertStyleSheet did not cause a synchronous style recalc.
+ unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount();
+ ASSERT_EQ(0U, accessCount);
+
+ HTMLElement* bodyElement = coreDoc->body();
+ ASSERT(bodyElement);
+
+ RenderStyle* style = bodyElement->renderStyle();
+ ASSERT(style);
+
+ // Inserted stylesheet not yet applied.
+ ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(WebCore::CSSPropertyColor));
+
+ // Apply inserted stylesheet.
+ coreDoc->updateRenderTreeIfNeeded();
+
+ style = bodyElement->renderStyle();
+ ASSERT(style);
+
+ // Inserted stylesheet applied.
+ ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(WebCore::CSSPropertyColor));
+}
+
+}
« no previous file with comments | « Source/core/dom/StyleEngine.cpp ('k') | Source/web/web.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698