Chromium Code Reviews| Index: Source/WebKit/chromium/tests/WebFrameTest.cpp |
| diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp |
| index dba403be336fc801d6a56a2b7a66d570acb0078a..645f5a159eead38cf28246cbc1b5e1a9d8dd53ec 100644 |
| --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp |
| +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp |
| @@ -2201,8 +2201,6 @@ TEST_F(WebFrameTest, SelectRange) |
| registerMockedHttpURLLoad("select_range_basic.html"); |
| registerMockedHttpURLLoad("select_range_scroll.html"); |
| - registerMockedHttpURLLoad("select_range_iframe.html"); |
| - registerMockedHttpURLLoad("select_range_editable.html"); |
| m_webView = createWebViewForTextSelection(m_baseURL + "select_range_basic.html"); |
| frame = m_webView->mainFrame(); |
| @@ -2225,6 +2223,15 @@ TEST_F(WebFrameTest, SelectRange) |
| EXPECT_EQ("Some offscreen test text for testing.", selectionAsString(frame)); |
| m_webView->close(); |
| m_webView = 0; |
| +} |
| + |
| +TEST_F(WebFrameTest, SelectRangeInIframe) { |
| + WebFrame* frame; |
| + WebRect startWebRect; |
| + WebRect endWebRect; |
| + |
| + registerMockedHttpURLLoad("select_range_iframe.html"); |
| + registerMockedHttpURLLoad("select_range_basic.html"); |
| m_webView = createWebViewForTextSelection(m_baseURL + "select_range_iframe.html"); |
| frame = m_webView->mainFrame(); |
| @@ -2237,21 +2244,73 @@ TEST_F(WebFrameTest, SelectRange) |
| EXPECT_EQ("Some test text for testing.", selectionAsString(subframe)); |
| m_webView->close(); |
| m_webView = 0; |
| +} |
| + |
| +TEST_F(WebFrameTest, SelectRangeDivContentEditable) { |
| + WebFrame* frame; |
| + WebRect startWebRect; |
| + WebRect endWebRect; |
| + |
| + registerMockedHttpURLLoad("select_range_div_editable.html"); |
| // Select the middle of an editable element, then try to extend the selection to the top of the document. |
| // The selection range should be clipped to the bounds of the editable element. |
| - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_editable.html"); |
| + m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_editable.html"); |
| frame = m_webView->mainFrame(); |
| EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| m_webView->selectionBounds(startWebRect, endWebRect); |
| + |
| frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
| EXPECT_EQ("16-char header. This text is initially selected.", selectionAsString(frame)); |
| m_webView->close(); |
| m_webView = 0; |
| // As above, but extending the selection to the bottom of the document. |
| - m_webView = createWebViewForTextSelection(m_baseURL + "select_range_editable.html"); |
| + m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_editable.html"); |
| frame = m_webView->mainFrame(); |
| + |
| + m_webView->selectionBounds(startWebRect, endWebRect); |
| + frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
| + EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| + m_webView->selectionBounds(startWebRect, endWebRect); |
| + |
| + m_webView->selectionBounds(startWebRect, endWebRect); |
| + frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); |
| + EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsString(frame)); |
| + m_webView->close(); |
| + m_webView = 0; |
| +} |
| + |
| +// positionForPoint returns the wrong values for contenteditable spans. See |
| +// http://crbug.com/238334. |
| +TEST_F(WebFrameTest, DISABLED_SelectRangeSpanContentEditable) { |
| + WebFrame* frame; |
| + WebRect startWebRect; |
| + WebRect endWebRect; |
| + |
| + registerMockedHttpURLLoad("select_range_span_editable.html"); |
| + |
| + // Select the middle of an editable element, then try to extend the selection to the top of the document. |
| + // The selection range should be clipped to the bounds of the editable element. |
| + m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_editable.html"); |
| + frame = m_webView->mainFrame(); |
| + EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| + m_webView->selectionBounds(startWebRect, endWebRect); |
| + |
| + frame->selectRange(bottomRightMinusOne(endWebRect), WebPoint(0, 0)); |
| + EXPECT_EQ("16-char header. This text is initially selected.", selectionAsString(frame)); |
| + m_webView->close(); |
| + m_webView = 0; |
| + |
| + // As above, but extending the selection to the bottom of the document. |
| + m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_editable.html"); |
| + frame = m_webView->mainFrame(); |
| + |
| + m_webView->selectionBounds(startWebRect, endWebRect); |
| + frame->selectRange(topLeft(startWebRect), bottomRightMinusOne(endWebRect)); |
| + EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| + m_webView->selectionBounds(startWebRect, endWebRect); |
| + |
| EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| m_webView->selectionBounds(startWebRect, endWebRect); |
| frame->selectRange(topLeft(startWebRect), WebPoint(640, 480)); |
| @@ -2302,7 +2361,9 @@ TEST_F(WebFrameTest, SelectRangeCanMoveSelectionStart) |
| frame->executeScript(WebScriptSource("selectElement('editable_2');")); |
| EXPECT_EQ("Editable 2.", selectionAsString(frame)); |
| frame->selectRange(bottomRightMinusOne(elementBounds(frame, "editable_2")), topLeft(elementBounds(frame, "header_2"))); |
| - EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); |
| + // positionForPoint returns the wrong values for contenteditable spans. See |
| + // http://crbug.com/238334. |
| + //EXPECT_EQ("[ Editable 1. Editable 2.", selectionAsString(frame)); |
| } |
| TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd) |
| @@ -2347,10 +2408,74 @@ TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd) |
| frame->executeScript(WebScriptSource("selectElement('editable_1');")); |
| EXPECT_EQ("Editable 1.", selectionAsString(frame)); |
| frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightMinusOne(elementBounds(frame, "footer_1"))); |
| - EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); |
| + // positionForPoint returns the wrong values for contenteditable spans. See |
| + // http://crbug.com/238334. |
| + //EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); |
| +} |
| + |
| +// positionForPoint returns the wrong values for contenteditable spans. See |
| +// http://crbug.com/238334. |
| +TEST_F(WebFrameTest, DISABLED_PositionForPointTest) { |
|
cjhopman
2013/05/06 21:49:37
I don't know how to actually write this test (shou
|
| + registerMockedHttpURLLoad("select_range_span_editable.html"); |
| + m_webView = createWebViewForTextSelection(m_baseURL + "select_range_span_editable.html"); |
| + WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame()); |
| + WebCore::RenderObject* renderer = mainFrame->frame()->selection()->rootEditableElement()->renderer(); |
| + EXPECT_EQ(0, renderer->positionForPoint(WebCore::LayoutPoint(-1, -1)).deepEquivalent().computeOffsetInContainerNode()); |
| + EXPECT_EQ(64, renderer->positionForPoint(WebCore::LayoutPoint(1000, 1000)).deepEquivalent().computeOffsetInContainerNode()); |
| + |
| + registerMockedHttpURLLoad("select_range_div_editable.html"); |
| + m_webView = createWebViewForTextSelection(m_baseURL + "select_range_div_editable.html"); |
| + mainFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame()); |
| + renderer = mainFrame->frame()->selection()->rootEditableElement()->renderer(); |
| + EXPECT_EQ(0, renderer->positionForPoint(WebCore::LayoutPoint(-1, -1)).deepEquivalent().computeOffsetInContainerNode()); |
| + EXPECT_EQ(64, renderer->positionForPoint(WebCore::LayoutPoint(1000, 1000)).deepEquivalent().computeOffsetInContainerNode()); |
| } |
| #if OS(ANDROID) |
| +TEST_F(WebFrameTest, SelectRangeStaysHorizontallyAlignedWhenMoved) |
| +{ |
| + WebFrameImpl* frame; |
| + registerMockedHttpURLLoad("move_caret.html"); |
| + |
| + m_webView = createWebViewForTextSelection(m_baseURL + "move_caret.html"); |
| + frame = (WebFrameImpl*)m_webView->mainFrame(); |
| + |
| + WebRect initialStartRect; |
| + WebRect initialEndRect; |
| + WebRect startRect; |
| + WebRect endRect; |
| + |
| + frame->executeScript(WebScriptSource("selectRange();")); |
| + m_webView->selectionBounds(initialStartRect, initialEndRect); |
| + WebPoint movedStart(topLeft(initialStartRect)); |
| + |
| + movedStart.y += 40; |
| + frame->selectRange(movedStart, bottomRightMinusOne(initialEndRect)); |
| + m_webView->selectionBounds(startRect, endRect); |
| + EXPECT_EQ(startRect, initialStartRect); |
| + EXPECT_EQ(endRect, initialEndRect); |
| + |
| + movedStart.y -= 80; |
| + frame->selectRange(movedStart, bottomRightMinusOne(initialEndRect)); |
| + m_webView->selectionBounds(startRect, endRect); |
| + EXPECT_EQ(startRect, initialStartRect); |
| + EXPECT_EQ(endRect, initialEndRect); |
| + |
| + WebPoint movedEnd(bottomRightMinusOne(initialEndRect)); |
| + |
| + movedEnd.y += 40; |
| + frame->selectRange(topLeft(initialStartRect), movedEnd); |
| + m_webView->selectionBounds(startRect, endRect); |
| + EXPECT_EQ(startRect, initialStartRect); |
| + EXPECT_EQ(endRect, initialEndRect); |
| + |
| + movedEnd.y -= 80; |
| + frame->selectRange(topLeft(initialStartRect), movedEnd); |
| + m_webView->selectionBounds(startRect, endRect); |
| + EXPECT_EQ(startRect, initialStartRect); |
| + EXPECT_EQ(endRect, initialEndRect); |
| +} |
| + |
| TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) |
| { |
| WebFrameImpl* frame; |
| @@ -2364,7 +2489,7 @@ TEST_F(WebFrameTest, MoveCaretStaysHorizontallyAlignedWhenMoved) |
| WebRect startRect; |
| WebRect endRect; |
| - frame->executeScript(WebScriptSource("select();")); |
| + frame->executeScript(WebScriptSource("selectCaret();")); |
| m_webView->selectionBounds(initialStartRect, initialEndRect); |
| WebPoint moveTo(topLeft(initialStartRect)); |