| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "public/web/WebDocument.h" | 7 #include "public/web/WebDocument.h" |
| 8 | 8 |
| 9 #include "CSSPropertyNames.h" | 9 #include "CSSPropertyNames.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 using blink::WebDocument; | 25 using blink::WebDocument; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 TEST(WebDocumentTest, InsertStyleSheet) | 29 TEST(WebDocumentTest, InsertStyleSheet) |
| 30 { | 30 { |
| 31 WebViewHelper webViewHelper; | 31 WebViewHelper webViewHelper; |
| 32 webViewHelper.initializeAndLoad("about:blank"); | 32 webViewHelper.initializeAndLoad("about:blank"); |
| 33 | 33 |
| 34 WebDocument webDoc = webViewHelper.webView()->mainFrame()->document(); | 34 WebDocument webDoc = webViewHelper.webView()->mainFrame()->document(); |
| 35 Document* coreDoc = webViewHelper.webViewImpl()->page()->mainFrame()->docume
nt(); | 35 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); |
| 36 | 36 |
| 37 webDoc.insertStyleSheet("body { color: green }"); | 37 webDoc.insertStyleSheet("body { color: green }"); |
| 38 | 38 |
| 39 // Check insertStyleSheet did not cause a synchronous style recalc. | 39 // Check insertStyleSheet did not cause a synchronous style recalc. |
| 40 unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount(); | 40 unsigned accessCount = coreDoc->styleEngine()->resolverAccessCount(); |
| 41 ASSERT_EQ(0U, accessCount); | 41 ASSERT_EQ(0U, accessCount); |
| 42 | 42 |
| 43 HTMLElement* bodyElement = coreDoc->body(); | 43 HTMLElement* bodyElement = coreDoc->body(); |
| 44 ASSERT(bodyElement); | 44 ASSERT(bodyElement); |
| 45 | 45 |
| 46 RenderStyle* style = bodyElement->renderStyle(); | 46 RenderStyle* style = bodyElement->renderStyle(); |
| 47 ASSERT(style); | 47 ASSERT(style); |
| 48 | 48 |
| 49 // Inserted stylesheet not yet applied. | 49 // Inserted stylesheet not yet applied. |
| 50 ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(WebCore::CSSPropertyC
olor)); | 50 ASSERT_EQ(Color(0, 0, 0), style->visitedDependentColor(WebCore::CSSPropertyC
olor)); |
| 51 | 51 |
| 52 // Apply inserted stylesheet. | 52 // Apply inserted stylesheet. |
| 53 coreDoc->updateRenderTreeIfNeeded(); | 53 coreDoc->updateRenderTreeIfNeeded(); |
| 54 | 54 |
| 55 style = bodyElement->renderStyle(); | 55 style = bodyElement->renderStyle(); |
| 56 ASSERT(style); | 56 ASSERT(style); |
| 57 | 57 |
| 58 // Inserted stylesheet applied. | 58 // Inserted stylesheet applied. |
| 59 ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(WebCore::CSSPropert
yColor)); | 59 ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(WebCore::CSSPropert
yColor)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 } | 62 } |
| OLD | NEW |