| 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 20 matching lines...) Expand all Loading... |
| 31 #include "core/dom/ClientRect.h" | 31 #include "core/dom/ClientRect.h" |
| 32 #include "core/dom/ClientRectList.h" | 32 #include "core/dom/ClientRectList.h" |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
| 35 #include "core/dom/StaticNodeList.h" | 35 #include "core/dom/StaticNodeList.h" |
| 36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
| 37 #include "core/exported/WebViewBase.h" | 37 #include "core/exported/WebViewBase.h" |
| 38 #include "core/frame/FrameTestHelpers.h" | 38 #include "core/frame/FrameTestHelpers.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/frame/LocalFrameView.h" | 40 #include "core/frame/LocalFrameView.h" |
| 41 #include "core/frame/WebLocalFrameBase.h" |
| 41 #include "core/html/HTMLIFrameElement.h" | 42 #include "core/html/HTMLIFrameElement.h" |
| 42 #include "core/input/EventHandler.h" | 43 #include "core/input/EventHandler.h" |
| 43 #include "core/layout/HitTestResult.h" | 44 #include "core/layout/HitTestResult.h" |
| 44 #include "core/layout/LayoutTreeAsText.h" | 45 #include "core/layout/LayoutTreeAsText.h" |
| 45 #include "core/layout/api/LayoutViewItem.h" | 46 #include "core/layout/api/LayoutViewItem.h" |
| 46 #include "platform/graphics/TouchAction.h" | 47 #include "platform/graphics/TouchAction.h" |
| 47 #include "platform/testing/URLTestHelpers.h" | 48 #include "platform/testing/URLTestHelpers.h" |
| 48 #include "platform/testing/UnitTestHelpers.h" | 49 #include "platform/testing/UnitTestHelpers.h" |
| 49 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
| 50 #include "public/platform/WebCoalescedInputEvent.h" | 51 #include "public/platform/WebCoalescedInputEvent.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 Platform::Current() | 110 Platform::Current() |
| 110 ->GetURLLoaderMockFactory() | 111 ->GetURLLoaderMockFactory() |
| 111 ->UnregisterAllURLsAndClearMemoryCache(); | 112 ->UnregisterAllURLsAndClearMemoryCache(); |
| 112 } | 113 } |
| 113 | 114 |
| 114 protected: | 115 protected: |
| 115 void RunTouchActionTest(std::string file); | 116 void RunTouchActionTest(std::string file); |
| 116 void RunShadowDOMTest(std::string file); | 117 void RunShadowDOMTest(std::string file); |
| 117 void RunIFrameTest(std::string file); | 118 void RunIFrameTest(std::string file); |
| 118 void SendTouchEvent(WebView*, WebInputEvent::Type, IntPoint client_point); | 119 void SendTouchEvent(WebView*, WebInputEvent::Type, IntPoint client_point); |
| 119 WebView* SetupTest(std::string file, TouchActionTrackingWebWidgetClient&); | 120 WebViewBase* SetupTest(std::string file, TouchActionTrackingWebWidgetClient&); |
| 120 void RunTestOnTree(ContainerNode* root, | 121 void RunTestOnTree(ContainerNode* root, |
| 121 WebView*, | 122 WebView*, |
| 122 TouchActionTrackingWebWidgetClient&); | 123 TouchActionTrackingWebWidgetClient&); |
| 123 | 124 |
| 124 std::string base_url_; | 125 std::string base_url_; |
| 125 FrameTestHelpers::WebViewHelper web_view_helper_; | 126 FrameTestHelpers::WebViewHelper web_view_helper_; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 void TouchActionTest::RunTouchActionTest(std::string file) { | 129 void TouchActionTest::RunTouchActionTest(std::string file) { |
| 129 TouchActionTrackingWebWidgetClient client; | 130 TouchActionTrackingWebWidgetClient client; |
| 130 | 131 |
| 131 // runTouchActionTest() loads a document in a frame, setting up a | 132 // runTouchActionTest() loads a document in a frame, setting up a |
| 132 // nested run loop. Should any Oilpan GC happen while it is in | 133 // nested run loop. Should any Oilpan GC happen while it is in |
| 133 // effect, the implicit assumption that we're outside any event | 134 // effect, the implicit assumption that we're outside any event |
| 134 // loop (=> there being no pointers on the stack needing scanning) | 135 // loop (=> there being no pointers on the stack needing scanning) |
| 135 // when that GC strikes will no longer hold. | 136 // when that GC strikes will no longer hold. |
| 136 // | 137 // |
| 137 // To ensure that the references on the stack are also traced, we | 138 // To ensure that the references on the stack are also traced, we |
| 138 // turn them into persistent, stack allocated references. This | 139 // turn them into persistent, stack allocated references. This |
| 139 // workaround is sufficient to handle this artificial test | 140 // workaround is sufficient to handle this artificial test |
| 140 // scenario. | 141 // scenario. |
| 141 WebView* web_view = SetupTest(file, client); | 142 WebViewBase* web_view = SetupTest(file, client); |
| 142 | 143 |
| 143 Persistent<Document> document = | 144 Persistent<Document> document = |
| 144 static_cast<Document*>(web_view->MainFrame()->GetDocument()); | 145 static_cast<Document*>(web_view->MainFrameImpl()->GetDocument()); |
| 145 RunTestOnTree(document.Get(), web_view, client); | 146 RunTestOnTree(document.Get(), web_view, client); |
| 146 | 147 |
| 147 // Explicitly reset to break dependency on locally scoped client. | 148 // Explicitly reset to break dependency on locally scoped client. |
| 148 web_view_helper_.Reset(); | 149 web_view_helper_.Reset(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void TouchActionTest::RunShadowDOMTest(std::string file) { | 152 void TouchActionTest::RunShadowDOMTest(std::string file) { |
| 152 TouchActionTrackingWebWidgetClient client; | 153 TouchActionTrackingWebWidgetClient client; |
| 153 | 154 |
| 154 WebView* web_view = SetupTest(file, client); | 155 WebViewBase* web_view = SetupTest(file, client); |
| 155 | 156 |
| 156 DummyExceptionStateForTesting es; | 157 DummyExceptionStateForTesting es; |
| 157 | 158 |
| 158 // Oilpan: see runTouchActionTest() comment why these are persistent | 159 // Oilpan: see runTouchActionTest() comment why these are persistent |
| 159 // references. | 160 // references. |
| 160 Persistent<Document> document = | 161 Persistent<Document> document = |
| 161 static_cast<Document*>(web_view->MainFrame()->GetDocument()); | 162 static_cast<Document*>(web_view->MainFrameImpl()->GetDocument()); |
| 162 Persistent<StaticElementList> host_nodes = | 163 Persistent<StaticElementList> host_nodes = |
| 163 document->QuerySelectorAll("[shadow-host]", es); | 164 document->QuerySelectorAll("[shadow-host]", es); |
| 164 ASSERT_FALSE(es.HadException()); | 165 ASSERT_FALSE(es.HadException()); |
| 165 ASSERT_GE(host_nodes->length(), 1u); | 166 ASSERT_GE(host_nodes->length(), 1u); |
| 166 | 167 |
| 167 for (unsigned index = 0; index < host_nodes->length(); index++) { | 168 for (unsigned index = 0; index < host_nodes->length(); index++) { |
| 168 ShadowRoot* shadow_root = host_nodes->item(index)->openShadowRoot(); | 169 ShadowRoot* shadow_root = host_nodes->item(index)->openShadowRoot(); |
| 169 RunTestOnTree(shadow_root, web_view, client); | 170 RunTestOnTree(shadow_root, web_view, client); |
| 170 } | 171 } |
| 171 | 172 |
| 172 // Projections show up in the main document. | 173 // Projections show up in the main document. |
| 173 RunTestOnTree(document.Get(), web_view, client); | 174 RunTestOnTree(document.Get(), web_view, client); |
| 174 | 175 |
| 175 // Explicitly reset to break dependency on locally scoped client. | 176 // Explicitly reset to break dependency on locally scoped client. |
| 176 web_view_helper_.Reset(); | 177 web_view_helper_.Reset(); |
| 177 } | 178 } |
| 178 | 179 |
| 179 void TouchActionTest::RunIFrameTest(std::string file) { | 180 void TouchActionTest::RunIFrameTest(std::string file) { |
| 180 TouchActionTrackingWebWidgetClient client; | 181 TouchActionTrackingWebWidgetClient client; |
| 181 | 182 |
| 182 WebView* web_view = SetupTest(file, client); | 183 WebViewBase* web_view = SetupTest(file, client); |
| 183 WebFrame* cur_frame = web_view->MainFrame()->FirstChild(); | 184 WebFrame* cur_frame = web_view->MainFrame()->FirstChild(); |
| 184 ASSERT_TRUE(cur_frame); | 185 ASSERT_TRUE(cur_frame); |
| 185 | 186 |
| 186 for (; cur_frame; cur_frame = cur_frame->NextSibling()) { | 187 for (; cur_frame; cur_frame = cur_frame->NextSibling()) { |
| 187 // Oilpan: see runTouchActionTest() comment why these are persistent | 188 // Oilpan: see runTouchActionTest() comment why these are persistent |
| 188 // references. | 189 // references. |
| 189 Persistent<Document> content_doc = | 190 Persistent<Document> content_doc = |
| 190 static_cast<Document*>(cur_frame->GetDocument()); | 191 static_cast<Document*>(cur_frame->ToWebLocalFrame()->GetDocument()); |
| 191 RunTestOnTree(content_doc.Get(), web_view, client); | 192 RunTestOnTree(content_doc.Get(), web_view, client); |
| 192 } | 193 } |
| 193 | 194 |
| 194 // Explicitly reset to break dependency on locally scoped client. | 195 // Explicitly reset to break dependency on locally scoped client. |
| 195 web_view_helper_.Reset(); | 196 web_view_helper_.Reset(); |
| 196 } | 197 } |
| 197 | 198 |
| 198 WebView* TouchActionTest::SetupTest( | 199 WebViewBase* TouchActionTest::SetupTest( |
| 199 std::string file, | 200 std::string file, |
| 200 TouchActionTrackingWebWidgetClient& client) { | 201 TouchActionTrackingWebWidgetClient& client) { |
| 201 URLTestHelpers::RegisterMockedURLLoadFromBase(WebString::FromUTF8(base_url_), | 202 URLTestHelpers::RegisterMockedURLLoadFromBase(WebString::FromUTF8(base_url_), |
| 202 testing::WebTestDataPath(), | 203 testing::WebTestDataPath(), |
| 203 WebString::FromUTF8(file)); | 204 WebString::FromUTF8(file)); |
| 204 // Note that JavaScript must be enabled for shadow DOM tests. | 205 // Note that JavaScript must be enabled for shadow DOM tests. |
| 205 WebView* web_view = web_view_helper_.InitializeAndLoad( | 206 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
| 206 base_url_ + file, nullptr, nullptr, &client); | 207 base_url_ + file, nullptr, nullptr, &client); |
| 207 | 208 |
| 208 // Set size to enable hit testing, and avoid line wrapping for consistency | 209 // Set size to enable hit testing, and avoid line wrapping for consistency |
| 209 // with browser. | 210 // with browser. |
| 210 web_view->Resize(WebSize(800, 1200)); | 211 web_view->Resize(WebSize(800, 1200)); |
| 211 | 212 |
| 212 // Scroll to verify the code properly transforms windows to client co-ords. | 213 // Scroll to verify the code properly transforms windows to client co-ords. |
| 213 const int kScrollOffset = 100; | 214 const int kScrollOffset = 100; |
| 214 Document* document = | 215 Document* document = |
| 215 static_cast<Document*>(web_view->MainFrame()->GetDocument()); | 216 static_cast<Document*>(web_view->MainFrameImpl()->GetDocument()); |
| 216 document->GetFrame()->View()->LayoutViewportScrollableArea()->SetScrollOffset( | 217 document->GetFrame()->View()->LayoutViewportScrollableArea()->SetScrollOffset( |
| 217 ScrollOffset(0, kScrollOffset), kProgrammaticScroll); | 218 ScrollOffset(0, kScrollOffset), kProgrammaticScroll); |
| 218 | 219 |
| 219 return web_view; | 220 return web_view; |
| 220 } | 221 } |
| 221 | 222 |
| 222 IntRect WindowClipRect(const LocalFrameView& frame_view) { | 223 IntRect WindowClipRect(const LocalFrameView& frame_view) { |
| 223 LayoutRect clip_rect( | 224 LayoutRect clip_rect( |
| 224 LayoutPoint(), | 225 LayoutPoint(), |
| 225 LayoutSize(frame_view.VisibleContentSize(kExcludeScrollbars))); | 226 LayoutSize(frame_view.VisibleContentSize(kExcludeScrollbars))); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 419 |
| 419 TEST_F(TouchActionTest, ShadowDOM) { | 420 TEST_F(TouchActionTest, ShadowDOM) { |
| 420 RunShadowDOMTest("touch-action-shadow-dom.html"); | 421 RunShadowDOMTest("touch-action-shadow-dom.html"); |
| 421 } | 422 } |
| 422 | 423 |
| 423 TEST_F(TouchActionTest, Pan) { | 424 TEST_F(TouchActionTest, Pan) { |
| 424 RunTouchActionTest("touch-action-pan.html"); | 425 RunTouchActionTest("touch-action-pan.html"); |
| 425 } | 426 } |
| 426 | 427 |
| 427 } // namespace blink | 428 } // namespace blink |
| OLD | NEW |