| 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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 webViewImpl->resize(WebSize(640, 480)); | 712 webViewImpl->resize(WebSize(640, 480)); |
| 713 webViewImpl->layout(); | 713 webViewImpl->layout(); |
| 714 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 714 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
| 715 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 715 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
| 716 | 716 |
| 717 // Make the page scale and scroll with the given paremeters. | 717 // Make the page scale and scroll with the given paremeters. |
| 718 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); | 718 webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); |
| 719 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 719 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
| 720 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 720 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
| 721 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 721 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
| 722 webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScroll
State(); | 722 webViewImpl->page()->mainFrame()->loader().history()->saveDocumentAndScrollS
tate(); |
| 723 | 723 |
| 724 // Confirm that restoring the page state restores the parameters. | 724 // Confirm that restoring the page state restores the parameters. |
| 725 webViewImpl->setPageScaleFactor(1.5f, WebPoint(16, 24)); | 725 webViewImpl->setPageScaleFactor(1.5f, WebPoint(16, 24)); |
| 726 EXPECT_EQ(1.5f, webViewImpl->pageScaleFactor()); | 726 EXPECT_EQ(1.5f, webViewImpl->pageScaleFactor()); |
| 727 EXPECT_EQ(16, webViewImpl->mainFrame()->scrollOffset().width); | 727 EXPECT_EQ(16, webViewImpl->mainFrame()->scrollOffset().width); |
| 728 EXPECT_EQ(24, webViewImpl->mainFrame()->scrollOffset().height); | 728 EXPECT_EQ(24, webViewImpl->mainFrame()->scrollOffset().height); |
| 729 // WebViewImpl::setPageScaleFactor is performing user scrolls, which will se
t the | 729 // WebViewImpl::setPageScaleFactor is performing user scrolls, which will se
t the |
| 730 // wasScrolledByUser flag on the main frame, and prevent restoreScrollPositi
onAndViewState | 730 // wasScrolledByUser flag on the main frame, and prevent restoreScrollPositi
onAndViewState |
| 731 // from restoring the scrolling position. | 731 // from restoring the scrolling position. |
| 732 webViewImpl->page()->mainFrame()->view()->setWasScrolledByUser(false); | 732 webViewImpl->page()->mainFrame()->view()->setWasScrolledByUser(false); |
| 733 webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPosition
AndViewState(); | 733 webViewImpl->page()->mainFrame()->loader().history()->restoreScrollPositionA
ndViewState(); |
| 734 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 734 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
| 735 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 735 EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); |
| 736 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 736 EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); |
| 737 webViewImpl->page()->mainFrame()->loader()->history()->saveDocumentAndScroll
State(); | 737 webViewImpl->page()->mainFrame()->loader().history()->saveDocumentAndScrollS
tate(); |
| 738 | 738 |
| 739 // Confirm that resetting the page state resets the saved scroll position. | 739 // Confirm that resetting the page state resets the saved scroll position. |
| 740 // The HistoryController treats a page scale factor of 0.0f as special and a
voids | 740 // The HistoryController treats a page scale factor of 0.0f as special and a
voids |
| 741 // restoring it to the WebView. | 741 // restoring it to the WebView. |
| 742 webViewImpl->resetScrollAndScaleState(); | 742 webViewImpl->resetScrollAndScaleState(); |
| 743 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 743 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
| 744 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 744 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
| 745 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 745 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
| 746 webViewImpl->page()->mainFrame()->loader()->history()->restoreScrollPosition
AndViewState(); | 746 webViewImpl->page()->mainFrame()->loader().history()->restoreScrollPositionA
ndViewState(); |
| 747 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 747 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
| 748 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 748 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
| 749 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 749 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
| 750 } | 750 } |
| 751 | 751 |
| 752 class EnterFullscreenWebViewClient : public WebViewClient { | 752 class EnterFullscreenWebViewClient : public WebViewClient { |
| 753 public: | 753 public: |
| 754 // WebViewClient methods | 754 // WebViewClient methods |
| 755 virtual bool enterFullScreen() { return true; } | 755 virtual bool enterFullScreen() { return true; } |
| 756 virtual void exitFullScreen() { } | 756 virtual void exitFullScreen() { } |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 FrameTestHelpers::WebViewHelper m_webViewHelper; | 1180 FrameTestHelpers::WebViewHelper m_webViewHelper; |
| 1181 WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initialize(true, 0,
&client)); | 1181 WebViewImpl* webViewImpl = toWebViewImpl(m_webViewHelper.initialize(true, 0,
&client)); |
| 1182 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); | 1182 webViewImpl->page()->settings().setJavaScriptCanOpenWindowsAutomatically(tru
e); |
| 1183 WebFrameImpl* frame = toWebFrameImpl(webViewImpl->mainFrame()); | 1183 WebFrameImpl* frame = toWebFrameImpl(webViewImpl->mainFrame()); |
| 1184 frame->setName("_start"); | 1184 frame->setName("_start"); |
| 1185 | 1185 |
| 1186 // Make a request that will open a new window | 1186 // Make a request that will open a new window |
| 1187 WebURLRequest webURLRequest; | 1187 WebURLRequest webURLRequest; |
| 1188 webURLRequest.initialize(); | 1188 webURLRequest.initialize(); |
| 1189 WebCore::FrameLoadRequest request(0, webURLRequest.toResourceRequest(), WTF:
:String("_blank")); | 1189 WebCore::FrameLoadRequest request(0, webURLRequest.toResourceRequest(), WTF:
:String("_blank")); |
| 1190 webViewImpl->page()->mainFrame()->loader()->load(request); | 1190 webViewImpl->page()->mainFrame()->loader().load(request); |
| 1191 ASSERT_TRUE(client.createdWebView()); | 1191 ASSERT_TRUE(client.createdWebView()); |
| 1192 EXPECT_FALSE(client.didFocusCalled()); | 1192 EXPECT_FALSE(client.didFocusCalled()); |
| 1193 | 1193 |
| 1194 // Make a request from the new window that will navigate the original window
. The original window should be focused. | 1194 // Make a request from the new window that will navigate the original window
. The original window should be focused. |
| 1195 WebURLRequest webURLRequestWithTargetStart; | 1195 WebURLRequest webURLRequestWithTargetStart; |
| 1196 webURLRequestWithTargetStart.initialize(); | 1196 webURLRequestWithTargetStart.initialize(); |
| 1197 WebCore::FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetS
tart.toResourceRequest(), WTF::String("_start")); | 1197 WebCore::FrameLoadRequest requestWithTargetStart(0, webURLRequestWithTargetS
tart.toResourceRequest(), WTF::String("_start")); |
| 1198 toWebViewImpl(client.createdWebView())->page()->mainFrame()->loader()->load(
requestWithTargetStart); | 1198 toWebViewImpl(client.createdWebView())->page()->mainFrame()->loader().load(r
equestWithTargetStart); |
| 1199 EXPECT_TRUE(client.didFocusCalled()); | 1199 EXPECT_TRUE(client.didFocusCalled()); |
| 1200 | 1200 |
| 1201 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 1201 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) | 1204 TEST_F(WebViewTest, DispatchesFocusOutFocusInOnViewToggleFocus) |
| 1205 { | 1205 { |
| 1206 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "focusout_focusin_events.html"); | 1206 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), "focusout_focusin_events.html"); |
| 1207 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "focusout_f
ocusin_events.html", true, 0); | 1207 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "focusout_f
ocusin_events.html", true, 0); |
| 1208 | 1208 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1221 | 1221 |
| 1222 webView->setFocus(true); | 1222 webView->setFocus(true); |
| 1223 webView->setFocus(false); | 1223 webView->setFocus(false); |
| 1224 webView->setFocus(true); | 1224 webView->setFocus(true); |
| 1225 | 1225 |
| 1226 WebElement element = webView->mainFrame()->document().getElementById("messag
e"); | 1226 WebElement element = webView->mainFrame()->document().getElementById("messag
e"); |
| 1227 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); | 1227 EXPECT_STREQ("DOMFocusOutDOMFocusIn", element.innerText().utf8().data()); |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 } | 1230 } |
| OLD | NEW |