| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // effect, the implicit assumption that we're outside any event | 138 // effect, the implicit assumption that we're outside any event |
| 139 // loop (=> there being no pointers on the stack needing scanning) | 139 // loop (=> there being no pointers on the stack needing scanning) |
| 140 // when that GC strikes will no longer hold. | 140 // when that GC strikes will no longer hold. |
| 141 // | 141 // |
| 142 // To ensure that the references on the stack are also traced, we | 142 // To ensure that the references on the stack are also traced, we |
| 143 // turn them into persistent, stack allocated references. This | 143 // turn them into persistent, stack allocated references. This |
| 144 // workaround is sufficient to handle this artificial test | 144 // workaround is sufficient to handle this artificial test |
| 145 // scenario. | 145 // scenario. |
| 146 WebView* webView = setupTest(file, client); | 146 WebView* webView = setupTest(file, client); |
| 147 | 147 |
| 148 Persistent<Document> document = static_cast<RawPtr<Document>>(webView->mainF
rame()->document()); | 148 Persistent<Document> document = static_cast<Document*>(webView->mainFrame()-
>document()); |
| 149 runTestOnTree(document.get(), webView, client); | 149 runTestOnTree(document.get(), webView, client); |
| 150 | 150 |
| 151 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 151 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
| 152 } | 152 } |
| 153 | 153 |
| 154 void TouchActionTest::runShadowDOMTest(std::string file) | 154 void TouchActionTest::runShadowDOMTest(std::string file) |
| 155 { | 155 { |
| 156 TouchActionTrackingWebViewClient client; | 156 TouchActionTrackingWebViewClient client; |
| 157 | 157 |
| 158 WebView* webView = setupTest(file, client); | 158 WebView* webView = setupTest(file, client); |
| 159 | 159 |
| 160 TrackExceptionState es; | 160 TrackExceptionState es; |
| 161 | 161 |
| 162 // Oilpan: see runTouchActionTest() comment why these are persistent referen
ces. | 162 // Oilpan: see runTouchActionTest() comment why these are persistent referen
ces. |
| 163 Persistent<Document> document = static_cast<RawPtr<Document>>(webView->mainF
rame()->document()); | 163 Persistent<Document> document = static_cast<Document*>(webView->mainFrame()-
>document()); |
| 164 Persistent<StaticElementList> hostNodes = document->querySelectorAll("[shado
w-host]", es); | 164 Persistent<StaticElementList> hostNodes = document->querySelectorAll("[shado
w-host]", es); |
| 165 ASSERT_FALSE(es.hadException()); | 165 ASSERT_FALSE(es.hadException()); |
| 166 ASSERT_GE(hostNodes->length(), 1u); | 166 ASSERT_GE(hostNodes->length(), 1u); |
| 167 | 167 |
| 168 for (unsigned index = 0; index < hostNodes->length(); index++) { | 168 for (unsigned index = 0; index < hostNodes->length(); index++) { |
| 169 ShadowRoot* shadowRoot = hostNodes->item(index)->openShadowRoot(); | 169 ShadowRoot* shadowRoot = hostNodes->item(index)->openShadowRoot(); |
| 170 runTestOnTree(shadowRoot, webView, client); | 170 runTestOnTree(shadowRoot, webView, client); |
| 171 } | 171 } |
| 172 | 172 |
| 173 // Projections show up in the main document. | 173 // Projections show up in the main document. |
| 174 runTestOnTree(document.get(), webView, client); | 174 runTestOnTree(document.get(), webView, client); |
| 175 | 175 |
| 176 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 176 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
| 177 } | 177 } |
| 178 | 178 |
| 179 void TouchActionTest::runIFrameTest(std::string file) | 179 void TouchActionTest::runIFrameTest(std::string file) |
| 180 { | 180 { |
| 181 TouchActionTrackingWebViewClient client; | 181 TouchActionTrackingWebViewClient client; |
| 182 | 182 |
| 183 WebView* webView = setupTest(file, client); | 183 WebView* webView = setupTest(file, client); |
| 184 WebFrame* curFrame = webView->mainFrame()->firstChild(); | 184 WebFrame* curFrame = webView->mainFrame()->firstChild(); |
| 185 ASSERT_TRUE(curFrame); | 185 ASSERT_TRUE(curFrame); |
| 186 | 186 |
| 187 for (; curFrame; curFrame = curFrame->nextSibling()) { | 187 for (; curFrame; curFrame = curFrame->nextSibling()) { |
| 188 // Oilpan: see runTouchActionTest() comment why these are persistent ref
erences. | 188 // Oilpan: see runTouchActionTest() comment why these are persistent ref
erences. |
| 189 Persistent<Document> contentDoc = static_cast<RawPtr<Document>>(curFrame
->document()); | 189 Persistent<Document> contentDoc = static_cast<Document*>(curFrame->docum
ent()); |
| 190 runTestOnTree(contentDoc.get(), webView, client); | 190 runTestOnTree(contentDoc.get(), webView, client); |
| 191 } | 191 } |
| 192 | 192 |
| 193 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. | 193 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally
scoped client. |
| 194 } | 194 } |
| 195 | 195 |
| 196 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView
Client& client) | 196 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView
Client& client) |
| 197 { | 197 { |
| 198 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file)); | 198 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL),
WebString::fromUTF8(file)); |
| 199 // Note that JavaScript must be enabled for shadow DOM tests. | 199 // Note that JavaScript must be enabled for shadow DOM tests. |
| 200 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true,
0, &client); | 200 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true,
0, &client); |
| 201 | 201 |
| 202 // Set size to enable hit testing, and avoid line wrapping for consistency w
ith browser. | 202 // Set size to enable hit testing, and avoid line wrapping for consistency w
ith browser. |
| 203 webView->resize(WebSize(800, 1200)); | 203 webView->resize(WebSize(800, 1200)); |
| 204 | 204 |
| 205 // Scroll to verify the code properly transforms windows to client co-ords. | 205 // Scroll to verify the code properly transforms windows to client co-ords. |
| 206 const int kScrollOffset = 100; | 206 const int kScrollOffset = 100; |
| 207 RawPtr<Document> document = static_cast<RawPtr<Document>>(webView->mainFrame
()->document()); | 207 Document* document = static_cast<Document*>(webView->mainFrame()->document()
); |
| 208 document->frame()->view()->setScrollPosition(IntPoint(0, kScrollOffset), Pro
grammaticScroll); | 208 document->frame()->view()->setScrollPosition(IntPoint(0, kScrollOffset), Pro
grammaticScroll); |
| 209 | 209 |
| 210 return webView; | 210 return webView; |
| 211 } | 211 } |
| 212 | 212 |
| 213 void TouchActionTest::runTestOnTree(ContainerNode* root, WebView* webView, Touch
ActionTrackingWebViewClient& client) | 213 void TouchActionTest::runTestOnTree(ContainerNode* root, WebView* webView, Touch
ActionTrackingWebViewClient& client) |
| 214 { | 214 { |
| 215 // Find all elements to test the touch-action of in the document. | 215 // Find all elements to test the touch-action of in the document. |
| 216 TrackExceptionState es; | 216 TrackExceptionState es; |
| 217 | 217 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 { | 367 { |
| 368 runShadowDOMTest("touch-action-shadow-dom.html"); | 368 runShadowDOMTest("touch-action-shadow-dom.html"); |
| 369 } | 369 } |
| 370 | 370 |
| 371 TEST_F(TouchActionTest, Pan) | 371 TEST_F(TouchActionTest, Pan) |
| 372 { | 372 { |
| 373 runTouchActionTest("touch-action-pan.html"); | 373 runTouchActionTest("touch-action-pan.html"); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace blink | 376 } // namespace blink |
| OLD | NEW |