OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/ScriptController.h" | 5 #include "bindings/core/v8/ScriptController.h" |
6 #include "core/dom/Document.h" | 6 #include "core/dom/Document.h" |
7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/html/HTMLIFrameElement.h" | 10 #include "core/html/HTMLIFrameElement.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 webView().settings()->setJavaScriptEnabled(true); | 624 webView().settings()->setJavaScriptEnabled(true); |
625 EXPECT_EQ(0u, touchHandlerRegionSize()); | 625 EXPECT_EQ(0u, touchHandlerRegionSize()); |
626 | 626 |
627 // Create a frame which is throttled and has two different types of | 627 // Create a frame which is throttled and has two different types of |
628 // top-level touchstart handlers. | 628 // top-level touchstart handlers. |
629 SimRequest mainResource("https://example.com/", "text/html"); | 629 SimRequest mainResource("https://example.com/", "text/html"); |
630 SimRequest frameResource("https://example.com/iframe.html", "text/html"); | 630 SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
631 | 631 |
632 loadURL("https://example.com/"); | 632 loadURL("https://example.com/"); |
633 mainResource.complete("<iframe id=frame sandbox=allow-scripts src=iframe.htm l></iframe>"); | 633 mainResource.complete("<iframe id=frame sandbox=allow-scripts src=iframe.htm l></iframe>"); |
634 frameResource.complete( | 634 frameResource.complete("<body style='touch-action: none'></body>"); |
Rick Byers
2016/07/07 20:02:09
Is using touch-action really better than explicit
dtapuska
2016/07/07 20:34:22
I was trying to future proof it if we move the pas
Rick Byers
2016/07/07 20:45:01
Ah, I see. I think we'll have to think harder abo
| |
635 "<script>" | |
636 "window.addEventListener('touchstart', function(){});" | |
637 "document.addEventListener('touchstart', function(){});" | |
638 "</script>"); | |
639 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")) ; | 635 auto* frameElement = toHTMLIFrameElement(document().getElementById("frame")) ; |
640 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); | 636 frameElement->setAttribute(styleAttr, "transform: translateY(480px)"); |
641 compositeFrame(); // Throttle the frame. | 637 compositeFrame(); // Throttle the frame. |
642 compositeFrame(); // Update touch handler regions. | 638 compositeFrame(); // Update touch handler regions. |
643 | 639 |
644 // The touch handlers in the throttled frame should have been ignored. | 640 // The touch handlers in the throttled frame should have been ignored. |
645 EXPECT_EQ(0u, touchHandlerRegionSize()); | 641 EXPECT_EQ(0u, touchHandlerRegionSize()); |
646 | 642 |
647 // Unthrottling the frame makes the touch handlers active again. Note that | 643 // Unthrottling the frame makes the touch handlers active again. |
648 // both handlers get combined into the same rectangle in the region, so | |
649 // there is only one rectangle in total. | |
650 frameElement->setAttribute(styleAttr, "transform: translateY(0px)"); | 644 frameElement->setAttribute(styleAttr, "transform: translateY(0px)"); |
651 compositeFrame(); // Unthrottle the frame. | 645 compositeFrame(); // Unthrottle the frame. |
652 compositeFrame(); // Update touch handler regions. | 646 compositeFrame(); // Update touch handler regions. |
653 EXPECT_EQ(1u, touchHandlerRegionSize()); | 647 EXPECT_EQ(1u, touchHandlerRegionSize()); |
654 } | 648 } |
655 | 649 |
656 TEST_F(FrameThrottlingTest, ThrottledEventHandlerIgnored) | 650 TEST_F(FrameThrottlingTest, ThrottledEventHandlerIgnored) |
657 { | 651 { |
658 webView().settings()->setAcceleratedCompositingEnabled(true); | 652 webView().settings()->setAcceleratedCompositingEnabled(true); |
659 webView().settings()->setJavaScriptEnabled(true); | 653 webView().settings()->setJavaScriptEnabled(true); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 localFrame->script().executeScriptInMainWorld( | 839 localFrame->script().executeScriptInMainWorld( |
846 "window.requestAnimationFrame(function() {\n" | 840 "window.requestAnimationFrame(function() {\n" |
847 " var throttledFrame = window.parent.frames.first;\n" | 841 " var throttledFrame = window.parent.frames.first;\n" |
848 " throttledFrame.document.documentElement.style = 'margin: 50px';\n" | 842 " throttledFrame.document.documentElement.style = 'margin: 50px';\n" |
849 " throttledFrame.document.querySelector('#d').getBoundingClientRect();\ n" | 843 " throttledFrame.document.querySelector('#d').getBoundingClientRect();\ n" |
850 "});\n"); | 844 "});\n"); |
851 compositeFrame(); | 845 compositeFrame(); |
852 } | 846 } |
853 | 847 |
854 } // namespace blink | 848 } // namespace blink |
OLD | NEW |