summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_view.cc
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 01:48:14 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-19 01:48:14 +0000
commit5015a072d245d2ce4526a136112c80c2f80d6b4a (patch)
tree5fb85f86c5e0a91f967b5fdd0d20ff669884572f /ppapi/tests/test_view.cc
parentff7570302fdfb87f54d363e14d4310fe101e990e (diff)
downloadchromium_src-5015a072d245d2ce4526a136112c80c2f80d6b4a.zip
chromium_src-5015a072d245d2ce4526a136112c80c2f80d6b4a.tar.gz
chromium_src-5015a072d245d2ce4526a136112c80c2f80d6b4a.tar.bz2
Add GetScrollOffset function to PPB_View
This adds a function to PPB_View which allows plugins to know the scroll offset of the page when they are in view. This is useful for OOP PDF which uses the scroll offset of the window it is contained in to determine the document's scroll location. A web page can send scroll location via postMessage but this is slow. Sending the offset directly via view messages is much faster and seems reasonable. We don't send the scroll offset in the cases where the plugin is off screen to avoid any more additional IPC traffic than what currently exists. BUG=303491 Review URL: https://codereview.chromium.org/329033003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278236 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_view.cc')
-rw-r--r--ppapi/tests/test_view.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/ppapi/tests/test_view.cc b/ppapi/tests/test_view.cc
index d141c05..5ce903a 100644
--- a/ppapi/tests/test_view.cc
+++ b/ppapi/tests/test_view.cc
@@ -46,6 +46,7 @@ void TestView::RunTests(const std::string& filter) {
RUN_TEST(PageHideShow, filter);
RUN_TEST(SizeChange, filter);
RUN_TEST(ClipChange, filter);
+ RUN_TEST(ScrollOffsetChange, filter);
}
bool TestView::WaitUntilViewChanged() {
@@ -199,3 +200,29 @@ std::string TestView::TestClipChange() {
ASSERT_TRUE(last_view_.GetClipRect() == desired_clip);
PASS();
}
+
+std::string TestView::TestScrollOffsetChange() {
+ instance_->EvalScript("document.body.style.width = '5000px';"
+ "document.body.style.height = '5000px';");
+ instance_->EvalScript("window.scrollTo(5, 1);");
+
+ PP_Time begin_time = pp::Module::Get()->core()->GetTime();
+ while (WaitUntilViewChanged() &&
+ last_view_.GetScrollOffset() != pp::Point(5, 1) &&
+ pp::Module::Get()->core()->GetTime() - begin_time <
+ kViewChangeTimeoutSec) {
+ }
+ ASSERT_EQ(pp::Point(5, 1), last_view_.GetScrollOffset());
+
+ instance_->EvalScript("window.scrollTo(0, 0);");
+
+ begin_time = pp::Module::Get()->core()->GetTime();
+ while (WaitUntilViewChanged() &&
+ last_view_.GetScrollOffset() != pp::Point(0, 0) &&
+ pp::Module::Get()->core()->GetTime() - begin_time <
+ kViewChangeTimeoutSec) {
+ }
+ ASSERT_EQ(pp::Point(0, 0), last_view_.GetScrollOffset());
+
+ PASS();
+}