OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 4096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4107 | 4107 |
4108 // If the selection is editable text, we can't extend it into non-editable t
ext. | 4108 // If the selection is editable text, we can't extend it into non-editable t
ext. |
4109 frame->executeScript(WebScriptSource("selectElement('editable_1');")); | 4109 frame->executeScript(WebScriptSource("selectElement('editable_1');")); |
4110 EXPECT_EQ("Editable 1.", selectionAsString(frame)); | 4110 EXPECT_EQ("Editable 1.", selectionAsString(frame)); |
4111 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightM
inusOne(elementBounds(frame, "footer_1"))); | 4111 frame->selectRange(topLeft(elementBounds(frame, "editable_1")), bottomRightM
inusOne(elementBounds(frame, "footer_1"))); |
4112 // positionForPoint returns the wrong values for contenteditable spans. See | 4112 // positionForPoint returns the wrong values for contenteditable spans. See |
4113 // http://crbug.com/238334. | 4113 // http://crbug.com/238334. |
4114 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); | 4114 // EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame)); |
4115 } | 4115 } |
4116 | 4116 |
| 4117 TEST_F(WebFrameTest, MoveRangeSelectionExtent) |
| 4118 { |
| 4119 WebLocalFrameImpl* frame; |
| 4120 WebRect startWebRect; |
| 4121 WebRect endWebRect; |
| 4122 |
| 4123 registerMockedHttpURLLoad("move_range_selection_extent.html"); |
| 4124 |
| 4125 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4126 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html
", &webViewHelper); |
| 4127 frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
| 4128 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| 4129 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
| 4130 |
| 4131 frame->moveRangeSelectionExtent(WebPoint(640, 480)); |
| 4132 EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsStr
ing(frame)); |
| 4133 |
| 4134 frame->moveRangeSelectionExtent(WebPoint(0, 0)); |
| 4135 EXPECT_EQ("16-char header. ", selectionAsString(frame)); |
| 4136 |
| 4137 // Reset with swapped base and extent. |
| 4138 frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect)); |
| 4139 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| 4140 |
| 4141 frame->moveRangeSelectionExtent(WebPoint(640, 480)); |
| 4142 EXPECT_EQ(" 16-char footer.", selectionAsString(frame)); |
| 4143 |
| 4144 frame->moveRangeSelectionExtent(WebPoint(0, 0)); |
| 4145 EXPECT_EQ("16-char header. This text is initially selected.", selectionAsStr
ing(frame)); |
| 4146 |
| 4147 frame->executeCommand(WebString::fromUTF8("Unselect")); |
| 4148 EXPECT_EQ("", selectionAsString(frame)); |
| 4149 } |
| 4150 |
| 4151 TEST_F(WebFrameTest, MoveRangeSelectionExtentCannotCollapse) |
| 4152 { |
| 4153 WebLocalFrameImpl* frame; |
| 4154 WebRect startWebRect; |
| 4155 WebRect endWebRect; |
| 4156 |
| 4157 registerMockedHttpURLLoad("move_range_selection_extent.html"); |
| 4158 |
| 4159 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4160 initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html
", &webViewHelper); |
| 4161 frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame()); |
| 4162 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| 4163 webViewHelper.webView()->selectionBounds(startWebRect, endWebRect); |
| 4164 |
| 4165 frame->moveRangeSelectionExtent(bottomRightMinusOne(startWebRect)); |
| 4166 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| 4167 |
| 4168 // Reset with swapped base and extent. |
| 4169 frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect)); |
| 4170 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| 4171 |
| 4172 frame->moveRangeSelectionExtent(bottomRightMinusOne(endWebRect)); |
| 4173 EXPECT_EQ("This text is initially selected.", selectionAsString(frame)); |
| 4174 } |
| 4175 |
4117 static int computeOffset(RenderObject* renderer, int x, int y) | 4176 static int computeOffset(RenderObject* renderer, int x, int y) |
4118 { | 4177 { |
4119 return VisiblePosition(renderer->positionForPoint(LayoutPoint(x, y))).deepEq
uivalent().computeOffsetInContainerNode(); | 4178 return VisiblePosition(renderer->positionForPoint(LayoutPoint(x, y))).deepEq
uivalent().computeOffsetInContainerNode(); |
4120 } | 4179 } |
4121 | 4180 |
4122 // positionForPoint returns the wrong values for contenteditable spans. See | 4181 // positionForPoint returns the wrong values for contenteditable spans. See |
4123 // http://crbug.com/238334. | 4182 // http://crbug.com/238334. |
4124 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) | 4183 TEST_F(WebFrameTest, DISABLED_PositionForPointTest) |
4125 { | 4184 { |
4126 registerMockedHttpURLLoad("select_range_span_editable.html"); | 4185 registerMockedHttpURLLoad("select_range_span_editable.html"); |
(...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6722 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6781 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6723 | 6782 |
6724 // Neither should a page reload. | 6783 // Neither should a page reload. |
6725 localFrame->reload(); | 6784 localFrame->reload(); |
6726 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); | 6785 EXPECT_EQ(4u, frameClient.provisionalLoadCount()); |
6727 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); | 6786 EXPECT_FALSE(frameClient.wasLastProvisionalLoadATransition()); |
6728 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); | 6787 EXPECT_EQ(1u, frameClient.navigationalDataReceivedCount()); |
6729 } | 6788 } |
6730 | 6789 |
6731 } // namespace | 6790 } // namespace |
OLD | NEW |