| 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 5644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5655 | 5655 |
| 5656 // Make sure we initialize to minimum scale, even if the window size | 5656 // Make sure we initialize to minimum scale, even if the window size |
| 5657 // only becomes available after the load begins. | 5657 // only becomes available after the load begins. |
| 5658 FrameTestHelpers::WebViewHelper webViewHelper; | 5658 FrameTestHelpers::WebViewHelper webViewHelper; |
| 5659 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien
t); | 5659 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, &clien
t); |
| 5660 webViewHelper.resize(WebSize(1000, 1000)); | 5660 webViewHelper.resize(WebSize(1000, 1000)); |
| 5661 | 5661 |
| 5662 WebLocalFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); | 5662 WebLocalFrameImpl* frameImpl = webViewHelper.webViewImpl()->mainFrameImpl(); |
| 5663 DocumentLoader::InitialScrollState& initialScrollState = | 5663 DocumentLoader::InitialScrollState& initialScrollState = |
| 5664 frameImpl->frame()->loader().documentLoader()->initialScrollState(); | 5664 frameImpl->frame()->loader().documentLoader()->initialScrollState(); |
| 5665 GraphicsLayer* frameViewLayer = frameImpl->frameView()->layerForScrolling(); |
| 5665 | 5666 |
| 5666 EXPECT_FALSE(client.wasFrameScrolled()); | 5667 EXPECT_FALSE(client.wasFrameScrolled()); |
| 5667 EXPECT_FALSE(initialScrollState.wasScrolledByUser); | 5668 EXPECT_FALSE(initialScrollState.wasScrolledByUser); |
| 5668 | 5669 |
| 5669 // Do a compositor scroll, verify that this is counted as a user scroll. | 5670 // Do a compositor scroll, verify that this is counted as a user scroll. |
| 5670 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(0, 1), WebFloatSize(), 1.7f, 0); | 5671 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(0, 1
)); |
| 5672 frameViewLayer->didScroll(); |
| 5673 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(), WebFloatSize(), 1.7f, 0); |
| 5671 EXPECT_TRUE(client.wasFrameScrolled()); | 5674 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5672 EXPECT_TRUE(initialScrollState.wasScrolledByUser); | 5675 EXPECT_TRUE(initialScrollState.wasScrolledByUser); |
| 5673 | 5676 |
| 5674 client.reset(); | 5677 client.reset(); |
| 5675 initialScrollState.wasScrolledByUser = false; | 5678 initialScrollState.wasScrolledByUser = false; |
| 5676 | 5679 |
| 5677 // The page scale 1.0f and scroll. | 5680 // The page scale 1.0f and scroll. |
| 5678 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(0, 1), WebFloatSize(), 1.0f, 0); | 5681 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(0, 2
)); |
| 5682 frameViewLayer->didScroll(); |
| 5683 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(), WebFloatSize(), 1.0f, 0); |
| 5679 EXPECT_TRUE(client.wasFrameScrolled()); | 5684 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5680 EXPECT_TRUE(initialScrollState.wasScrolledByUser); | 5685 EXPECT_TRUE(initialScrollState.wasScrolledByUser); |
| 5681 client.reset(); | 5686 client.reset(); |
| 5682 initialScrollState.wasScrolledByUser = false; | 5687 initialScrollState.wasScrolledByUser = false; |
| 5683 | 5688 |
| 5684 // No scroll event if there is no scroll delta. | 5689 // No scroll event if there is no scroll delta. |
| 5690 frameViewLayer->didScroll(); |
| 5685 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(), WebFloatSize(), 1.0f, 0); | 5691 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(), WebFloatSize(), 1.0f, 0); |
| 5686 EXPECT_FALSE(client.wasFrameScrolled()); | 5692 EXPECT_FALSE(client.wasFrameScrolled()); |
| 5687 EXPECT_FALSE(initialScrollState.wasScrolledByUser); | 5693 EXPECT_FALSE(initialScrollState.wasScrolledByUser); |
| 5688 client.reset(); | 5694 client.reset(); |
| 5689 | 5695 |
| 5690 // Non zero page scale and scroll. | 5696 // Non zero page scale and scroll. |
| 5691 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(9, 13), WebFloatSize(), 0.6f, 0); | 5697 frameViewLayer->platformLayer()->setScrollPositionDouble(WebDoublePoint(9, 1
5)); |
| 5698 frameViewLayer->didScroll(); |
| 5699 webViewHelper.webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSiz
e(), WebFloatSize(), 0.6f, 0); |
| 5692 EXPECT_TRUE(client.wasFrameScrolled()); | 5700 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5693 EXPECT_TRUE(initialScrollState.wasScrolledByUser); | 5701 EXPECT_TRUE(initialScrollState.wasScrolledByUser); |
| 5694 client.reset(); | 5702 client.reset(); |
| 5695 initialScrollState.wasScrolledByUser = false; | 5703 initialScrollState.wasScrolledByUser = false; |
| 5696 | 5704 |
| 5697 // Programmatic scroll. | 5705 // Programmatic scroll. |
| 5698 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 5706 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
| 5699 EXPECT_TRUE(client.wasFrameScrolled()); | 5707 EXPECT_TRUE(client.wasFrameScrolled()); |
| 5700 EXPECT_FALSE(initialScrollState.wasScrolledByUser); | 5708 EXPECT_FALSE(initialScrollState.wasScrolledByUser); |
| 5701 client.reset(); | 5709 client.reset(); |
| (...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8844 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 8852 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
| 8845 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); | 8853 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); |
| 8846 | 8854 |
| 8847 // Normally, the result of the JS url replaces the existing contents on the | 8855 // Normally, the result of the JS url replaces the existing contents on the |
| 8848 // Document. However, if the JS triggers a navigation, the contents should | 8856 // Document. However, if the JS triggers a navigation, the contents should |
| 8849 // not be replaced. | 8857 // not be replaced. |
| 8850 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum
ent()->documentElement()->innerText()); | 8858 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum
ent()->documentElement()->innerText()); |
| 8851 } | 8859 } |
| 8852 | 8860 |
| 8853 } // namespace blink | 8861 } // namespace blink |
| OLD | NEW |