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

Side by Side Diff: Source/web/tests/WebDocumentTest.cpp

Issue 1140153006: Remove Navigation Transitions from Blink. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed layout tests. Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/WebRuntimeFeatures.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/NodeComputedStyle.h" 10 #include "core/dom/NodeComputedStyle.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 // Apply inserted stylesheet. 51 // Apply inserted stylesheet.
52 coreDoc->updateLayoutTreeIfNeeded(); 52 coreDoc->updateLayoutTreeIfNeeded();
53 53
54 const ComputedStyle& styleAfterInsertion = bodyElement->computedStyleRef(); 54 const ComputedStyle& styleAfterInsertion = bodyElement->computedStyleRef();
55 55
56 // Inserted stylesheet applied. 56 // Inserted stylesheet applied.
57 ASSERT_EQ(Color(0, 128, 0), styleAfterInsertion.visitedDependentColor(CSSPro pertyColor)); 57 ASSERT_EQ(Color(0, 128, 0), styleAfterInsertion.visitedDependentColor(CSSPro pertyColor));
58 } 58 }
59 59
60 TEST(WebDocumentTest, BeginExitTransition)
61 {
62 std::string baseURL = "http://www.test.com:0/";
63 const char* htmlURL = "transition_exit.html";
64 const char* cssURL = "transition_exit.css";
65 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString:: fromUTF8(htmlURL));
66 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f romUTF8(cssURL));
67
68 WebViewHelper webViewHelper;
69 webViewHelper.initializeAndLoad(baseURL + htmlURL);
70
71 WebFrame* frame = webViewHelper.webView()->mainFrame();
72 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document();
73 Element* transitionElement = coreDoc->getElementById("foo");
74 ASSERT(transitionElement);
75
76 const ComputedStyle* transitionStyle = transitionElement->computedStyle();
77 ASSERT(transitionStyle);
78
79 HTMLElement* bodyElement = coreDoc->body();
80 ASSERT(bodyElement);
81
82 const ComputedStyle* bodyStyle = bodyElement->computedStyle();
83 ASSERT(bodyStyle);
84 // The transition_exit.css stylesheet should not have been applied at this p oint.
85 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(CSSPropertyColor) );
86
87 frame->document().beginExitTransition("#foo", false);
88
89 // Make sure the stylesheet load request gets processed.
90 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame);
91 coreDoc->updateLayoutTreeIfNeeded();
92
93 // The element should now be hidden.
94 transitionStyle = transitionElement->computedStyle();
95 ASSERT_TRUE(transitionStyle);
96 ASSERT_EQ(transitionStyle->opacity(), 0);
97
98 // The stylesheet should now have been applied.
99 bodyStyle = bodyElement->computedStyle();
100 ASSERT(bodyStyle);
101 ASSERT_EQ(Color(0, 128, 0), bodyStyle->visitedDependentColor(CSSPropertyColo r));
102 }
103
104
105 TEST(WebDocumentTest, BeginExitTransitionToNativeApp)
106 {
107 std::string baseURL = "http://www.test.com:0/";
108 const char* htmlURL = "transition_exit.html";
109 const char* cssURL = "transition_exit.css";
110 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString:: fromUTF8(htmlURL));
111 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f romUTF8(cssURL));
112
113 WebViewHelper webViewHelper;
114 webViewHelper.initializeAndLoad(baseURL + htmlURL);
115
116 WebFrame* frame = webViewHelper.webView()->mainFrame();
117 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document();
118 Element* transitionElement = coreDoc->getElementById("foo");
119 ASSERT(transitionElement);
120
121 const ComputedStyle* transitionStyle = transitionElement->computedStyle();
122 ASSERT(transitionStyle);
123
124 HTMLElement* bodyElement = coreDoc->body();
125 ASSERT(bodyElement);
126
127 const ComputedStyle* bodyStyle = bodyElement->computedStyle();
128 ASSERT(bodyStyle);
129 // The transition_exit.css stylesheet should not have been applied at this p oint.
130 ASSERT_EQ(Color(0, 0, 0), bodyStyle->visitedDependentColor(CSSPropertyColor) );
131
132 frame->document().beginExitTransition("#foo", true);
133
134 // Make sure the stylesheet load request gets processed.
135 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame);
136 coreDoc->updateLayoutTreeIfNeeded();
137
138 // The element should not be hidden.
139 transitionStyle = transitionElement->computedStyle();
140 ASSERT_TRUE(transitionStyle);
141 ASSERT_EQ(transitionStyle->opacity(), 1);
142
143 // The stylesheet should now have been applied.
144 bodyStyle = bodyElement->computedStyle();
145 ASSERT(bodyStyle);
146 ASSERT_EQ(Color(0, 128, 0), bodyStyle->visitedDependentColor(CSSPropertyColo r));
147 }
148
149
150 TEST(WebDocumentTest, HideAndShowTransitionElements)
151 {
152 std::string baseURL = "http://www.test.com:0/";
153 const char* htmlURL = "transition_hide_and_show.html";
154 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString:: fromUTF8(htmlURL));
155
156 WebViewHelper webViewHelper;
157 webViewHelper.initializeAndLoad(baseURL + htmlURL);
158
159 WebFrame* frame = webViewHelper.webView()->mainFrame();
160 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document();
161 Element* transitionElement = coreDoc->getElementById("foo");
162 ASSERT(transitionElement);
163
164 const ComputedStyle* transitionStyle = transitionElement->computedStyle();
165 ASSERT(transitionStyle);
166 EXPECT_EQ(transitionStyle->opacity(), 1);
167
168 // Hide transition elements
169 frame->document().hideTransitionElements("#foo");
170 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame);
171 coreDoc->updateLayoutTreeIfNeeded();
172 transitionStyle = transitionElement->computedStyle();
173 ASSERT_TRUE(transitionStyle);
174 EXPECT_EQ(transitionStyle->opacity(), 0);
175
176 // Show transition elements
177 frame->document().showTransitionElements("#foo");
178 FrameTestHelpers::pumpPendingRequestsDoNotUse(frame);
179 coreDoc->updateLayoutTreeIfNeeded();
180 transitionStyle = transitionElement->computedStyle();
181 ASSERT_TRUE(transitionStyle);
182 EXPECT_EQ(transitionStyle->opacity(), 1);
183 }
184
185
186 TEST(WebDocumentTest, SetIsTransitionDocument)
187 {
188 std::string baseURL = "http://www.test.com:0/";
189 const char* htmlURL = "transition_exit.html";
190 const char* cssURL = "transition_exit.css";
191 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + htmlURL), WebString:: fromUTF8(htmlURL));
192 URLTestHelpers::registerMockedURLLoad(toKURL(baseURL + cssURL), WebString::f romUTF8(cssURL));
193
194 WebViewHelper webViewHelper;
195 webViewHelper.initializeAndLoad(baseURL + htmlURL);
196
197 WebFrame* frame = webViewHelper.webView()->mainFrame();
198 Document* coreDoc = toLocalFrame(webViewHelper.webViewImpl()->page()->mainFr ame())->document();
199
200 ASSERT_FALSE(coreDoc->isTransitionDocument());
201
202 frame->document().setIsTransitionDocument(true);
203 ASSERT_TRUE(coreDoc->isTransitionDocument());
204
205 frame->document().setIsTransitionDocument(false);
206 ASSERT_FALSE(coreDoc->isTransitionDocument());
207 }
208 60
209 namespace { 61 namespace {
210 const char* baseURLOriginA = "http://example.test:0/"; 62 const char* baseURLOriginA = "http://example.test:0/";
211 const char* baseURLOriginSubA = "http://subdomain.example.test:0/"; 63 const char* baseURLOriginSubA = "http://subdomain.example.test:0/";
212 const char* baseURLOriginB = "http://not-example.test:0/"; 64 const char* baseURLOriginB = "http://not-example.test:0/";
213 const char* emptyFile = "first_party/empty.html"; 65 const char* emptyFile = "first_party/empty.html";
214 const char* nestedData = "first_party/nested-data.html"; 66 const char* nestedData = "first_party/nested-data.html";
215 const char* nestedOriginA = "first_party/nested-originA.html"; 67 const char* nestedOriginA = "first_party/nested-originA.html";
216 const char* nestedOriginSubA = "first_party/nested-originSubA.html"; 68 const char* nestedOriginSubA = "first_party/nested-originSubA.html";
217 const char* nestedOriginAInOriginA = "first_party/nested-originA-in-originA. html"; 69 const char* nestedOriginAInOriginA = "first_party/nested-originA-in-originA. html";
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 219
368 TEST_F(WebDocumentFirstPartyTest, NestedData) 220 TEST_F(WebDocumentFirstPartyTest, NestedData)
369 { 221 {
370 load(nestedData); 222 load(nestedData);
371 223
372 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies()); 224 ASSERT_EQ(toOriginA(nestedData), topDocument()->firstPartyForCookies());
373 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f irstPartyForCookies()); 225 ASSERT_EQ(SecurityOrigin::urlWithUniqueSecurityOrigin(), nestedDocument()->f irstPartyForCookies());
374 } 226 }
375 227
376 } 228 }
OLDNEW
« no previous file with comments | « Source/web/WebRuntimeFeatures.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698