| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2  * Copyright (C) 2011, 2012 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 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1333   EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().height); | 1333   EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().height); | 
| 1334 | 1334 | 
| 1335   // Set up a composition from existing text that needs to be committed. | 1335   // Set up a composition from existing text that needs to be committed. | 
| 1336   Vector<CompositionUnderline> empty_underlines; | 1336   Vector<CompositionUnderline> empty_underlines; | 
| 1337   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 1337   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 
| 1338   frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( | 1338   frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( | 
| 1339       empty_underlines, 0, 3); | 1339       empty_underlines, 0, 3); | 
| 1340 | 1340 | 
| 1341   // Scroll the input field out of the viewport. | 1341   // Scroll the input field out of the viewport. | 
| 1342   Element* element = static_cast<Element*>( | 1342   Element* element = static_cast<Element*>( | 
| 1343       web_view->MainFrame()->GetDocument().GetElementById("btn")); | 1343       web_view->MainFrameImpl()->GetDocument().GetElementById("btn")); | 
| 1344   element->scrollIntoView(); | 1344   element->scrollIntoView(); | 
| 1345   float offset_height = web_view->MainFrameImpl()->GetScrollOffset().height; | 1345   float offset_height = web_view->MainFrameImpl()->GetScrollOffset().height; | 
| 1346   EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); | 1346   EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); | 
| 1347   EXPECT_LT(0, offset_height); | 1347   EXPECT_LT(0, offset_height); | 
| 1348 | 1348 | 
| 1349   WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); | 1349   WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); | 
| 1350   EXPECT_EQ("hello", std::string(info.value.Utf8().data())); | 1350   EXPECT_EQ("hello", std::string(info.value.Utf8().data())); | 
| 1351 | 1351 | 
| 1352   // Verify that the input field is not scrolled back into the viewport. | 1352   // Verify that the input field is not scrolled back into the viewport. | 
| 1353   frame->FrameWidget() | 1353   frame->FrameWidget() | 
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1533 | 1533 | 
| 1534 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { | 1534 TEST_P(WebViewTest, SetCompositionFromExistingTextInRichText) { | 
| 1535   RegisterMockedHttpURLLoad("content_editable_rich_text.html"); | 1535   RegisterMockedHttpURLLoad("content_editable_rich_text.html"); | 
| 1536   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 1536   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 1537       base_url_ + "content_editable_rich_text.html"); | 1537       base_url_ + "content_editable_rich_text.html"); | 
| 1538   web_view->SetInitialFocus(false); | 1538   web_view->SetInitialFocus(false); | 
| 1539   WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 1539   WebVector<WebCompositionUnderline> underlines(static_cast<size_t>(1)); | 
| 1540   underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 1540   underlines[0] = WebCompositionUnderline(0, 4, 0, false, 0); | 
| 1541   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 1541   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 
| 1542   frame->SetEditableSelectionOffsets(1, 1); | 1542   frame->SetEditableSelectionOffsets(1, 1); | 
| 1543   WebDocument document = web_view->MainFrame()->GetDocument(); | 1543   WebDocument document = web_view->MainFrameImpl()->GetDocument(); | 
| 1544   EXPECT_FALSE(document.GetElementById("bold").IsNull()); | 1544   EXPECT_FALSE(document.GetElementById("bold").IsNull()); | 
| 1545   frame->SetCompositionFromExistingText(0, 4, underlines); | 1545   frame->SetCompositionFromExistingText(0, 4, underlines); | 
| 1546   EXPECT_FALSE(document.GetElementById("bold").IsNull()); | 1546   EXPECT_FALSE(document.GetElementById("bold").IsNull()); | 
| 1547 } | 1547 } | 
| 1548 | 1548 | 
| 1549 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { | 1549 TEST_P(WebViewTest, SetEditableSelectionOffsetsKeepsComposition) { | 
| 1550   RegisterMockedHttpURLLoad("input_field_populated.html"); | 1550   RegisterMockedHttpURLLoad("input_field_populated.html"); | 
| 1551   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 1551   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 1552       base_url_ + "input_field_populated.html"); | 1552       base_url_ + "input_field_populated.html"); | 
| 1553   web_view->SetInitialFocus(false); | 1553   web_view->SetInitialFocus(false); | 
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1954   const std::string foo_url = base_url_ + "foo.html"; | 1954   const std::string foo_url = base_url_ + "foo.html"; | 
| 1955   const std::string bar_url = base_url_ + "bar.html"; | 1955   const std::string bar_url = base_url_ + "bar.html"; | 
| 1956 | 1956 | 
| 1957   WebViewBase* web_view = web_view_helper_.InitializeAndLoad(foo_url); | 1957   WebViewBase* web_view = web_view_helper_.InitializeAndLoad(foo_url); | 
| 1958 | 1958 | 
| 1959   ASSERT_TRUE(web_view); | 1959   ASSERT_TRUE(web_view); | 
| 1960 | 1960 | 
| 1961   // Drag and drop barUrl and verify that we've navigated to it. | 1961   // Drag and drop barUrl and verify that we've navigated to it. | 
| 1962   DragAndDropURL(web_view, bar_url); | 1962   DragAndDropURL(web_view, bar_url); | 
| 1963   EXPECT_EQ(bar_url, | 1963   EXPECT_EQ(bar_url, | 
| 1964             web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); | 1964             web_view->MainFrameImpl()->GetDocument().Url().GetString().Utf8()); | 
| 1965 | 1965 | 
| 1966   // Drag and drop fooUrl and verify that we've navigated back to it. | 1966   // Drag and drop fooUrl and verify that we've navigated back to it. | 
| 1967   DragAndDropURL(web_view, foo_url); | 1967   DragAndDropURL(web_view, foo_url); | 
| 1968   EXPECT_EQ(foo_url, | 1968   EXPECT_EQ(foo_url, | 
| 1969             web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); | 1969             web_view->MainFrameImpl()->GetDocument().Url().GetString().Utf8()); | 
| 1970 | 1970 | 
| 1971   // Disable navigation on drag-and-drop. | 1971   // Disable navigation on drag-and-drop. | 
| 1972   web_view->SettingsImpl()->SetNavigateOnDragDrop(false); | 1972   web_view->SettingsImpl()->SetNavigateOnDragDrop(false); | 
| 1973 | 1973 | 
| 1974   // Attempt to drag and drop to barUrl and verify that no navigation has | 1974   // Attempt to drag and drop to barUrl and verify that no navigation has | 
| 1975   // occurred. | 1975   // occurred. | 
| 1976   DragAndDropURL(web_view, bar_url); | 1976   DragAndDropURL(web_view, bar_url); | 
| 1977   EXPECT_EQ(foo_url, | 1977   EXPECT_EQ(foo_url, | 
| 1978             web_view->MainFrame()->GetDocument().Url().GetString().Utf8()); | 1978             web_view->MainFrameImpl()->GetDocument().Url().GetString().Utf8()); | 
| 1979 } | 1979 } | 
| 1980 | 1980 | 
| 1981 bool WebViewTest::TapElement(WebInputEvent::Type type, Element* element) { | 1981 bool WebViewTest::TapElement(WebInputEvent::Type type, Element* element) { | 
| 1982   if (!element || !element->GetLayoutObject()) | 1982   if (!element || !element->GetLayoutObject()) | 
| 1983     return false; | 1983     return false; | 
| 1984 | 1984 | 
| 1985   DCHECK(web_view_helper_.WebView()); | 1985   DCHECK(web_view_helper_.WebView()); | 
| 1986   element->scrollIntoViewIfNeeded(); | 1986   element->scrollIntoViewIfNeeded(); | 
| 1987 | 1987 | 
| 1988   // TODO(bokan): Technically incorrect, event positions should be in viewport | 1988   // TODO(bokan): Technically incorrect, event positions should be in viewport | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 2004 | 2004 | 
| 2005   web_view_helper_.WebView()->HandleInputEvent(WebCoalescedInputEvent(event)); | 2005   web_view_helper_.WebView()->HandleInputEvent(WebCoalescedInputEvent(event)); | 
| 2006   RunPendingTasks(); | 2006   RunPendingTasks(); | 
| 2007   return true; | 2007   return true; | 
| 2008 } | 2008 } | 
| 2009 | 2009 | 
| 2010 bool WebViewTest::TapElementById(WebInputEvent::Type type, | 2010 bool WebViewTest::TapElementById(WebInputEvent::Type type, | 
| 2011                                  const WebString& id) { | 2011                                  const WebString& id) { | 
| 2012   DCHECK(web_view_helper_.WebView()); | 2012   DCHECK(web_view_helper_.WebView()); | 
| 2013   Element* element = static_cast<Element*>( | 2013   Element* element = static_cast<Element*>( | 
| 2014       web_view_helper_.WebView()->MainFrame()->GetDocument().GetElementById( | 2014       web_view_helper_.WebView()->MainFrameImpl()->GetDocument().GetElementById( | 
| 2015           id)); | 2015           id)); | 
| 2016   return TapElement(type, element); | 2016   return TapElement(type, element); | 
| 2017 } | 2017 } | 
| 2018 | 2018 | 
| 2019 IntSize WebViewTest::PrintICBSizeFromPageSize(const FloatSize& page_size) { | 2019 IntSize WebViewTest::PrintICBSizeFromPageSize(const FloatSize& page_size) { | 
| 2020   // The expected layout size comes from the calculation done in | 2020   // The expected layout size comes from the calculation done in | 
| 2021   // ResizePageRectsKeepingRatio() which is used from PrintContext::begin() to | 2021   // ResizePageRectsKeepingRatio() which is used from PrintContext::begin() to | 
| 2022   // scale the page size. | 2022   // scale the page size. | 
| 2023   const float ratio = page_size.Height() / (float)page_size.Width(); | 2023   const float ratio = page_size.Height() / (float)page_size.Width(); | 
| 2024   const int icb_width = | 2024   const int icb_width = | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2131   WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2131   WebGestureEvent event(WebInputEvent::kGestureLongPress, | 
| 2132                         WebInputEvent::kNoModifiers, | 2132                         WebInputEvent::kNoModifiers, | 
| 2133                         WebInputEvent::kTimeStampForTesting); | 2133                         WebInputEvent::kTimeStampForTesting); | 
| 2134   event.source_device = kWebGestureDeviceTouchscreen; | 2134   event.source_device = kWebGestureDeviceTouchscreen; | 
| 2135   event.x = 10; | 2135   event.x = 10; | 
| 2136   event.y = 10; | 2136   event.y = 10; | 
| 2137 | 2137 | 
| 2138   EXPECT_NE(WebInputEventResult::kHandledSystem, | 2138   EXPECT_NE(WebInputEventResult::kHandledSystem, | 
| 2139             web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2139             web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 
| 2140 | 2140 | 
| 2141   HTMLElement* element = | 2141   HTMLElement* element = ToHTMLElement( | 
| 2142       ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); | 2142       web_view->MainFrameImpl()->GetDocument().GetElementById("obj")); | 
| 2143   EXPECT_FALSE(element->CanStartSelection()); | 2143   EXPECT_FALSE(element->CanStartSelection()); | 
| 2144 } | 2144 } | 
| 2145 | 2145 | 
| 2146 TEST_P(WebViewTest, LongPressObjectFallback) { | 2146 TEST_P(WebViewTest, LongPressObjectFallback) { | 
| 2147   RegisterMockedHttpURLLoad("long_press_object_fallback.html"); | 2147   RegisterMockedHttpURLLoad("long_press_object_fallback.html"); | 
| 2148 | 2148 | 
| 2149   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 2149   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 2150       base_url_ + "long_press_object_fallback.html"); | 2150       base_url_ + "long_press_object_fallback.html"); | 
| 2151   web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); | 2151   web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(true); | 
| 2152   web_view->Resize(WebSize(500, 300)); | 2152   web_view->Resize(WebSize(500, 300)); | 
| 2153   web_view->UpdateAllLifecyclePhases(); | 2153   web_view->UpdateAllLifecyclePhases(); | 
| 2154   RunPendingTasks(); | 2154   RunPendingTasks(); | 
| 2155 | 2155 | 
| 2156   WebGestureEvent event(WebInputEvent::kGestureLongPress, | 2156   WebGestureEvent event(WebInputEvent::kGestureLongPress, | 
| 2157                         WebInputEvent::kNoModifiers, | 2157                         WebInputEvent::kNoModifiers, | 
| 2158                         WebInputEvent::kTimeStampForTesting); | 2158                         WebInputEvent::kTimeStampForTesting); | 
| 2159   event.source_device = kWebGestureDeviceTouchscreen; | 2159   event.source_device = kWebGestureDeviceTouchscreen; | 
| 2160   event.x = 10; | 2160   event.x = 10; | 
| 2161   event.y = 10; | 2161   event.y = 10; | 
| 2162 | 2162 | 
| 2163   EXPECT_EQ(WebInputEventResult::kHandledSystem, | 2163   EXPECT_EQ(WebInputEventResult::kHandledSystem, | 
| 2164             web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 2164             web_view->HandleInputEvent(WebCoalescedInputEvent(event))); | 
| 2165 | 2165 | 
| 2166   HTMLElement* element = | 2166   HTMLElement* element = ToHTMLElement( | 
| 2167       ToHTMLElement(web_view->MainFrame()->GetDocument().GetElementById("obj")); | 2167       web_view->MainFrameImpl()->GetDocument().GetElementById("obj")); | 
| 2168   EXPECT_TRUE(element->CanStartSelection()); | 2168   EXPECT_TRUE(element->CanStartSelection()); | 
| 2169 } | 2169 } | 
| 2170 | 2170 | 
| 2171 TEST_P(WebViewTest, LongPressImage) { | 2171 TEST_P(WebViewTest, LongPressImage) { | 
| 2172   RegisterMockedHttpURLLoad("long_press_image.html"); | 2172   RegisterMockedHttpURLLoad("long_press_image.html"); | 
| 2173 | 2173 | 
| 2174   WebViewBase* web_view = | 2174   WebViewBase* web_view = | 
| 2175       web_view_helper_.InitializeAndLoad(base_url_ + "long_press_image.html"); | 2175       web_view_helper_.InitializeAndLoad(base_url_ + "long_press_image.html"); | 
| 2176   web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 2176   web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 
| 2177   web_view->Resize(WebSize(500, 300)); | 2177   web_view->Resize(WebSize(500, 300)); | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2243   web_view->SettingsImpl()->SetTouchDragDropEnabled(true); | 2243   web_view->SettingsImpl()->SetTouchDragDropEnabled(true); | 
| 2244   web_view->Resize(WebSize(500, 300)); | 2244   web_view->Resize(WebSize(500, 300)); | 
| 2245   web_view->UpdateAllLifecyclePhases(); | 2245   web_view->UpdateAllLifecyclePhases(); | 
| 2246   RunPendingTasks(); | 2246   RunPendingTasks(); | 
| 2247 | 2247 | 
| 2248   WebString anchor_tag_id = WebString::FromUTF8("anchorTag"); | 2248   WebString anchor_tag_id = WebString::FromUTF8("anchorTag"); | 
| 2249   WebString image_tag_id = WebString::FromUTF8("imageTag"); | 2249   WebString image_tag_id = WebString::FromUTF8("imageTag"); | 
| 2250 | 2250 | 
| 2251   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, anchor_tag_id)); | 2251   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, anchor_tag_id)); | 
| 2252   EXPECT_STREQ("anchor contextmenu", | 2252   EXPECT_STREQ("anchor contextmenu", | 
| 2253                web_view->MainFrame()->GetDocument().Title().Utf8().data()); | 2253                web_view->MainFrameImpl()->GetDocument().Title().Utf8().data()); | 
| 2254 | 2254 | 
| 2255   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image_tag_id)); | 2255   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureLongPress, image_tag_id)); | 
| 2256   EXPECT_STREQ("image contextmenu", | 2256   EXPECT_STREQ("image contextmenu", | 
| 2257                web_view->MainFrame()->GetDocument().Title().Utf8().data()); | 2257                web_view->MainFrameImpl()->GetDocument().Title().Utf8().data()); | 
| 2258 } | 2258 } | 
| 2259 | 2259 | 
| 2260 TEST_P(WebViewTest, LongPressEmptyEditableSelection) { | 2260 TEST_P(WebViewTest, LongPressEmptyEditableSelection) { | 
| 2261   RegisterMockedHttpURLLoad("long_press_empty_editable_selection.html"); | 2261   RegisterMockedHttpURLLoad("long_press_empty_editable_selection.html"); | 
| 2262 | 2262 | 
| 2263   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 2263   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 2264       base_url_ + "long_press_empty_editable_selection.html"); | 2264       base_url_ + "long_press_empty_editable_selection.html"); | 
| 2265   web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 2265   web_view->SettingsImpl()->SetAlwaysShowContextMenuOnTouch(false); | 
| 2266   web_view->Resize(WebSize(500, 300)); | 2266   web_view->Resize(WebSize(500, 300)); | 
| 2267   web_view->UpdateAllLifecyclePhases(); | 2267   web_view->UpdateAllLifecyclePhases(); | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2378                         WebInputEvent::kTimeStampForTesting); | 2378                         WebInputEvent::kTimeStampForTesting); | 
| 2379   event.source_device = kWebGestureDeviceTouchscreen; | 2379   event.source_device = kWebGestureDeviceTouchscreen; | 
| 2380   event.x = 100; | 2380   event.x = 100; | 
| 2381   event.y = 25; | 2381   event.y = 25; | 
| 2382   event.data.tap.tap_count = 2; | 2382   event.data.tap.tap_count = 2; | 
| 2383 | 2383 | 
| 2384   web_view->HandleInputEvent(WebCoalescedInputEvent(event)); | 2384   web_view->HandleInputEvent(WebCoalescedInputEvent(event)); | 
| 2385   EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 2385   EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 
| 2386 | 2386 | 
| 2387   HTMLTextAreaElement* text_area_element = toHTMLTextAreaElement( | 2387   HTMLTextAreaElement* text_area_element = toHTMLTextAreaElement( | 
| 2388       web_view->MainFrame()->GetDocument().GetElementById(blanklinestextbox)); | 2388       web_view->MainFrameImpl()->GetDocument().GetElementById( | 
|  | 2389           blanklinestextbox)); | 
| 2389   text_area_element->setValue("hello"); | 2390   text_area_element->setValue("hello"); | 
| 2390 | 2391 | 
| 2391   // Long-press past last word of textbox. | 2392   // Long-press past last word of textbox. | 
| 2392   EXPECT_TRUE( | 2393   EXPECT_TRUE( | 
| 2393       TapElementById(WebInputEvent::kGestureLongPress, blanklinestextbox)); | 2394       TapElementById(WebInputEvent::kGestureLongPress, blanklinestextbox)); | 
| 2394   EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 2395   EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 
| 2395 | 2396 | 
| 2396   // Double-tap past last word of textbox. | 2397   // Double-tap past last word of textbox. | 
| 2397   web_view->HandleInputEvent(WebCoalescedInputEvent(event)); | 2398   web_view->HandleInputEvent(WebCoalescedInputEvent(event)); | 
| 2398   EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 2399   EXPECT_TRUE(frame->SelectionAsText().IsEmpty()); | 
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2733 | 2734 | 
| 2734 TEST_P(WebViewTest, FinishComposingTextDoesntTriggerAutofillTextChange) { | 2735 TEST_P(WebViewTest, FinishComposingTextDoesntTriggerAutofillTextChange) { | 
| 2735   RegisterMockedHttpURLLoad("input_field_populated.html"); | 2736   RegisterMockedHttpURLLoad("input_field_populated.html"); | 
| 2736   MockAutofillClient client; | 2737   MockAutofillClient client; | 
| 2737   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 2738   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 2738       base_url_ + "input_field_populated.html"); | 2739       base_url_ + "input_field_populated.html"); | 
| 2739   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 2740   WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 
| 2740   frame->SetAutofillClient(&client); | 2741   frame->SetAutofillClient(&client); | 
| 2741   web_view->SetInitialFocus(false); | 2742   web_view->SetInitialFocus(false); | 
| 2742 | 2743 | 
| 2743   WebDocument document = web_view->MainFrame()->GetDocument(); | 2744   WebDocument document = web_view->MainFrameImpl()->GetDocument(); | 
| 2744   HTMLFormControlElement* form = | 2745   HTMLFormControlElement* form = | 
| 2745       ToHTMLFormControlElement(document.GetElementById("sample")); | 2746       ToHTMLFormControlElement(document.GetElementById("sample")); | 
| 2746 | 2747 | 
| 2747   WebInputMethodController* active_input_method_controller = | 2748   WebInputMethodController* active_input_method_controller = | 
| 2748       frame->FrameWidget()->GetActiveWebInputMethodController(); | 2749       frame->FrameWidget()->GetActiveWebInputMethodController(); | 
| 2749   // Set up a composition that needs to be committed. | 2750   // Set up a composition that needs to be committed. | 
| 2750   std::string composition_text("testingtext"); | 2751   std::string composition_text("testingtext"); | 
| 2751 | 2752 | 
| 2752   WebVector<WebCompositionUnderline> empty_underlines; | 2753   WebVector<WebCompositionUnderline> empty_underlines; | 
| 2753   active_input_method_controller->SetComposition( | 2754   active_input_method_controller->SetComposition( | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2788   frame->SetCompositionFromExistingText(8, 12, empty_underlines); | 2789   frame->SetCompositionFromExistingText(8, 12, empty_underlines); | 
| 2789 | 2790 | 
| 2790   WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); | 2791   WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); | 
| 2791   EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", | 2792   EXPECT_EQ("0123456789abcdefghijklmnopqrstuvwxyz", | 
| 2792             std::string(info.value.Utf8().data())); | 2793             std::string(info.value.Utf8().data())); | 
| 2793   EXPECT_EQ(8, info.composition_start); | 2794   EXPECT_EQ(8, info.composition_start); | 
| 2794   EXPECT_EQ(12, info.composition_end); | 2795   EXPECT_EQ(12, info.composition_end); | 
| 2795 | 2796 | 
| 2796   EXPECT_EQ(0, client.TextChanges()); | 2797   EXPECT_EQ(0, client.TextChanges()); | 
| 2797 | 2798 | 
| 2798   WebDocument document = web_view->MainFrame()->GetDocument(); | 2799   WebDocument document = web_view->MainFrameImpl()->GetDocument(); | 
| 2799   EXPECT_EQ(WebString::FromUTF8("none"), | 2800   EXPECT_EQ(WebString::FromUTF8("none"), | 
| 2800             document.GetElementById("inputEvent").FirstChild().NodeValue()); | 2801             document.GetElementById("inputEvent").FirstChild().NodeValue()); | 
| 2801 | 2802 | 
| 2802   frame->SetAutofillClient(0); | 2803   frame->SetAutofillClient(0); | 
| 2803 } | 2804 } | 
| 2804 | 2805 | 
| 2805 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient { | 2806 class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient { | 
| 2806  public: | 2807  public: | 
| 2807   ViewCreatingWebViewClient() : did_focus_called_(false) {} | 2808   ViewCreatingWebViewClient() : did_focus_called_(false) {} | 
| 2808 | 2809 | 
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2875                    ->MainFrame()) | 2876                    ->MainFrame()) | 
| 2876       ->Loader() | 2877       ->Loader() | 
| 2877       .Load(request_with_target_start); | 2878       .Load(request_with_target_start); | 
| 2878   EXPECT_TRUE(client.DidFocusCalled()); | 2879   EXPECT_TRUE(client.DidFocusCalled()); | 
| 2879 | 2880 | 
| 2880   web_view_helper.Reset();  // Remove dependency on locally scoped client. | 2881   web_view_helper.Reset();  // Remove dependency on locally scoped client. | 
| 2881 } | 2882 } | 
| 2882 | 2883 | 
| 2883 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) { | 2884 TEST_P(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) { | 
| 2884   RegisterMockedHttpURLLoad("focusout_focusin_events.html"); | 2885   RegisterMockedHttpURLLoad("focusout_focusin_events.html"); | 
| 2885   WebView* web_view = web_view_helper_.InitializeAndLoad( | 2886   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 2886       base_url_ + "focusout_focusin_events.html"); | 2887       base_url_ + "focusout_focusin_events.html"); | 
| 2887 | 2888 | 
| 2888   web_view->SetFocus(true); | 2889   web_view->SetFocus(true); | 
| 2889   web_view->SetFocus(false); | 2890   web_view->SetFocus(false); | 
| 2890   web_view->SetFocus(true); | 2891   web_view->SetFocus(true); | 
| 2891 | 2892 | 
| 2892   WebElement element = | 2893   WebElement element = | 
| 2893       web_view->MainFrame()->GetDocument().GetElementById("message"); | 2894       web_view->MainFrameImpl()->GetDocument().GetElementById("message"); | 
| 2894   EXPECT_STREQ("focusoutfocusin", element.TextContent().Utf8().data()); | 2895   EXPECT_STREQ("focusoutfocusin", element.TextContent().Utf8().data()); | 
| 2895 } | 2896 } | 
| 2896 | 2897 | 
| 2897 TEST_P(WebViewTest, DispatchesDomFocusOutDomFocusInOnViewToggleFocus) { | 2898 TEST_P(WebViewTest, DispatchesDomFocusOutDomFocusInOnViewToggleFocus) { | 
| 2898   RegisterMockedHttpURLLoad("domfocusout_domfocusin_events.html"); | 2899   RegisterMockedHttpURLLoad("domfocusout_domfocusin_events.html"); | 
| 2899   WebView* web_view = web_view_helper_.InitializeAndLoad( | 2900   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 2900       base_url_ + "domfocusout_domfocusin_events.html"); | 2901       base_url_ + "domfocusout_domfocusin_events.html"); | 
| 2901 | 2902 | 
| 2902   web_view->SetFocus(true); | 2903   web_view->SetFocus(true); | 
| 2903   web_view->SetFocus(false); | 2904   web_view->SetFocus(false); | 
| 2904   web_view->SetFocus(true); | 2905   web_view->SetFocus(true); | 
| 2905 | 2906 | 
| 2906   WebElement element = | 2907   WebElement element = | 
| 2907       web_view->MainFrame()->GetDocument().GetElementById("message"); | 2908       web_view->MainFrameImpl()->GetDocument().GetElementById("message"); | 
| 2908   EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.TextContent().Utf8().data()); | 2909   EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.TextContent().Utf8().data()); | 
| 2909 } | 2910 } | 
| 2910 | 2911 | 
| 2911 static void OpenDateTimeChooser(WebView* web_view, | 2912 static void OpenDateTimeChooser(WebView* web_view, | 
| 2912                                 HTMLInputElement* input_element) { | 2913                                 HTMLInputElement* input_element) { | 
| 2913   input_element->focus(); | 2914   input_element->focus(); | 
| 2914 | 2915 | 
| 2915   WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown, | 2916   WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown, | 
| 2916                              WebInputEvent::kNoModifiers, | 2917                              WebInputEvent::kNoModifiers, | 
| 2917                              WebInputEvent::kTimeStampForTesting); | 2918                              WebInputEvent::kTimeStampForTesting); | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3004 | 3005 | 
| 3005   // Clear the WebViewClient from the webViewHelper to avoid use-after-free in | 3006   // Clear the WebViewClient from the webViewHelper to avoid use-after-free in | 
| 3006   // the WebViewHelper destructor. | 3007   // the WebViewHelper destructor. | 
| 3007   web_view_helper_.Reset(); | 3008   web_view_helper_.Reset(); | 
| 3008   RuntimeEnabledFeatures::SetInputMultipleFieldsUIEnabled( | 3009   RuntimeEnabledFeatures::SetInputMultipleFieldsUIEnabled( | 
| 3009       original_multiple_fields_flag); | 3010       original_multiple_fields_flag); | 
| 3010 } | 3011 } | 
| 3011 | 3012 | 
| 3012 TEST_P(WebViewTest, DispatchesFocusBlurOnViewToggle) { | 3013 TEST_P(WebViewTest, DispatchesFocusBlurOnViewToggle) { | 
| 3013   RegisterMockedHttpURLLoad("focus_blur_events.html"); | 3014   RegisterMockedHttpURLLoad("focus_blur_events.html"); | 
| 3014   WebView* web_view = | 3015   WebViewBase* web_view = | 
| 3015       web_view_helper_.InitializeAndLoad(base_url_ + "focus_blur_events.html"); | 3016       web_view_helper_.InitializeAndLoad(base_url_ + "focus_blur_events.html"); | 
| 3016 | 3017 | 
| 3017   web_view->SetFocus(true); | 3018   web_view->SetFocus(true); | 
| 3018   web_view->SetFocus(false); | 3019   web_view->SetFocus(false); | 
| 3019   web_view->SetFocus(true); | 3020   web_view->SetFocus(true); | 
| 3020 | 3021 | 
| 3021   WebElement element = | 3022   WebElement element = | 
| 3022       web_view->MainFrame()->GetDocument().GetElementById("message"); | 3023       web_view->MainFrameImpl()->GetDocument().GetElementById("message"); | 
| 3023   // Expect not to see duplication of events. | 3024   // Expect not to see duplication of events. | 
| 3024   EXPECT_STREQ("blurfocus", element.TextContent().Utf8().data()); | 3025   EXPECT_STREQ("blurfocus", element.TextContent().Utf8().data()); | 
| 3025 } | 3026 } | 
| 3026 | 3027 | 
| 3027 TEST_P(WebViewTest, SmartClipData) { | 3028 TEST_P(WebViewTest, SmartClipData) { | 
| 3028   static const char kExpectedClipText[] = "\nPrice 10,000,000won"; | 3029   static const char kExpectedClipText[] = "\nPrice 10,000,000won"; | 
| 3029   static const char kExpectedClipHtml[] = | 3030   static const char kExpectedClipHtml[] = | 
| 3030       "<div id=\"div4\" style=\"padding: 10px; margin: 10px; border: 2px " | 3031       "<div id=\"div4\" style=\"padding: 10px; margin: 10px; border: 2px " | 
| 3031       "solid skyblue; float: left; width: 190px; height: 30px; " | 3032       "solid skyblue; float: left; width: 190px; height: 30px; " | 
| 3032       "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " | 3033       "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " | 
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3598   web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(1)); | 3599   web_view->SetZoomLevel(WebView::ZoomFactorToZoomLevel(1)); | 
| 3599   size = web_view->ContentsPreferredMinimumSize(); | 3600   size = web_view->ContentsPreferredMinimumSize(); | 
| 3600   EXPECT_EQ(2, size.width); | 3601   EXPECT_EQ(2, size.width); | 
| 3601   EXPECT_EQ(2, size.height); | 3602   EXPECT_EQ(2, size.height); | 
| 3602 } | 3603 } | 
| 3603 | 3604 | 
| 3604 TEST_P(WebViewTest, PreferredSizeDirtyLayout) { | 3605 TEST_P(WebViewTest, PreferredSizeDirtyLayout) { | 
| 3605   std::string url = base_url_ + "specify_size.html?100px:100px"; | 3606   std::string url = base_url_ + "specify_size.html?100px:100px"; | 
| 3606   URLTestHelpers::RegisterMockedURLLoad( | 3607   URLTestHelpers::RegisterMockedURLLoad( | 
| 3607       ToKURL(url), testing::WebTestDataPath("specify_size.html")); | 3608       ToKURL(url), testing::WebTestDataPath("specify_size.html")); | 
| 3608   WebView* web_view = web_view_helper_.InitializeAndLoad(url); | 3609   WebViewBase* web_view = web_view_helper_.InitializeAndLoad(url); | 
| 3609   WebElement document_element = | 3610   WebElement document_element = | 
| 3610       web_view->MainFrame()->GetDocument().DocumentElement(); | 3611       web_view->MainFrameImpl()->GetDocument().DocumentElement(); | 
| 3611 | 3612 | 
| 3612   WebSize size = web_view->ContentsPreferredMinimumSize(); | 3613   WebSize size = web_view->ContentsPreferredMinimumSize(); | 
| 3613   EXPECT_EQ(100, size.width); | 3614   EXPECT_EQ(100, size.width); | 
| 3614   EXPECT_EQ(100, size.height); | 3615   EXPECT_EQ(100, size.height); | 
| 3615 | 3616 | 
| 3616   document_element.SetAttribute("style", "display: none"); | 3617   document_element.SetAttribute("style", "display: none"); | 
| 3617 | 3618 | 
| 3618   size = web_view->ContentsPreferredMinimumSize(); | 3619   size = web_view->ContentsPreferredMinimumSize(); | 
| 3619   EXPECT_EQ(0, size.width); | 3620   EXPECT_EQ(0, size.width); | 
| 3620   EXPECT_EQ(0, size.height); | 3621   EXPECT_EQ(0, size.height); | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 3648   IntPoint tapped_position_; | 3649   IntPoint tapped_position_; | 
| 3649   WebNode tapped_node_; | 3650   WebNode tapped_node_; | 
| 3650   bool page_changed_ = false; | 3651   bool page_changed_ = false; | 
| 3651 }; | 3652 }; | 
| 3652 | 3653 | 
| 3653 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeeded) { | 3654 TEST_P(WebViewTest, ShowUnhandledTapUIIfNeeded) { | 
| 3654   std::string test_file = "show_unhandled_tap.html"; | 3655   std::string test_file = "show_unhandled_tap.html"; | 
| 3655   RegisterMockedHttpURLLoad("Ahem.ttf"); | 3656   RegisterMockedHttpURLLoad("Ahem.ttf"); | 
| 3656   RegisterMockedHttpURLLoad(test_file); | 3657   RegisterMockedHttpURLLoad(test_file); | 
| 3657   UnhandledTapWebViewClient client; | 3658   UnhandledTapWebViewClient client; | 
| 3658   WebView* web_view = web_view_helper_.InitializeAndLoad(base_url_ + test_file, | 3659   WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 
| 3659                                                          nullptr, &client); | 3660       base_url_ + test_file, nullptr, &client); | 
| 3660   web_view->Resize(WebSize(500, 300)); | 3661   web_view->Resize(WebSize(500, 300)); | 
| 3661   web_view->UpdateAllLifecyclePhases(); | 3662   web_view->UpdateAllLifecyclePhases(); | 
| 3662   RunPendingTasks(); | 3663   RunPendingTasks(); | 
| 3663 | 3664 | 
| 3664   // Scroll the bottom into view so we can distinguish window coordinates from | 3665   // Scroll the bottom into view so we can distinguish window coordinates from | 
| 3665   // document coordinates. | 3666   // document coordinates. | 
| 3666   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, | 3667   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, | 
| 3667                              WebString::FromUTF8("bottom"))); | 3668                              WebString::FromUTF8("bottom"))); | 
| 3668   EXPECT_TRUE(client.GetWasCalled()); | 3669   EXPECT_TRUE(client.GetWasCalled()); | 
| 3669   EXPECT_EQ(64, client.GetTappedXPos()); | 3670   EXPECT_EQ(64, client.GetTappedXPos()); | 
| 3670   EXPECT_EQ(278, client.GetTappedYPos()); | 3671   EXPECT_EQ(278, client.GetTappedYPos()); | 
| 3671   EXPECT_FALSE(client.IsTappedNodeNull()); | 3672   EXPECT_FALSE(client.IsTappedNodeNull()); | 
| 3672   EXPECT_TRUE(client.GetWebNode().IsTextNode()); | 3673   EXPECT_TRUE(client.GetWebNode().IsTextNode()); | 
| 3673 | 3674 | 
| 3674   // Test basic tap handling and notification. | 3675   // Test basic tap handling and notification. | 
| 3675   client.Reset(); | 3676   client.Reset(); | 
| 3676   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, | 3677   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, | 
| 3677                              WebString::FromUTF8("target"))); | 3678                              WebString::FromUTF8("target"))); | 
| 3678   EXPECT_TRUE(client.GetWasCalled()); | 3679   EXPECT_TRUE(client.GetWasCalled()); | 
| 3679   EXPECT_EQ(144, client.GetTappedXPos()); | 3680   EXPECT_EQ(144, client.GetTappedXPos()); | 
| 3680   EXPECT_EQ(82, client.GetTappedYPos()); | 3681   EXPECT_EQ(82, client.GetTappedYPos()); | 
| 3681   EXPECT_FALSE(client.IsTappedNodeNull()); | 3682   EXPECT_FALSE(client.IsTappedNodeNull()); | 
| 3682   EXPECT_TRUE(client.GetWebNode().IsTextNode()); | 3683   EXPECT_TRUE(client.GetWebNode().IsTextNode()); | 
| 3683   // Make sure the returned text node has the parent element that was our | 3684   // Make sure the returned text node has the parent element that was our | 
| 3684   // target. | 3685   // target. | 
| 3685   EXPECT_EQ(web_view->MainFrame()->GetDocument().GetElementById("target"), | 3686   EXPECT_EQ(web_view->MainFrameImpl()->GetDocument().GetElementById("target"), | 
| 3686             client.GetWebNode().ParentNode()); | 3687             client.GetWebNode().ParentNode()); | 
| 3687 | 3688 | 
| 3688   // Test correct conversion of coordinates to viewport space under pinch-zoom. | 3689   // Test correct conversion of coordinates to viewport space under pinch-zoom. | 
| 3689   web_view->SetPageScaleFactor(2); | 3690   web_view->SetPageScaleFactor(2); | 
| 3690   web_view->SetVisualViewportOffset(WebFloatPoint(50, 20)); | 3691   web_view->SetVisualViewportOffset(WebFloatPoint(50, 20)); | 
| 3691   client.Reset(); | 3692   client.Reset(); | 
| 3692   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, | 3693   EXPECT_TRUE(TapElementById(WebInputEvent::kGestureTap, | 
| 3693                              WebString::FromUTF8("target"))); | 3694                              WebString::FromUTF8("target"))); | 
| 3694   EXPECT_TRUE(client.GetWasCalled()); | 3695   EXPECT_TRUE(client.GetWasCalled()); | 
| 3695   EXPECT_EQ(188, client.GetTappedXPos()); | 3696   EXPECT_EQ(188, client.GetTappedXPos()); | 
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4337   EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 4338   EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 
| 4338   if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { | 4339   if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { | 
| 4339     EXPECT_NE(nullptr, | 4340     EXPECT_NE(nullptr, | 
| 4340               frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 4341               frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 
| 4341   } else { | 4342   } else { | 
| 4342     EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 4343     EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 
| 4343   } | 4344   } | 
| 4344 } | 4345 } | 
| 4345 | 4346 | 
| 4346 }  // namespace blink | 4347 }  // namespace blink | 
| OLD | NEW | 
|---|