| 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 5320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5331 // Make sure that a modal dialog forces us to notify right away. | 5331 // Make sure that a modal dialog forces us to notify right away. |
| 5332 newView->mainFrame()->executeScript( | 5332 newView->mainFrame()->executeScript( |
| 5333 WebScriptSource("window.opener.confirm('Modal');")); | 5333 WebScriptSource("window.opener.confirm('Modal');")); |
| 5334 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5334 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
| 5335 | 5335 |
| 5336 // Ensure that we don't notify again later. | 5336 // Ensure that we don't notify again later. |
| 5337 runPendingTasks(); | 5337 runPendingTasks(); |
| 5338 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5338 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
| 5339 } | 5339 } |
| 5340 | 5340 |
| 5341 class TestMainFrameUserOrProgrammaticScrollFrameClient : public FrameTestHelpers
::TestWebFrameClient { | 5341 class TestScrolledFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 5342 public: | 5342 public: |
| 5343 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); } | 5343 TestScrolledFrameClient() { reset(); } |
| 5344 void reset() | 5344 void reset() |
| 5345 { | 5345 { |
| 5346 m_didScrollMainFrame = false; | 5346 m_didScrollFrame = false; |
| 5347 m_wasProgrammaticScroll = false; | |
| 5348 } | 5347 } |
| 5349 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } | 5348 bool wasFrameScrolled() const { return m_didScrollFrame; } |
| 5350 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } | |
| 5351 | 5349 |
| 5352 // WebFrameClient: | 5350 // WebFrameClient: |
| 5353 virtual void didChangeScrollOffset(WebLocalFrame* frame) override | 5351 virtual void didChangeScrollOffset(WebLocalFrame* frame) override |
| 5354 { | 5352 { |
| 5355 if (frame->parent()) | 5353 if (frame->parent()) |
| 5356 return; | 5354 return; |
| 5357 EXPECT_FALSE(m_didScrollMainFrame); | 5355 EXPECT_FALSE(m_didScrollFrame); |
| 5358 FrameView* view = toWebLocalFrameImpl(frame)->frameView(); | 5356 FrameView* view = toWebLocalFrameImpl(frame)->frameView(); |
| 5359 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect | 5357 // FrameView can be scrolled in FrameView::setFixedVisibleContentRect |
| 5360 // which is called from LocalFrame::createView (before the frame is asso
ciated | 5358 // which is called from LocalFrame::createView (before the frame is asso
ciated |
| 5361 // with the the view). | 5359 // with the the view). |
| 5362 if (view) { | 5360 if (view) |
| 5363 m_didScrollMainFrame = true; | 5361 m_didScrollFrame = true; |
| 5364 m_wasProgrammaticScroll = view->inProgrammaticScroll(); | |
| 5365 } | |
| 5366 } | 5362 } |
| 5367 private: | 5363 private: |
| 5368 bool m_didScrollMainFrame; | 5364 bool m_didScrollFrame; |
| 5369 bool m_wasProgrammaticScroll; | |
| 5370 }; | 5365 }; |
| 5371 | 5366 |
| 5372 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) | 5367 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) |
| 5373 { | 5368 { |
| 5374 registerMockedHttpURLLoad("long_scroll.html"); | 5369 registerMockedHttpURLLoad("long_scroll.html"); |
| 5375 TestMainFrameUserOrProgrammaticScrollFrameClient client; | 5370 TestScrolledFrameClient client; |
| 5376 | 5371 |
| 5377 // Make sure we initialize to minimum scale, even if the window size | 5372 // Make sure we initialize to minimum scale, even if the window size |
| 5378 // only becomes available after the load begins. | 5373 // only becomes available after the load begins. |
| 5379 FrameTestHelpers::WebViewHelper webViewHelper; | 5374 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5380 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien
t); | 5375 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien
t); |
| 5381 webViewHelper.webView()->resize(WebSize(1000, 1000)); | 5376 webViewHelper.webView()->resize(WebSize(1000, 1000)); |
| 5382 webViewHelper.webView()->layout(); | 5377 webViewHelper.webView()->layout(); |
| 5383 | 5378 |
| 5384 EXPECT_FALSE(client.wasUserScroll()); | 5379 WebLocalFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); |
| 5385 EXPECT_FALSE(client.wasProgrammaticScroll()); | 5380 FrameView* view = frameImpl->frameView(); |
| 5381 |
| 5382 EXPECT_FALSE(client.wasFrameScrolled()); |
| 5383 EXPECT_FALSE(view->wasScrolledByUser()); |
| 5386 | 5384 |
| 5387 // Do a compositor scroll, verify that this is counted as a user scroll. | 5385 // Do a compositor scroll, verify that this is counted as a user scroll. |
| 5388 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(0, 1), WebFloatSize(), 1.7f, 0); | 5386 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(0, 1), WebFloatSize(), 1.7f, 0); |
| 5389 EXPECT_TRUE(client.wasUserScroll()); | 5387 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5388 EXPECT_TRUE(view->wasScrolledByUser()); |
| 5389 |
| 5390 client.reset(); | 5390 client.reset(); |
| 5391 | 5391 view->setWasScrolledByUser(false); |
| 5392 EXPECT_FALSE(client.wasUserScroll()); | |
| 5393 EXPECT_FALSE(client.wasProgrammaticScroll()); | |
| 5394 | 5392 |
| 5395 // The page scale 1.0f and scroll. | 5393 // The page scale 1.0f and scroll. |
| 5396 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(0, 1), WebFloatSize(), 1.0f, 0); | 5394 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(0, 1), WebFloatSize(), 1.0f, 0); |
| 5397 EXPECT_TRUE(client.wasUserScroll()); | 5395 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5396 EXPECT_TRUE(view->wasScrolledByUser()); |
| 5398 client.reset(); | 5397 client.reset(); |
| 5398 view->setWasScrolledByUser(false); |
| 5399 | 5399 |
| 5400 // No scroll event if there is no scroll delta. | 5400 // No scroll event if there is no scroll delta. |
| 5401 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(), WebFloatSize(), 1.0f, 0); | 5401 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(), WebFloatSize(), 1.0f, 0); |
| 5402 EXPECT_FALSE(client.wasUserScroll()); | 5402 EXPECT_FALSE(client.wasFrameScrolled()); |
| 5403 EXPECT_FALSE(client.wasProgrammaticScroll()); | 5403 EXPECT_FALSE(view->wasScrolledByUser()); |
| 5404 client.reset(); | 5404 client.reset(); |
| 5405 | 5405 |
| 5406 // Non zero page scale and scroll. | 5406 // Non zero page scale and scroll. |
| 5407 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(9, 13), WebFloatSize(), 0.6f, 0); | 5407 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(9, 13), WebFloatSize(), 0.6f, 0); |
| 5408 EXPECT_TRUE(client.wasUserScroll()); | 5408 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5409 EXPECT_TRUE(view->wasScrolledByUser()); |
| 5409 client.reset(); | 5410 client.reset(); |
| 5411 view->setWasScrolledByUser(false); |
| 5410 | 5412 |
| 5411 // Programmatic scroll. | 5413 // Programmatic scroll. |
| 5412 WebLocalFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); | |
| 5413 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 5414 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
| 5414 EXPECT_FALSE(client.wasUserScroll()); | 5415 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5415 EXPECT_TRUE(client.wasProgrammaticScroll()); | 5416 EXPECT_FALSE(view->wasScrolledByUser()); |
| 5416 client.reset(); | 5417 client.reset(); |
| 5417 | 5418 |
| 5418 // Programmatic scroll to same offset. No scroll event should be generated. | 5419 // Programmatic scroll to same offset. No scroll event should be generated. |
| 5419 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 5420 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
| 5420 EXPECT_FALSE(client.wasProgrammaticScroll()); | 5421 EXPECT_FALSE(client.wasFrameScrolled()); |
| 5421 EXPECT_FALSE(client.wasUserScroll()); | 5422 EXPECT_FALSE(view->wasScrolledByUser()); |
| 5422 client.reset(); | 5423 client.reset(); |
| 5423 } | 5424 } |
| 5424 | 5425 |
| 5425 TEST_F(WebFrameTest, FirstPartyForCookiesForRedirect) | 5426 TEST_F(WebFrameTest, FirstPartyForCookiesForRedirect) |
| 5426 { | 5427 { |
| 5427 WTF::String filePath = Platform::current()->unitTestSupport()->webKitRootDir
(); | 5428 WTF::String filePath = Platform::current()->unitTestSupport()->webKitRootDir
(); |
| 5428 filePath.append("/Source/web/tests/data/first_party.html"); | 5429 filePath.append("/Source/web/tests/data/first_party.html"); |
| 5429 | 5430 |
| 5430 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); | 5431 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); |
| 5431 char redirect[] = "http://internal.test/first_party.html"; | 5432 char redirect[] = "http://internal.test/first_party.html"; |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5939 FrameTestHelpers::loadFrame(frame, | 5940 FrameTestHelpers::loadFrame(frame, |
| 5940 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html
')"); | 5941 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html
')"); |
| 5941 EXPECT_EQ(client.frame(), iframe); | 5942 EXPECT_EQ(client.frame(), iframe); |
| 5942 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 5943 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| 5943 } | 5944 } |
| 5944 | 5945 |
| 5945 // Test verifies that layout will change a layer's scrollable attibutes | 5946 // Test verifies that layout will change a layer's scrollable attibutes |
| 5946 TEST_F(WebFrameTest, overflowHiddenRewrite) | 5947 TEST_F(WebFrameTest, overflowHiddenRewrite) |
| 5947 { | 5948 { |
| 5948 registerMockedHttpURLLoad("non-scrollable.html"); | 5949 registerMockedHttpURLLoad("non-scrollable.html"); |
| 5949 TestMainFrameUserOrProgrammaticScrollFrameClient client; | |
| 5950 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); | 5950 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr
(new FakeCompositingWebViewClient()); |
| 5951 FrameTestHelpers::WebViewHelper webViewHelper; | 5951 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5952 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); | 5952 webViewHelper.initialize(true, 0, fakeCompositingWebViewClient.get(), &confi
gueCompositingWebView); |
| 5953 | 5953 |
| 5954 webViewHelper.webView()->resize(WebSize(100, 100)); | 5954 webViewHelper.webView()->resize(WebSize(100, 100)); |
| 5955 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); | 5955 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), m_baseURL
+ "non-scrollable.html"); |
| 5956 | 5956 |
| 5957 DeprecatedPaintLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); | 5957 DeprecatedPaintLayerCompositor* compositor = webViewHelper.webViewImpl()->c
ompositor(); |
| 5958 ASSERT_TRUE(compositor->scrollLayer()); | 5958 ASSERT_TRUE(compositor->scrollLayer()); |
| 5959 | 5959 |
| (...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7267 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); | 7267 ASSERT_EQ(2u, popupWebFrameClient.messages.size()); |
| 7268 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); | 7268 EXPECT_TRUE(std::string::npos != popupWebFrameClient.messages[1].text.utf8()
.find("Blocked a frame")); |
| 7269 | 7269 |
| 7270 // Manually reset to break WebViewHelpers' dependencies on the stack | 7270 // Manually reset to break WebViewHelpers' dependencies on the stack |
| 7271 // allocated WebFrameClients. | 7271 // allocated WebFrameClients. |
| 7272 webViewHelper.reset(); | 7272 webViewHelper.reset(); |
| 7273 popupWebViewHelper.reset(); | 7273 popupWebViewHelper.reset(); |
| 7274 } | 7274 } |
| 7275 | 7275 |
| 7276 } // namespace blink | 7276 } // namespace blink |
| OLD | NEW |