Title: [124632] trunk/Source/WebKit/chromium
- Revision
- 124632
- Author
- [email protected]
- Date
- 2012-08-03 11:36:30 -0700 (Fri, 03 Aug 2012)
Log Message
[chromium] Add a test to WebFrameTest for selectRange and visiblePositionForWindowPoint.
https://bugs.webkit.org/show_bug.cgi?id=93108
Patch by Oli Lan <[email protected]> on 2012-08-03
Reviewed by Adam Barth.
Adds a new test WebFrameTest.SelectRange. This tests WebFrameImpl::selectRange, and also
serves to test WebFrameImpl::visiblePositionForWindowPoint as it is used by selectRange.
The test uses sample files that contain selected text on load. The test uses
WebViewImpl::selectionBounds to retrieve the ends of the selection, then unselects
and calls WebFrameImpl::selectRange to attempt to reselect the same text.
Three cases are tested: the normal case, the case where the selected text is offscreen
due to a scroll, and the case where the selected text is in an iframe. This allows the
problem cases and fix in https://bugs.webkit.org/show_bug.cgi?id=79117 to be tested.
* tests/WebFrameTest.cpp:
* tests/data/select_range_basic.html: Added.
* tests/data/select_range_iframe.html: Added.
* tests/data/select_range_scroll.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (124631 => 124632)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-08-03 18:34:27 UTC (rev 124631)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-08-03 18:36:30 UTC (rev 124632)
@@ -1,3 +1,26 @@
+2012-08-03 Oli Lan <[email protected]>
+
+ [chromium] Add a test to WebFrameTest for selectRange and visiblePositionForWindowPoint.
+ https://bugs.webkit.org/show_bug.cgi?id=93108
+
+ Reviewed by Adam Barth.
+
+ Adds a new test WebFrameTest.SelectRange. This tests WebFrameImpl::selectRange, and also
+ serves to test WebFrameImpl::visiblePositionForWindowPoint as it is used by selectRange.
+
+ The test uses sample files that contain selected text on load. The test uses
+ WebViewImpl::selectionBounds to retrieve the ends of the selection, then unselects
+ and calls WebFrameImpl::selectRange to attempt to reselect the same text.
+
+ Three cases are tested: the normal case, the case where the selected text is offscreen
+ due to a scroll, and the case where the selected text is in an iframe. This allows the
+ problem cases and fix in https://bugs.webkit.org/show_bug.cgi?id=79117 to be tested.
+
+ * tests/WebFrameTest.cpp:
+ * tests/data/select_range_basic.html: Added.
+ * tests/data/select_range_iframe.html: Added.
+ * tests/data/select_range_scroll.html: Added.
+
2012-08-03 Ilya Tikhonovsky <[email protected]>
Web Inspector: eliminate visitBaseClass method from NMI. It introduces unnecessary complexity.
Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (124631 => 124632)
--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-08-03 18:34:27 UTC (rev 124631)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-08-03 18:36:30 UTC (rev 124632)
@@ -804,4 +804,38 @@
EXPECT_TRUE(selectionHtml.isEmpty());
}
+TEST_F(WebFrameTest, SelectRange)
+{
+ registerMockedHttpURLLoad("select_range_basic.html");
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "select_range_basic.html", true);
+ WebFrame* frame = webView->mainFrame();
+ WebRect startWebRect;
+ WebRect endWebRect;
+ webView->selectionBounds(startWebRect, endWebRect);
+ frame->executeCommand(WebString::fromUTF8("Unselect"));
+ EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
+ frame->selectRange(WebPoint(startWebRect.x, startWebRect.y), WebPoint(endWebRect.x + endWebRect.width, endWebRect.y + endWebRect.height));
+ EXPECT_EQ("some test text for testing", std::string(frame->selectionAsText().utf8().data()));
+
+ registerMockedHttpURLLoad("select_range_scroll.html");
+ webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "select_range_scroll.html", true);
+ frame = webView->mainFrame();
+ webView->selectionBounds(startWebRect, endWebRect);
+ frame->executeCommand(WebString::fromUTF8("Unselect"));
+ EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
+ frame->selectRange(WebPoint(startWebRect.x, startWebRect.y), WebPoint(endWebRect.x + endWebRect.width, endWebRect.y + endWebRect.height));
+ EXPECT_EQ("some offscreen test text for testing", std::string(frame->selectionAsText().utf8().data()));
+
+ registerMockedHttpURLLoad("select_range_iframe.html");
+ webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "select_range_iframe.html", true);
+ frame = webView->mainFrame();
+ WebFrame* subframe = frame->findChildByExpression(WebString::fromUTF8("/html/body/iframe"));
+ webView->selectionBounds(startWebRect, endWebRect);
+ EXPECT_EQ("some test text for testing", std::string(subframe->selectionAsText().utf8().data()));
+ subframe->executeCommand(WebString::fromUTF8("Unselect"));
+ EXPECT_EQ("", std::string(subframe->selectionAsText().utf8().data()));
+ subframe->selectRange(WebPoint(startWebRect.x, startWebRect.y), WebPoint(endWebRect.x + endWebRect.width, endWebRect.y + endWebRect.height));
+ EXPECT_EQ("some test text for testing", std::string(subframe->selectionAsText().utf8().data()));
+}
+
} // namespace
Added: trunk/Source/WebKit/chromium/tests/data/select_range_basic.html (0 => 124632)
--- trunk/Source/WebKit/chromium/tests/data/select_range_basic.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/select_range_basic.html 2012-08-03 18:36:30 UTC (rev 124632)
@@ -0,0 +1,9 @@
+<span id='target'>some test text for testing</span>
+<script>
+ function select() {
+ var range = document.createRange();
+ range.selectNode(document.getElementById('target'));
+ window.getSelection().addRange(range);
+ }
+ window._onload_ = select;
+</script>
Added: trunk/Source/WebKit/chromium/tests/data/select_range_iframe.html (0 => 124632)
--- trunk/Source/WebKit/chromium/tests/data/select_range_iframe.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/select_range_iframe.html 2012-08-03 18:36:30 UTC (rev 124632)
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ This is a test case for selecting a range within an iframe.
+ <iframe width=400 height=200 id="iframe" src=""
+ </body>
+</html>
+<script>
+ document.getElementById('iframe').contentWindow.focus();
+</script>
Added: trunk/Source/WebKit/chromium/tests/data/select_range_scroll.html (0 => 124632)
--- trunk/Source/WebKit/chromium/tests/data/select_range_scroll.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/select_range_scroll.html 2012-08-03 18:36:30 UTC (rev 124632)
@@ -0,0 +1,9 @@
+<div style='height:3000px'>
+ <span id="target">some offscreen test text for testing</span>
+</div>
+<script>
+ var range = document.createRange();
+ range.selectNode(document.getElementById('target'));
+ window.getSelection().addRange(range);
+ window.scrollBy(0,500);
+</script>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes