OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 void runTestOnTree(WebCore::ContainerNode* root, WebView*, TouchActionTracki
ngWebViewClient&); | 124 void runTestOnTree(WebCore::ContainerNode* root, WebView*, TouchActionTracki
ngWebViewClient&); |
125 | 125 |
126 std::string m_baseURL; | 126 std::string m_baseURL; |
127 FrameTestHelpers::WebViewHelper m_webViewHelper; | 127 FrameTestHelpers::WebViewHelper m_webViewHelper; |
128 }; | 128 }; |
129 | 129 |
130 void TouchActionTest::runTouchActionTest(std::string file) | 130 void TouchActionTest::runTouchActionTest(std::string file) |
131 { | 131 { |
132 TouchActionTrackingWebViewClient client; | 132 TouchActionTrackingWebViewClient client; |
133 | 133 |
| 134 // runTouchActionTest() loads a document in a frame, setting up a |
| 135 // nested message loop. Should any Oilpan GC happen while it is in |
| 136 // effect, the implicit assumption that we're outside any event |
| 137 // loop (=> there being no pointers on the stack needing scanning) |
| 138 // when that GC strikes will no longer hold. |
| 139 // |
| 140 // To ensure that the references on the stack are also traced, we |
| 141 // turn them into persistent, stack allocated references. This |
| 142 // workaround is sufficient to handle this artificial test |
| 143 // scenario. |
134 WebView* webView = setupTest(file, client); | 144 WebView* webView = setupTest(file, client); |
135 | 145 |
136 RefPtrWillBeRawPtr<WebCore::Document> document = static_cast<PassRefPtrWillB
eRawPtr<WebCore::Document> >(webView->mainFrame()->document()); | 146 RefPtrWillBePersistent<WebCore::Document> document = static_cast<PassRefPtrW
illBeRawPtr<WebCore::Document> >(webView->mainFrame()->document()); |
137 runTestOnTree(document.get(), webView, client); | 147 runTestOnTree(document.get(), webView, client); |
138 | 148 |
139 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 149 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
140 } | 150 } |
141 | 151 |
142 void TouchActionTest::runShadowDOMTest(std::string file) | 152 void TouchActionTest::runShadowDOMTest(std::string file) |
143 { | 153 { |
144 TouchActionTrackingWebViewClient client; | 154 TouchActionTrackingWebViewClient client; |
145 | 155 |
146 WebView* webView = setupTest(file, client); | 156 WebView* webView = setupTest(file, client); |
147 | 157 |
148 WebCore::TrackExceptionState es; | 158 WebCore::TrackExceptionState es; |
149 RefPtrWillBeRawPtr<WebCore::Document> document = static_cast<PassRefPtrWillB
eRawPtr<WebCore::Document> >(webView->mainFrame()->document()); | 159 |
150 RefPtr<WebCore::NodeList> hostNodes = document->querySelectorAll("[shadow-ho
st]", es); | 160 // Oilpan: see runTouchActionTest() comment why these are persistent referen
ces. |
| 161 RefPtrWillBePersistent<WebCore::Document> document = static_cast<PassRefPtrW
illBeRawPtr<WebCore::Document> >(webView->mainFrame()->document()); |
| 162 RefPtrWillBePersistent<WebCore::NodeList> hostNodes = document->querySelecto
rAll("[shadow-host]", es); |
151 ASSERT_FALSE(es.hadException()); | 163 ASSERT_FALSE(es.hadException()); |
152 ASSERT_GE(hostNodes->length(), 1u); | 164 ASSERT_GE(hostNodes->length(), 1u); |
153 | 165 |
154 for (unsigned index = 0; index < hostNodes->length(); index++) { | 166 for (unsigned index = 0; index < hostNodes->length(); index++) { |
155 WebCore::ShadowRoot* shadowRoot = WebCore::toElement(hostNodes->item(ind
ex))->shadowRoot(); | 167 WebCore::ShadowRoot* shadowRoot = WebCore::toElement(hostNodes->item(ind
ex))->shadowRoot(); |
156 runTestOnTree(shadowRoot, webView, client); | 168 runTestOnTree(shadowRoot, webView, client); |
157 } | 169 } |
158 | 170 |
159 // Projections show up in the main document. | 171 // Projections show up in the main document. |
160 runTestOnTree(document.get(), webView, client); | 172 runTestOnTree(document.get(), webView, client); |
(...skipping 18 matching lines...) Expand all Loading... |
179 RefPtrWillBeRawPtr<WebCore::Document> document = static_cast<PassRefPtrWillB
eRawPtr<WebCore::Document> >(webView->mainFrame()->document()); | 191 RefPtrWillBeRawPtr<WebCore::Document> document = static_cast<PassRefPtrWillB
eRawPtr<WebCore::Document> >(webView->mainFrame()->document()); |
180 document->frame()->view()->setScrollOffset(WebCore::IntPoint(0, kScrollOffse
t)); | 192 document->frame()->view()->setScrollOffset(WebCore::IntPoint(0, kScrollOffse
t)); |
181 | 193 |
182 return webView; | 194 return webView; |
183 } | 195 } |
184 | 196 |
185 void TouchActionTest::runTestOnTree(WebCore::ContainerNode* root, WebView* webVi
ew, TouchActionTrackingWebViewClient& client) | 197 void TouchActionTest::runTestOnTree(WebCore::ContainerNode* root, WebView* webVi
ew, TouchActionTrackingWebViewClient& client) |
186 { | 198 { |
187 // Find all elements to test the touch-action of in the document. | 199 // Find all elements to test the touch-action of in the document. |
188 WebCore::TrackExceptionState es; | 200 WebCore::TrackExceptionState es; |
189 RefPtr<WebCore::NodeList> nodes = root->querySelectorAll("[expected-action]"
, es); | 201 |
| 202 // Oilpan: see runTouchActionTest() comment why these are persistent referen
ces. |
| 203 RefPtrWillBePersistent<WebCore::NodeList> nodes = root->querySelectorAll("[e
xpected-action]", es); |
190 ASSERT_FALSE(es.hadException()); | 204 ASSERT_FALSE(es.hadException()); |
191 | 205 |
192 for (unsigned index = 0; index < nodes->length(); index++) { | 206 for (unsigned index = 0; index < nodes->length(); index++) { |
193 WebCore::Element* element = toElement(nodes->item(index)); | 207 WebCore::Element* element = toElement(nodes->item(index)); |
194 element->scrollIntoViewIfNeeded(); | 208 element->scrollIntoViewIfNeeded(); |
195 ASSERT_TRUE(nodes->item(index)->isElementNode()); | 209 ASSERT_TRUE(nodes->item(index)->isElementNode()); |
196 | 210 |
197 std::string failureContext("Test case: "); | 211 std::string failureContext("Test case: "); |
198 if (element->hasID()) { | 212 if (element->hasID()) { |
199 failureContext.append(element->getIdAttribute().ascii().data()); | 213 failureContext.append(element->getIdAttribute().ascii().data()); |
200 } else if (element->firstChild()) { | 214 } else if (element->firstChild()) { |
201 failureContext.append("\""); | 215 failureContext.append("\""); |
202 failureContext.append(element->firstChild()->textContent(false).stri
pWhiteSpace().ascii().data()); | 216 failureContext.append(element->firstChild()->textContent(false).stri
pWhiteSpace().ascii().data()); |
203 failureContext.append("\""); | 217 failureContext.append("\""); |
204 } else { | 218 } else { |
205 failureContext += "<missing ID>"; | 219 failureContext += "<missing ID>"; |
206 } | 220 } |
207 | 221 |
208 // Run each test three times at different positions in the element. | 222 // Run each test three times at different positions in the element. |
209 // Note that we don't want the bounding box because our tests sometimes
have elements with | 223 // Note that we don't want the bounding box because our tests sometimes
have elements with |
210 // multiple border boxes with other elements in between. Use the first b
order box (which | 224 // multiple border boxes with other elements in between. Use the first b
order box (which |
211 // we can easily visualize in a browser for debugging). | 225 // we can easily visualize in a browser for debugging). |
212 RefPtrWillBeRawPtr<WebCore::ClientRectList> rects = element->getClientRe
cts(); | 226 RefPtrWillBePersistent<WebCore::ClientRectList> rects = element->getClie
ntRects(); |
213 ASSERT_GE(rects->length(), 0u) << failureContext; | 227 ASSERT_GE(rects->length(), 0u) << failureContext; |
214 RefPtrWillBeRawPtr<WebCore::ClientRect> r = rects->item(0); | 228 RefPtrWillBePersistent<WebCore::ClientRect> r = rects->item(0); |
215 WebCore::FloatRect clientFloatRect = WebCore::FloatRect(r->left(), r->to
p(), r->width(), r->height()); | 229 WebCore::FloatRect clientFloatRect = WebCore::FloatRect(r->left(), r->to
p(), r->width(), r->height()); |
216 WebCore::IntRect clientRect = enclosedIntRect(clientFloatRect); | 230 WebCore::IntRect clientRect = enclosedIntRect(clientFloatRect); |
217 for (int locIdx = 0; locIdx < 3; locIdx++) { | 231 for (int locIdx = 0; locIdx < 3; locIdx++) { |
218 WebCore::IntPoint clientPoint; | 232 WebCore::IntPoint clientPoint; |
219 std::stringstream contextStream; | 233 std::stringstream contextStream; |
220 contextStream << failureContext << " ("; | 234 contextStream << failureContext << " ("; |
221 switch (locIdx) { | 235 switch (locIdx) { |
222 case 0: | 236 case 0: |
223 clientPoint = clientRect.center(); | 237 clientPoint = clientRect.center(); |
224 contextStream << "center"; | 238 contextStream << "center"; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 { | 343 { |
330 runShadowDOMTest("touch-action-shadow-dom.html"); | 344 runShadowDOMTest("touch-action-shadow-dom.html"); |
331 } | 345 } |
332 | 346 |
333 TEST_F(TouchActionTest, Pan) | 347 TEST_F(TouchActionTest, Pan) |
334 { | 348 { |
335 runTouchActionTest("touch-action-pan.html"); | 349 runTouchActionTest("touch-action-pan.html"); |
336 } | 350 } |
337 | 351 |
338 } | 352 } |
OLD | NEW |