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 "public/web/WebDocument.h" | 5 #include "public/web/WebDocument.h" |
6 | 6 |
7 #include "core/CSSPropertyNames.h" | 7 #include "core/CSSPropertyNames.h" |
8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
9 #include "core/dom/NodeComputedStyle.h" | 9 #include "core/dom/NodeComputedStyle.h" |
10 #include "core/dom/StyleEngine.h" | 10 #include "core/dom/StyleEngine.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return m_webViewHelper.webView()->mainFrame()->document(); | 60 return m_webViewHelper.webView()->mainFrame()->document(); |
61 } | 61 } |
62 | 62 |
63 TEST_F(WebDocumentTest, InsertStyleSheet) | 63 TEST_F(WebDocumentTest, InsertStyleSheet) |
64 { | 64 { |
65 loadURL("about:blank"); | 65 loadURL("about:blank"); |
66 | 66 |
67 WebDocument webDoc = topWebDocument(); | 67 WebDocument webDoc = topWebDocument(); |
68 Document* coreDoc = topDocument(); | 68 Document* coreDoc = topDocument(); |
69 | 69 |
| 70 unsigned startCount = coreDoc->styleEngine().styleForElementCount(); |
| 71 |
70 webDoc.insertStyleSheet("body { color: green }"); | 72 webDoc.insertStyleSheet("body { color: green }"); |
71 | 73 |
72 // Check insertStyleSheet did not cause a synchronous style recalc. | 74 // Check insertStyleSheet did not cause a synchronous style recalc. |
73 unsigned accessCount = coreDoc->styleEngine().resolverAccessCount(); | 75 unsigned elementCount = coreDoc->styleEngine().styleForElementCount() - star
tCount; |
74 ASSERT_EQ(0U, accessCount); | 76 ASSERT_EQ(0U, elementCount); |
75 | 77 |
76 HTMLElement* bodyElement = coreDoc->body(); | 78 HTMLElement* bodyElement = coreDoc->body(); |
77 ASSERT(bodyElement); | 79 ASSERT(bodyElement); |
78 | 80 |
79 const ComputedStyle& styleBeforeInsertion = bodyElement->computedStyleRef(); | 81 const ComputedStyle& styleBeforeInsertion = bodyElement->computedStyleRef(); |
80 | 82 |
81 // Inserted stylesheet not yet applied. | 83 // Inserted stylesheet not yet applied. |
82 ASSERT_EQ(Color(0, 0, 0), styleBeforeInsertion.visitedDependentColor(CSSProp
ertyColor)); | 84 ASSERT_EQ(Color(0, 0, 0), styleBeforeInsertion.visitedDependentColor(CSSProp
ertyColor)); |
83 | 85 |
84 // Apply inserted stylesheet. | 86 // Apply inserted stylesheet. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 load(nestedOriginAInOriginB); | 320 load(nestedOriginAInOriginB); |
319 | 321 |
320 SchemeRegistry::registerURLSchemeAsFirstPartyWhenTopLevel("http"); | 322 SchemeRegistry::registerURLSchemeAsFirstPartyWhenTopLevel("http"); |
321 | 323 |
322 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), topDocument()->firstPartyForCoo
kies()); | 324 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), topDocument()->firstPartyForCoo
kies()); |
323 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), nestedDocument()->firstPartyFor
Cookies()); | 325 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), nestedDocument()->firstPartyFor
Cookies()); |
324 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), nestedNestedDocument()->firstPa
rtyForCookies()); | 326 ASSERT_EQ(toOriginA(nestedOriginAInOriginB), nestedNestedDocument()->firstPa
rtyForCookies()); |
325 } | 327 } |
326 | 328 |
327 } // namespace blink | 329 } // namespace blink |
OLD | NEW |