| 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 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 | 2987 |
| 2988 // Test without any preventDefault. | 2988 // Test without any preventDefault. |
| 2989 client.reset(); | 2989 client.reset(); |
| 2990 frame->executeScript(WebScriptSource("setTest('none');")); | 2990 frame->executeScript(WebScriptSource("setTest('none');")); |
| 2991 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); | 2991 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, WebString::fromUTF8("t
arget"))); |
| 2992 EXPECT_TRUE(client.getWasCalled()); | 2992 EXPECT_TRUE(client.getWasCalled()); |
| 2993 | 2993 |
| 2994 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2994 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
| 2995 } | 2995 } |
| 2996 | 2996 |
| 2997 // Test 3 frames, all on the same layer (i.e. [1 2 3]) | |
| 2998 TEST_F(WebViewTest, TestPushFrameTimingRequestRectsToGraphicsLayer1) | |
| 2999 { | |
| 3000 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; | |
| 3001 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3002 url = m_baseURL + "frame_timing_inner.html?200px:200px"; | |
| 3003 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3004 url = m_baseURL + "frame_timing_inner.html?300px:300px"; | |
| 3005 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3006 url = m_baseURL + "frame_timing_1.html"; | |
| 3007 registerMockedURLLoad(toKURL(url), "frame_timing_1.html"); | |
| 3008 | |
| 3009 WebView* webView = m_webViewHelper.initialize(true); | |
| 3010 loadFrame(webView->mainFrame(), url); | |
| 3011 | |
| 3012 webView->resize(WebSize(800, 600)); | |
| 3013 webView->updateAllLifecyclePhases(); | |
| 3014 | |
| 3015 WebViewImpl* webViewImpl = toWebViewImpl(webView); | |
| 3016 | |
| 3017 Frame* frame = webViewImpl->page()->mainFrame(); | |
| 3018 int64_t id = frame->frameID(); | |
| 3019 | |
| 3020 EXPECT_EQ(3u, frame->tree().childCount()); | |
| 3021 | |
| 3022 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests = | |
| 3023 toLocalFrame(frame)->document() | |
| 3024 ->layoutView()->enclosingLayer() | |
| 3025 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() | |
| 3026 ->graphicsLayerBacking()->platformLayer()->frameTimingRequests(); | |
| 3027 | |
| 3028 EXPECT_EQ(4u, frameTimingRequests.size()); | |
| 3029 EXPECT_EQ(id + 0, frameTimingRequests[0].first); | |
| 3030 EXPECT_EQ(WebRect(0, 0, 800, 600), frameTimingRequests[0].second); | |
| 3031 EXPECT_EQ(id + 1, frameTimingRequests[1].first); | |
| 3032 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests[1].second); | |
| 3033 EXPECT_EQ(id + 2, frameTimingRequests[2].first); | |
| 3034 EXPECT_EQ(WebRect(106, 2, 200, 200), frameTimingRequests[2].second); | |
| 3035 EXPECT_EQ(id + 3, frameTimingRequests[3].first); | |
| 3036 EXPECT_EQ(WebRect(310, 2, 300, 300), frameTimingRequests[3].second); | |
| 3037 } | |
| 3038 | |
| 3039 // Test 3 frames, where frame 2 is on a different GraphicsLayer (i.e. [1 2' 3]) | |
| 3040 TEST_F(WebViewTest, TestPushFrameTimingRequestRectsToGraphicsLayer2) | |
| 3041 { | |
| 3042 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; | |
| 3043 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3044 url = m_baseURL + "frame_timing_inner.html?200px:200px"; | |
| 3045 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3046 url = m_baseURL + "frame_timing_inner.html?300px:300px"; | |
| 3047 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3048 url = m_baseURL + "frame_timing_2.html"; | |
| 3049 registerMockedURLLoad(toKURL(url), "frame_timing_2.html"); | |
| 3050 | |
| 3051 WebView* webView = m_webViewHelper.initialize(true); | |
| 3052 loadFrame(webView->mainFrame(), url); | |
| 3053 | |
| 3054 webView->resize(WebSize(800, 600)); | |
| 3055 webView->updateAllLifecyclePhases(); | |
| 3056 | |
| 3057 WebViewImpl* webViewImpl = toWebViewImpl(webView); | |
| 3058 | |
| 3059 Frame* frame = webViewImpl->page()->mainFrame(); | |
| 3060 int64_t id = frame->frameID(); | |
| 3061 | |
| 3062 EXPECT_EQ(3u, frame->tree().childCount()); | |
| 3063 | |
| 3064 const WebLayer* graphicsLayer1 = | |
| 3065 toLocalFrame(webViewImpl->page()->mainFrame())->document() | |
| 3066 ->layoutView()->enclosingLayer() | |
| 3067 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() | |
| 3068 ->graphicsLayerBacking()->platformLayer(); | |
| 3069 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests1 = | |
| 3070 graphicsLayer1->frameTimingRequests(); | |
| 3071 | |
| 3072 EXPECT_EQ(3u, frameTimingRequests1.size()); | |
| 3073 EXPECT_EQ(id + 0, frameTimingRequests1[0].first); | |
| 3074 EXPECT_EQ(WebRect(0, 0, 800, 600), frameTimingRequests1[0].second); | |
| 3075 EXPECT_EQ(id + 1, frameTimingRequests1[1].first); | |
| 3076 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests1[1].second); | |
| 3077 EXPECT_EQ(id + 3, frameTimingRequests1[2].first); | |
| 3078 EXPECT_EQ(WebRect(310, 2, 300, 300), frameTimingRequests1[2].second); | |
| 3079 | |
| 3080 const WebLayer* graphicsLayer2 = nullptr; | |
| 3081 for (Frame* frame = webViewImpl->page()->mainFrame(); frame; | |
| 3082 frame = frame->tree().traverseNext()) { | |
| 3083 graphicsLayer2 = toLocalFrame(frame)->document()->layoutView() | |
| 3084 ->enclosingLayer() | |
| 3085 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() | |
| 3086 ->graphicsLayerBacking()->platformLayer(); | |
| 3087 if (graphicsLayer2 != graphicsLayer1) | |
| 3088 break; | |
| 3089 } | |
| 3090 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests2 = | |
| 3091 graphicsLayer2->frameTimingRequests(); | |
| 3092 EXPECT_EQ(1u, frameTimingRequests2.size()); | |
| 3093 EXPECT_EQ(id + 2, frameTimingRequests2[0].first); | |
| 3094 EXPECT_EQ(WebRect(2, 2, 200, 200), frameTimingRequests2[0].second); | |
| 3095 } | |
| 3096 | |
| 3097 | |
| 3098 // Test nested frames (i.e. [1 2'[4 5'] 3]) | |
| 3099 TEST_F(WebViewTest, TestPushFrameTimingRequestRectsToGraphicsLayer3) | |
| 3100 { | |
| 3101 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; | |
| 3102 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3103 url = m_baseURL + "frame_timing_inner.html?200px:200px"; | |
| 3104 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3105 url = m_baseURL + "frame_timing_inner.html?300px:300px"; | |
| 3106 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3107 url = m_baseURL + "frame_timing_b.html"; | |
| 3108 registerMockedURLLoad(toKURL(url), "frame_timing_b.html"); | |
| 3109 url = m_baseURL + "frame_timing_3.html"; | |
| 3110 registerMockedURLLoad(toKURL(url), "frame_timing_3.html"); | |
| 3111 | |
| 3112 WebView* webView = m_webViewHelper.initialize(true); | |
| 3113 loadFrame(webView->mainFrame(), url); | |
| 3114 | |
| 3115 webView->resize(WebSize(800, 600)); | |
| 3116 webView->updateAllLifecyclePhases(); | |
| 3117 | |
| 3118 WebViewImpl* webViewImpl = toWebViewImpl(webView); | |
| 3119 | |
| 3120 Frame* frame = webViewImpl->page()->mainFrame(); | |
| 3121 int64_t id = frame->frameID(); | |
| 3122 | |
| 3123 EXPECT_EQ(3u, frame->tree().childCount()); | |
| 3124 | |
| 3125 const WebLayer* graphicsLayer1 = | |
| 3126 toLocalFrame(webViewImpl->page()->mainFrame())->document() | |
| 3127 ->layoutView()->enclosingLayer() | |
| 3128 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() | |
| 3129 ->graphicsLayerBacking()->platformLayer(); | |
| 3130 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests1 = | |
| 3131 graphicsLayer1->frameTimingRequests(); | |
| 3132 | |
| 3133 EXPECT_EQ(3u, frameTimingRequests1.size()); | |
| 3134 EXPECT_EQ(id + 0, frameTimingRequests1[0].first); | |
| 3135 EXPECT_EQ(WebRect(0, 0, 800, 600), frameTimingRequests1[0].second); | |
| 3136 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests1[1].second); | |
| 3137 EXPECT_EQ(WebRect(410, 2, 200, 200), frameTimingRequests1[2].second); | |
| 3138 | |
| 3139 const WebLayer* graphicsLayer2 = nullptr; | |
| 3140 for (Frame* frame = webViewImpl->page()->mainFrame(); frame; | |
| 3141 frame = frame->tree().traverseNext()) { | |
| 3142 graphicsLayer2 = toLocalFrame(frame)->document()->layoutView() | |
| 3143 ->enclosingLayer() | |
| 3144 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() | |
| 3145 ->graphicsLayerBacking()->platformLayer(); | |
| 3146 if (graphicsLayer2 != graphicsLayer1) | |
| 3147 break; | |
| 3148 } | |
| 3149 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests2 = | |
| 3150 graphicsLayer2->frameTimingRequests(); | |
| 3151 EXPECT_EQ(2u, frameTimingRequests2.size()); | |
| 3152 EXPECT_EQ(WebRect(0, 0, 300, 300), frameTimingRequests2[0].second); | |
| 3153 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests2[1].second); | |
| 3154 | |
| 3155 const WebLayer* graphicsLayer3 = nullptr; | |
| 3156 for (Frame* frame = webViewImpl->page()->mainFrame(); frame; | |
| 3157 frame = frame->tree().traverseNext()) { | |
| 3158 graphicsLayer3 = toLocalFrame(frame)->document()->layoutView() | |
| 3159 ->enclosingLayer() | |
| 3160 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() | |
| 3161 ->graphicsLayerBacking()->platformLayer(); | |
| 3162 if (graphicsLayer3 != graphicsLayer1 && graphicsLayer3 != graphicsLayer2
) | |
| 3163 break; | |
| 3164 } | |
| 3165 WebVector<std::pair<int64_t, WebRect>> frameTimingRequests3 = | |
| 3166 graphicsLayer3->frameTimingRequests(); | |
| 3167 EXPECT_EQ(1u, frameTimingRequests3.size()); | |
| 3168 EXPECT_EQ(WebRect(2, 2, 100, 100), frameTimingRequests3[0].second); | |
| 3169 } | |
| 3170 | |
| 3171 // Test 3 frames, all on the same layer (i.e. [1 2 3]) | |
| 3172 // Fails on android, see crbug.com/488381. | |
| 3173 #if OS(ANDROID) | |
| 3174 TEST_F(WebViewTest, DISABLED_TestRecordFrameTimingEvents) | |
| 3175 #else | |
| 3176 TEST_F(WebViewTest, TestRecordFrameTimingEvents) | |
| 3177 #endif | |
| 3178 { | |
| 3179 std::string url = m_baseURL + "frame_timing_inner.html?100px:100px"; | |
| 3180 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3181 url = m_baseURL + "frame_timing_inner.html?200px:200px"; | |
| 3182 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3183 url = m_baseURL + "frame_timing_inner.html?300px:300px"; | |
| 3184 registerMockedURLLoad(toKURL(url), "frame_timing_inner.html"); | |
| 3185 url = m_baseURL + "frame_timing_1.html"; | |
| 3186 registerMockedURLLoad(toKURL(url), "frame_timing_1.html"); | |
| 3187 | |
| 3188 WebView* webView = m_webViewHelper.initialize(true); | |
| 3189 loadFrame(webView->mainFrame(), url); | |
| 3190 | |
| 3191 webView->resize(WebSize(800, 600)); | |
| 3192 webView->updateAllLifecyclePhases(); | |
| 3193 | |
| 3194 WebViewImpl* webViewImpl = toWebViewImpl(webView); | |
| 3195 | |
| 3196 Frame* frame = webViewImpl->page()->mainFrame(); | |
| 3197 int64_t id = frame->frameID(); | |
| 3198 | |
| 3199 Vector<WebFrameTimingEvent> compositePairs; | |
| 3200 compositePairs.append(WebFrameTimingEvent(1, 2.0)); | |
| 3201 compositePairs.append(WebFrameTimingEvent(2, 3.0)); | |
| 3202 compositePairs.append(WebFrameTimingEvent(3, 4.0)); | |
| 3203 WebVector<WebFrameTimingEvent> compositeEvents(compositePairs); | |
| 3204 webViewImpl->recordFrameTimingEvent(WebView::CompositeEvent, id, compositeEv
ents); | |
| 3205 PerformanceEntryVector composites = DOMWindowPerformance::performance(*frame
->domWindow())->getEntriesByType("composite"); | |
| 3206 PerformanceEntryVector renders = DOMWindowPerformance::performance(*frame->d
omWindow())->getEntriesByType("render"); | |
| 3207 ASSERT_EQ(3ul, composites.size()); | |
| 3208 ASSERT_EQ(0ul, renders.size()); | |
| 3209 for (size_t i = 0; i < composites.size(); ++i) { | |
| 3210 double docTime = frame->domWindow()->document()->loader()->timing().mono
tonicTimeToZeroBasedDocumentTime(compositePairs[i].startTime) * 1000.0; | |
| 3211 ASSERT_EQ(docTime, composites[i]->startTime()); | |
| 3212 } | |
| 3213 | |
| 3214 // Skip ahead to subframe 2. | |
| 3215 frame = frame->tree().traverseNext(); | |
| 3216 frame = frame->tree().traverseNext(); | |
| 3217 id += 2; | |
| 3218 | |
| 3219 Vector<WebFrameTimingEvent> renderPairs; | |
| 3220 renderPairs.append(WebFrameTimingEvent(4, 5.0, 6.0)); | |
| 3221 renderPairs.append(WebFrameTimingEvent(5, 6.0, 7.0)); | |
| 3222 renderPairs.append(WebFrameTimingEvent(6, 7.0, 8.0)); | |
| 3223 renderPairs.append(WebFrameTimingEvent(7, 8.0, 9.0)); | |
| 3224 WebVector<WebFrameTimingEvent> renderEvents(renderPairs); | |
| 3225 webViewImpl->recordFrameTimingEvent(WebView::RenderEvent, id, renderEvents); | |
| 3226 composites = DOMWindowPerformance::performance(*frame->domWindow())->getEntr
iesByType("composite"); | |
| 3227 renders = DOMWindowPerformance::performance(*frame->domWindow())->getEntries
ByType("render"); | |
| 3228 ASSERT_EQ(0ul, composites.size()); | |
| 3229 ASSERT_EQ(4ul, renders.size()); | |
| 3230 for (size_t i = 0; i < renders.size(); ++i) { | |
| 3231 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; | |
| 3232 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); | |
| 3233 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; | |
| 3234 double docDuration = docFinishTime - docStartTime; | |
| 3235 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); | |
| 3236 } | |
| 3237 } | |
| 3238 | |
| 3239 | |
| 3240 TEST_F(WebViewTest, StopLoadingIfJavaScriptURLReturnsNoStringResult) | 2997 TEST_F(WebViewTest, StopLoadingIfJavaScriptURLReturnsNoStringResult) |
| 3241 { | 2998 { |
| 3242 ViewCreatingWebViewClient client; | 2999 ViewCreatingWebViewClient client; |
| 3243 FrameTestHelpers::WebViewHelper mainWebView; | 3000 FrameTestHelpers::WebViewHelper mainWebView; |
| 3244 mainWebView.initializeAndLoad("about:blank", true, 0, &client); | 3001 mainWebView.initializeAndLoad("about:blank", true, 0, &client); |
| 3245 mainWebView.webViewImpl()->page()->settings().setJavaScriptCanOpenWindowsAut
omatically(true); | 3002 mainWebView.webViewImpl()->page()->settings().setJavaScriptCanOpenWindowsAut
omatically(true); |
| 3246 | 3003 |
| 3247 WebFrame* frame = mainWebView.webView()->mainFrame(); | 3004 WebFrame* frame = mainWebView.webView()->mainFrame(); |
| 3248 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3005 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 3249 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS
ource("var win = window.open('javascript:false'); win.document")); | 3006 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS
ource("var win = window.open('javascript:false'); win.document")); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3291 frame->setAutofillClient(&client); | 3048 frame->setAutofillClient(&client); |
| 3292 webView->setInitialFocus(false); | 3049 webView->setInitialFocus(false); |
| 3293 | 3050 |
| 3294 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); | 3051 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel
lo").c_str()))); |
| 3295 EXPECT_EQ(1, client.textChangesFromUserGesture()); | 3052 EXPECT_EQ(1, client.textChangesFromUserGesture()); |
| 3296 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); | 3053 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); |
| 3297 frame->setAutofillClient(0); | 3054 frame->setAutofillClient(0); |
| 3298 } | 3055 } |
| 3299 | 3056 |
| 3300 } // namespace blink | 3057 } // namespace blink |
| OLD | NEW |