| 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 "core/CSSPropertyNames.h" | 9 #include "core/CSSPropertyNames.h" |
| 10 #include "core/dom/NodeRenderStyle.h" | 10 #include "core/dom/NodeRenderStyle.h" |
| 11 #include "core/dom/StyleEngine.h" | 11 #include "core/dom/StyleEngine.h" |
| 12 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
| 13 #include "core/html/HTMLElement.h" | 13 #include "core/html/HTMLElement.h" |
| 14 #include "core/page/Page.h" | 14 #include "core/page/Page.h" |
| 15 #include "core/rendering/style/RenderStyle.h" | 15 #include "core/rendering/style/RenderStyle.h" |
| 16 #include "platform/graphics/Color.h" | 16 #include "platform/graphics/Color.h" |
| 17 #include "web/tests/FrameTestHelpers.h" | 17 #include "web/tests/FrameTestHelpers.h" |
| 18 #include "web/tests/URLTestHelpers.h" |
| 18 | 19 |
| 19 #include <gtest/gtest.h> | 20 #include <gtest/gtest.h> |
| 20 | 21 |
| 22 using namespace blink; |
| 21 using blink::Color; | 23 using blink::Color; |
| 22 using blink::Document; | 24 using blink::Document; |
| 23 using blink::HTMLElement; | 25 using blink::HTMLElement; |
| 24 using blink::RenderStyle; | 26 using blink::RenderStyle; |
| 25 using blink::FrameTestHelpers::WebViewHelper; | 27 using blink::FrameTestHelpers::WebViewHelper; |
| 28 using blink::URLTestHelpers::toKURL; |
| 26 using blink::WebDocument; | 29 using blink::WebDocument; |
| 27 | 30 |
| 28 namespace { | 31 namespace { |
| 29 | 32 |
| 30 TEST(WebDocumentTest, InsertStyleSheet) | 33 TEST(WebDocumentTest, InsertStyleSheet) |
| 31 { | 34 { |
| 32 WebViewHelper webViewHelper; | 35 WebViewHelper webViewHelper; |
| 33 webViewHelper.initializeAndLoad("about:blank"); | 36 webViewHelper.initializeAndLoad("about:blank"); |
| 34 | 37 |
| 35 WebDocument webDoc = webViewHelper.webView()->mainFrame()->document(); | 38 WebDocument webDoc = webViewHelper.webView()->mainFrame()->document(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 53 // Apply inserted stylesheet. | 56 // Apply inserted stylesheet. |
| 54 coreDoc->updateRenderTreeIfNeeded(); | 57 coreDoc->updateRenderTreeIfNeeded(); |
| 55 | 58 |
| 56 style = bodyElement->renderStyle(); | 59 style = bodyElement->renderStyle(); |
| 57 ASSERT(style); | 60 ASSERT(style); |
| 58 | 61 |
| 59 // Inserted stylesheet applied. | 62 // Inserted stylesheet applied. |
| 60 ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(blink::CSSPropertyC
olor)); | 63 ASSERT_EQ(Color(0, 128, 0), style->visitedDependentColor(blink::CSSPropertyC
olor)); |
| 61 } | 64 } |
| 62 | 65 |
| 66 TEST(WebDocumentTest, BeginExitTransition) |
| 67 { |
| 68 std::string baseURL = "http://www.test.com:0/"; |
| 69 const char* htmlURL = "transition_exit.html"; |
| 70 const char* cssURL = "transition_exit.css"; |
| 71 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString::
fromUTF8(htmlURL)); |
| 72 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f
romUTF8(cssURL)); |
| 73 |
| 74 WebViewHelper webViewHelper; |
| 75 webViewHelper.initializeAndLoad(baseURL + htmlURL); |
| 76 |
| 77 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 78 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr
ame())->document(); |
| 79 Element* transitionElement = coreDoc->getElementById("foo"); |
| 80 ASSERT(transitionElement); |
| 81 |
| 82 RenderStyle* transitionStyle = transitionElement->renderStyle(); |
| 83 ASSERT(transitionStyle); |
| 84 |
| 85 HTMLElement* bodyElement = coreDoc->body(); |
| 86 ASSERT(bodyElement); |
| 87 |
| 88 RenderStyle* bodyStyle = bodyElement->renderStyle(); |
| 89 ASSERT(bodyStyle); |
| 90 // The transition_exit.css stylesheet should not have been applied at this p
oint. |
| 91 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(blink::CSSPropert
yColor)); |
| 92 |
| 93 frame->document().beginExitTransition("#foo"); |
| 94 |
| 95 // Make sure the stylesheet load request gets processed. |
| 96 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame); |
| 97 coreDoc->updateRenderTreeIfNeeded(); |
| 98 |
| 99 // The element should now be hidden. |
| 100 transitionStyle = transitionElement->renderStyle(); |
| 101 ASSERT_FALSE(transitionStyle); |
| 102 |
| 103 // The stylesheet should now have been applied. |
| 104 bodyStyle = bodyElement->renderStyle(); |
| 105 ASSERT(bodyStyle); |
| 106 ASSERT_EQ(Color(0, 128, 0), bodyStyle->visitedDependentColor(blink::CSSPrope
rtyColor)); |
| 63 } | 107 } |
| 108 |
| 109 } |
| OLD | NEW |