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 27 matching lines...) Expand all Loading... |
38 #include "core/frame/FrameHost.h" | 38 #include "core/frame/FrameHost.h" |
39 #include "core/frame/FrameView.h" | 39 #include "core/frame/FrameView.h" |
40 #include "core/frame/LocalFrame.h" | 40 #include "core/frame/LocalFrame.h" |
41 #include "core/frame/PinchViewport.h" | 41 #include "core/frame/PinchViewport.h" |
42 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
43 #include "core/html/HTMLDocument.h" | 43 #include "core/html/HTMLDocument.h" |
44 #include "core/html/HTMLIFrameElement.h" | 44 #include "core/html/HTMLIFrameElement.h" |
45 #include "core/html/HTMLInputElement.h" | 45 #include "core/html/HTMLInputElement.h" |
46 #include "core/html/HTMLTextAreaElement.h" | 46 #include "core/html/HTMLTextAreaElement.h" |
47 #include "core/layout/LayoutView.h" | 47 #include "core/layout/LayoutView.h" |
| 48 #include "core/loader/DocumentLoader.h" |
48 #include "core/loader/FrameLoadRequest.h" | 49 #include "core/loader/FrameLoadRequest.h" |
49 #include "core/page/Chrome.h" | 50 #include "core/page/Chrome.h" |
50 #include "core/page/Page.h" | 51 #include "core/page/Page.h" |
51 #include "core/paint/DeprecatedPaintLayer.h" | 52 #include "core/paint/DeprecatedPaintLayer.h" |
52 #include "core/paint/DeprecatedPaintLayerPainter.h" | 53 #include "core/paint/DeprecatedPaintLayerPainter.h" |
| 54 #include "core/timing/DOMWindowPerformance.h" |
| 55 #include "core/timing/Performance.h" |
| 56 #include "core/timing/PerformanceCompositeTiming.h" |
53 #include "platform/KeyboardCodes.h" | 57 #include "platform/KeyboardCodes.h" |
54 #include "platform/geometry/IntSize.h" | 58 #include "platform/geometry/IntSize.h" |
55 #include "platform/graphics/Color.h" | 59 #include "platform/graphics/Color.h" |
56 #include "platform/testing/URLTestHelpers.h" | 60 #include "platform/testing/URLTestHelpers.h" |
57 #include "platform/testing/UnitTestHelpers.h" | 61 #include "platform/testing/UnitTestHelpers.h" |
58 #include "public/platform/Platform.h" | 62 #include "public/platform/Platform.h" |
59 #include "public/platform/WebClipboard.h" | 63 #include "public/platform/WebClipboard.h" |
60 #include "public/platform/WebDisplayMode.h" | 64 #include "public/platform/WebDisplayMode.h" |
61 #include "public/platform/WebDragData.h" | 65 #include "public/platform/WebDragData.h" |
62 #include "public/platform/WebSize.h" | 66 #include "public/platform/WebSize.h" |
(...skipping 19 matching lines...) Expand all Loading... |
82 #include "third_party/skia/include/core/SkCanvas.h" | 86 #include "third_party/skia/include/core/SkCanvas.h" |
83 #include "web/WebLocalFrameImpl.h" | 87 #include "web/WebLocalFrameImpl.h" |
84 #include "web/WebSettingsImpl.h" | 88 #include "web/WebSettingsImpl.h" |
85 #include "web/WebViewImpl.h" | 89 #include "web/WebViewImpl.h" |
86 #include "web/tests/FrameTestHelpers.h" | 90 #include "web/tests/FrameTestHelpers.h" |
87 #include <gtest/gtest.h> | 91 #include <gtest/gtest.h> |
88 | 92 |
89 using namespace blink; | 93 using namespace blink; |
90 using blink::FrameTestHelpers::loadFrame; | 94 using blink::FrameTestHelpers::loadFrame; |
91 using blink::URLTestHelpers::toKURL; | 95 using blink::URLTestHelpers::toKURL; |
| 96 using blink::URLTestHelpers::registerMockedURLLoad; |
92 using blink::testing::runPendingTasks; | 97 using blink::testing::runPendingTasks; |
93 | 98 |
94 namespace { | 99 namespace { |
95 | 100 |
96 enum HorizontalScrollbarState { | 101 enum HorizontalScrollbarState { |
97 NoHorizontalScrollbar, | 102 NoHorizontalScrollbar, |
98 VisibleHorizontalScrollbar, | 103 VisibleHorizontalScrollbar, |
99 }; | 104 }; |
100 | 105 |
101 enum VerticalScrollbarState { | 106 enum VerticalScrollbarState { |
(...skipping 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2718 | 2723 |
2719 // Test without any preventDefault. | 2724 // Test without any preventDefault. |
2720 client.reset(); | 2725 client.reset(); |
2721 frame->executeScript(WebScriptSource("setTest('none');")); | 2726 frame->executeScript(WebScriptSource("setTest('none');")); |
2722 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 2727 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
2723 EXPECT_TRUE(client.getWasCalled()); | 2728 EXPECT_TRUE(client.getWasCalled()); |
2724 | 2729 |
2725 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2730 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
2726 } | 2731 } |
2727 | 2732 |
| 2733 // Test 3 frames, all on the same layer (i.e. [1 2 3]) |
| 2734 TEST_F(WebViewTest, TestPushFrameTimingRequestRectsToGraphicsLayer1) |
| 2735 { |
| 2736 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; |
| 2737 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2738 url = m_baseURL + "frame_timing_inner.html?200px:200px"; |
| 2739 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2740 url = m_baseURL + "frame_timing_inner.html?300px:300px"; |
| 2741 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2742 url = m_baseURL + "frame_timing_1.html"; |
| 2743 registerMockedURLLoad(toKURL(url), "frame_timing_1.html"); |
| 2744 |
| 2745 WebView* webView = m_webViewHelper.initialize(true); |
| 2746 loadFrame(webView->mainFrame(), url); |
| 2747 |
| 2748 webView->resize(WebSize(800, 600)); |
| 2749 webView->layout(); |
| 2750 |
| 2751 WebViewImpl* webViewImpl = toWebViewImpl(webView); |
| 2752 |
| 2753 Frame* frame = webViewImpl->page()->mainFrame(); |
| 2754 int64_t id = frame->frameID(); |
| 2755 |
| 2756 EXPECT_EQ(3u, frame->tree().childCount()); |
| 2757 |
| 2758 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests = |
| 2759 toLocalFrame(webViewImpl->page()->mainFrame())->document() |
| 2760 ->layoutView()->enclosingLayer() |
| 2761 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| 2762 ->graphicsLayerBacking()->platformLayer()->frameTimingRequests(); |
| 2763 |
| 2764 EXPECT_EQ(4u, frameTimingRequests.size()); |
| 2765 EXPECT_EQ(id + 0, frameTimingRequests[0].first); |
| 2766 EXPECT_EQ(WebRect(0, 0, 800, 600), frameTimingRequests[0].second); |
| 2767 EXPECT_EQ(id + 1, frameTimingRequests[1].first); |
| 2768 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests[1].second); |
| 2769 EXPECT_EQ(id + 2, frameTimingRequests[2].first); |
| 2770 EXPECT_EQ(WebRect(210, 2, 200, 200), frameTimingRequests[2].second); |
| 2771 EXPECT_EQ(id + 3, frameTimingRequests[3].first); |
| 2772 EXPECT_EQ(WebRect(618, 2, 300, 300), frameTimingRequests[3].second); |
| 2773 } |
| 2774 |
| 2775 // Test 3 frames, where frame 2 is on a different GraphicsLayer (i.e. [1 2' 3]) |
| 2776 TEST_F(WebViewTest, TestPushFrameTimingRequestRectsToGraphicsLayer2) |
| 2777 { |
| 2778 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; |
| 2779 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2780 url = m_baseURL + "frame_timing_inner.html?200px:200px"; |
| 2781 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2782 url = m_baseURL + "frame_timing_inner.html?300px:300px"; |
| 2783 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2784 url = m_baseURL + "frame_timing_2.html"; |
| 2785 registerMockedURLLoad(toKURL(url), "frame_timing_2.html"); |
| 2786 |
| 2787 WebView* webView = m_webViewHelper.initialize(true); |
| 2788 loadFrame(webView->mainFrame(), url); |
| 2789 |
| 2790 webView->resize(WebSize(800, 600)); |
| 2791 webView->layout(); |
| 2792 |
| 2793 WebViewImpl* webViewImpl = toWebViewImpl(webView); |
| 2794 |
| 2795 Frame* frame = webViewImpl->page()->mainFrame(); |
| 2796 int64_t id = frame->frameID(); |
| 2797 |
| 2798 EXPECT_EQ(3u, frame->tree().childCount()); |
| 2799 |
| 2800 const WebLayer* graphicsLayer1 = |
| 2801 toLocalFrame(webViewImpl->page()->mainFrame())->document() |
| 2802 ->layoutView()->enclosingLayer() |
| 2803 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| 2804 ->graphicsLayerBacking()->platformLayer(); |
| 2805 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests1 = |
| 2806 graphicsLayer1->frameTimingRequests(); |
| 2807 |
| 2808 EXPECT_EQ(3u, frameTimingRequests1.size()); |
| 2809 EXPECT_EQ(id + 0, frameTimingRequests1[0].first); |
| 2810 EXPECT_EQ(WebRect(0, 0, 800, 600), frameTimingRequests1[0].second); |
| 2811 EXPECT_EQ(id + 1, frameTimingRequests1[1].first); |
| 2812 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests1[1].second); |
| 2813 EXPECT_EQ(id + 3, frameTimingRequests1[2].first); |
| 2814 EXPECT_EQ(WebRect(618, 2, 300, 300), frameTimingRequests1[2].second); |
| 2815 |
| 2816 const WebLayer* graphicsLayer2 = nullptr; |
| 2817 for (Frame* frame = webViewImpl->page()->mainFrame(); frame; |
| 2818 frame = frame->tree().traverseNext()) { |
| 2819 graphicsLayer2 = toLocalFrame(frame)->document()->layoutView() |
| 2820 ->enclosingLayer() |
| 2821 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| 2822 ->graphicsLayerBacking()->platformLayer(); |
| 2823 if (graphicsLayer2 != graphicsLayer1) |
| 2824 break; |
| 2825 } |
| 2826 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests2 = |
| 2827 graphicsLayer2->frameTimingRequests(); |
| 2828 EXPECT_EQ(1u, frameTimingRequests2.size()); |
| 2829 EXPECT_EQ(id + 2, frameTimingRequests2[0].first); |
| 2830 EXPECT_EQ(WebRect(2, 2, 200, 200), frameTimingRequests2[0].second); |
| 2831 } |
| 2832 |
| 2833 |
| 2834 // Test nested frames (i.e. [1 2'[4 5'] 3]) |
| 2835 TEST_F(WebViewTest, TestPushFrameTimingRequestRectsToGraphicsLayer3) |
| 2836 { |
| 2837 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; |
| 2838 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2839 url = m_baseURL + "frame_timing_inner.html?200px:200px"; |
| 2840 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2841 url = m_baseURL + "frame_timing_inner.html?300px:300px"; |
| 2842 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2843 url = m_baseURL + "frame_timing_b.html"; |
| 2844 registerMockedURLLoad(toKURL(url), "frame_timing_b.html"); |
| 2845 url = m_baseURL + "frame_timing_3.html"; |
| 2846 registerMockedURLLoad(toKURL(url), "frame_timing_3.html"); |
| 2847 |
| 2848 WebView* webView = m_webViewHelper.initialize(true); |
| 2849 loadFrame(webView->mainFrame(), url); |
| 2850 |
| 2851 webView->resize(WebSize(800, 600)); |
| 2852 webView->layout(); |
| 2853 |
| 2854 WebViewImpl* webViewImpl = toWebViewImpl(webView); |
| 2855 |
| 2856 Frame* frame = webViewImpl->page()->mainFrame(); |
| 2857 int64_t id = frame->frameID(); |
| 2858 |
| 2859 EXPECT_EQ(3u, frame->tree().childCount()); |
| 2860 |
| 2861 const WebLayer* graphicsLayer1 = |
| 2862 toLocalFrame(webViewImpl->page()->mainFrame())->document() |
| 2863 ->layoutView()->enclosingLayer() |
| 2864 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| 2865 ->graphicsLayerBacking()->platformLayer(); |
| 2866 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests1 = |
| 2867 graphicsLayer1->frameTimingRequests(); |
| 2868 |
| 2869 EXPECT_EQ(3u, frameTimingRequests1.size()); |
| 2870 EXPECT_EQ(id + 0, frameTimingRequests1[0].first); |
| 2871 EXPECT_EQ(WebRect(0, 0, 800, 600), frameTimingRequests1[0].second); |
| 2872 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests1[1].second); |
| 2873 EXPECT_EQ(WebRect(818, 2, 200, 200), frameTimingRequests1[2].second); |
| 2874 |
| 2875 const WebLayer* graphicsLayer2 = nullptr; |
| 2876 for (Frame* frame = webViewImpl->page()->mainFrame(); frame; |
| 2877 frame = frame->tree().traverseNext()) { |
| 2878 graphicsLayer2 = toLocalFrame(frame)->document()->layoutView() |
| 2879 ->enclosingLayer() |
| 2880 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| 2881 ->graphicsLayerBacking()->platformLayer(); |
| 2882 if (graphicsLayer2 != graphicsLayer1) |
| 2883 break; |
| 2884 } |
| 2885 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests2 = |
| 2886 graphicsLayer2->frameTimingRequests(); |
| 2887 EXPECT_EQ(2u, frameTimingRequests2.size()); |
| 2888 EXPECT_EQ(WebRect(0, 0, 300, 300), frameTimingRequests2[0].second); |
| 2889 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests2[1].second); |
| 2890 |
| 2891 const WebLayer* graphicsLayer3 = nullptr; |
| 2892 for (Frame* frame = webViewImpl->page()->mainFrame(); frame; |
| 2893 frame = frame->tree().traverseNext()) { |
| 2894 graphicsLayer3 = toLocalFrame(frame)->document()->layoutView() |
| 2895 ->enclosingLayer() |
| 2896 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
| 2897 ->graphicsLayerBacking()->platformLayer(); |
| 2898 if (graphicsLayer3 != graphicsLayer1 && graphicsLayer3 != graphicsLayer2
) |
| 2899 break; |
| 2900 } |
| 2901 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests3 = |
| 2902 graphicsLayer3->frameTimingRequests(); |
| 2903 EXPECT_EQ(1u, frameTimingRequests3.size()); |
| 2904 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests3[0].second); |
| 2905 } |
| 2906 |
| 2907 // Test 3 frames, all on the same layer (i.e. [1 2 3]) |
| 2908 TEST_F(WebViewTest, TestRecordFrameTimingEvents) |
| 2909 { |
| 2910 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; |
| 2911 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2912 url = m_baseURL + "frame_timing_inner.html?200px:200px"; |
| 2913 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2914 url = m_baseURL + "frame_timing_inner.html?300px:300px"; |
| 2915 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); |
| 2916 url = m_baseURL + "frame_timing_1.html"; |
| 2917 registerMockedURLLoad(toKURL(url), "frame_timing_1.html"); |
| 2918 |
| 2919 WebView* webView = m_webViewHelper.initialize(true); |
| 2920 loadFrame(webView->mainFrame(), url); |
| 2921 |
| 2922 webView->resize(WebSize(800, 600)); |
| 2923 webView->layout(); |
| 2924 |
| 2925 WebViewImpl* webViewImpl = toWebViewImpl(webView); |
| 2926 |
| 2927 Frame* frame = webViewImpl->page()->mainFrame(); |
| 2928 int64_t id = frame->frameID(); |
| 2929 |
| 2930 std::vector<std::pair<int, double>> compositePairs = { |
| 2931 std::make_pair(1, 2.0), std::make_pair(2, 3.0), std::make_pair(3, 4.0) |
| 2932 }; |
| 2933 WebVector<std::pair<int, double>> compositeEvents(compositePairs); |
| 2934 webViewImpl->recordFrameTimingEvent(WebView::CompositeEvent, id, compositeEv
ents); |
| 2935 PerformanceEntryVector composites = DOMWindowPerformance::performance(*frame
->domWindow())->getEntriesByType("composite"); |
| 2936 PerformanceEntryVector renders = DOMWindowPerformance::performance(*frame->d
omWindow())->getEntriesByType("render"); |
| 2937 ASSERT_EQ(3ul, composites.size()); |
| 2938 ASSERT_EQ(0ul, renders.size()); |
| 2939 for (size_t i = 0; i < composites.size(); ++i) { |
| 2940 double docTime = frame->domWindow()->document()->loader()->timing().mono
tonicTimeToZeroBasedDocumentTime(compositePairs[i].second) * 1000.0; |
| 2941 ASSERT_EQ(docTime, composites[i]->startTime()); |
| 2942 } |
| 2943 |
| 2944 // Skip ahead to subframe 2. |
| 2945 frame = frame->tree().traverseNext(); |
| 2946 frame = frame->tree().traverseNext(); |
| 2947 id += 2; |
| 2948 |
| 2949 std::vector<std::pair<int, double>> renderPairs = { |
| 2950 std::make_pair(4, 5.0), std::make_pair(5, 6.0), std::make_pair(6, 7.0), |
| 2951 std::make_pair(7, 8.0) }; |
| 2952 WebVector<std::pair<int, double>> renderEvents(renderPairs); |
| 2953 webViewImpl->recordFrameTimingEvent(WebView::RenderEvent, id, renderEvents); |
| 2954 composites = DOMWindowPerformance::performance(*frame->domWindow())->getEntr
iesByType("composite"); |
| 2955 renders = DOMWindowPerformance::performance(*frame->domWindow())->getEntries
ByType("render"); |
| 2956 ASSERT_EQ(0ul, composites.size()); |
| 2957 ASSERT_EQ(4ul, renders.size()); |
| 2958 for (size_t i = 0; i < renders.size(); ++i) { |
| 2959 double docTime = frame->domWindow()->document()->loader()->timing().mono
tonicTimeToZeroBasedDocumentTime(renderPairs[i].second) * 1000.0; |
| 2960 ASSERT_DOUBLE_EQ(docTime, renders[i]->startTime()); |
| 2961 } |
| 2962 } |
| 2963 |
2728 } // namespace | 2964 } // namespace |
OLD | NEW |