Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: third_party/WebKit/Source/web/tests/DeferredLoadingTest.cpp

Issue 2516473002: Cross-origin iframes: collect data under hypothetical loading strategies (Closed)
Patch Set: just look below Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/testing/HistogramTester.h" 5 #include "platform/testing/HistogramTester.h"
6 #include "platform/testing/UnitTestHelpers.h" 6 #include "platform/testing/UnitTestHelpers.h"
7 #include "web/WebViewImpl.h" 7 #include "web/WebViewImpl.h"
8 #include "web/tests/sim/SimCompositor.h" 8 #include "web/tests/sim/SimCompositor.h"
9 #include "web/tests/sim/SimDisplayItemList.h" 9 #include "web/tests/sim/SimDisplayItemList.h"
10 #include "web/tests/sim/SimRequest.h" 10 #include "web/tests/sim/SimRequest.h"
11 #include "web/tests/sim/SimTest.h" 11 #include "web/tests/sim/SimTest.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 static const char* kHistogramName = 15 static const char* kHistogramName =
16 "Navigation.DeferredDocumentLoading.StatesV3"; 16 "Navigation.DeferredDocumentLoading.StatesV4";
17 17
18 class DeferredLoadingTest : public SimTest { 18 class DeferredLoadingTest : public SimTest {
19 protected: 19 protected:
20 DeferredLoadingTest() { webView().resize(WebSize(640, 480)); } 20 DeferredLoadingTest() { webView().resize(WebSize(640, 480)); }
21 void compositeFrame() { 21 void compositeFrame() {
22 compositor().beginFrame(); 22 while (compositor().needsBeginFrame()) {
23 testing::runPendingTasks(); 23 compositor().beginFrame();
24 if (compositor().needsBeginFrame()) 24 testing::runPendingTasks();
25 compositor().beginFrame(); // VisibleNestedInRight doesn't need this. 25 }
26 ASSERT_FALSE(compositor().needsBeginFrame());
27 } 26 }
28 27
29 std::unique_ptr<SimRequest> createMainResource() { 28 std::unique_ptr<SimRequest> createMainResource() {
30 std::unique_ptr<SimRequest> mainResource = 29 std::unique_ptr<SimRequest> mainResource =
31 wrapUnique(new SimRequest("https://example.com/", "text/html")); 30 wrapUnique(new SimRequest("https://example.com/", "text/html"));
32 loadURL("https://example.com/"); 31 loadURL("https://example.com/");
33 return mainResource; 32 return mainResource;
34 } 33 }
35 }; 34 };
36 35
37 TEST_F(DeferredLoadingTest, Visible) { 36 TEST_F(DeferredLoadingTest, Visible) {
38 HistogramTester histogramTester; 37 HistogramTester histogramTester;
39 std::unique_ptr<SimRequest> mainResource = createMainResource(); 38 std::unique_ptr<SimRequest> mainResource = createMainResource();
40 39
41 mainResource->complete("<iframe sandbox></iframe>"); 40 mainResource->complete("<iframe sandbox></iframe>");
42 41
43 compositeFrame(); 42 compositeFrame();
44 43
45 histogramTester.expectBucketCount(kHistogramName, Created, 1); 44 histogramTester.expectBucketCount(kHistogramName, Created, 1);
46 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1); 45 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
46 histogramTester.expectBucketCount(kHistogramName, WouldLoad1ScreenAway, 1);
47 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
48 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 1);
49 histogramTester.expectTotalCount(kHistogramName, 5);
47 } 50 }
48 51
49 TEST_F(DeferredLoadingTest, Right) { 52 TEST_F(DeferredLoadingTest, Right) {
50 HistogramTester histogramTester; 53 HistogramTester histogramTester;
51 std::unique_ptr<SimRequest> mainResource = createMainResource(); 54 std::unique_ptr<SimRequest> mainResource = createMainResource();
52 55
53 mainResource->complete( 56 mainResource->complete(
54 "<iframe style='position:absolute; left:105vw;' sandbox></iframe>"); 57 "<iframe style='position:absolute; left:105vw;' sandbox></iframe>");
55 58
56 compositeFrame(); 59 compositeFrame();
57 60
58 histogramTester.expectBucketCount(kHistogramName, Created, 1); 61 histogramTester.expectBucketCount(kHistogramName, Created, 1);
59 histogramTester.expectTotalCount(kHistogramName, 1); 62 histogramTester.expectTotalCount(kHistogramName, 1);
60 } 63 }
61 64
62 TEST_F(DeferredLoadingTest, Below) { 65 TEST_F(DeferredLoadingTest, TwoScreensBelow) {
63 HistogramTester histogramTester; 66 HistogramTester histogramTester;
64 std::unique_ptr<SimRequest> mainResource = createMainResource(); 67 std::unique_ptr<SimRequest> mainResource = createMainResource();
65 68
66 mainResource->complete( 69 mainResource->complete(
67 "<iframe style='position:absolute; top:105vh;' sandbox></iframe>"); 70 "<iframe style='position:absolute; top:205vh;' sandbox></iframe>");
68 71
69 compositeFrame(); 72 compositeFrame();
70 73
71 histogramTester.expectBucketCount(kHistogramName, Created, 1); 74 histogramTester.expectBucketCount(kHistogramName, Created, 1);
72 histogramTester.expectTotalCount(kHistogramName, 1); 75 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
76 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 1);
77 histogramTester.expectTotalCount(kHistogramName, 3);
73 } 78 }
74 79
75 TEST_F(DeferredLoadingTest, Above) { 80 TEST_F(DeferredLoadingTest, Above) {
76 HistogramTester histogramTester; 81 HistogramTester histogramTester;
77 std::unique_ptr<SimRequest> mainResource = createMainResource(); 82 std::unique_ptr<SimRequest> mainResource = createMainResource();
78 83
79 mainResource->complete( 84 mainResource->complete(
80 "<iframe style='position:absolute; top:-10000px;' sandbox></iframe>"); 85 "<iframe style='position:absolute; top:-10000px;' sandbox></iframe>");
81 86
82 compositeFrame(); 87 compositeFrame();
83 88
84 histogramTester.expectBucketCount(kHistogramName, Created, 1); 89 histogramTester.expectBucketCount(kHistogramName, Created, 1);
85 histogramTester.expectBucketCount(kHistogramName, WouldLoadAbove, 1); 90 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
91 histogramTester.expectBucketCount(kHistogramName, WouldLoad1ScreenAway, 1);
92 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
93 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 1);
94 histogramTester.expectTotalCount(kHistogramName, 5);
86 } 95 }
87 96
88 TEST_F(DeferredLoadingTest, Left) { 97 TEST_F(DeferredLoadingTest, Left) {
89 HistogramTester histogramTester; 98 HistogramTester histogramTester;
90 std::unique_ptr<SimRequest> mainResource = createMainResource(); 99 std::unique_ptr<SimRequest> mainResource = createMainResource();
91 100
92 mainResource->complete( 101 mainResource->complete(
93 "<iframe style='position:absolute; left:-10000px;' sandbox></iframe>"); 102 "<iframe style='position:absolute; left:-10000px;' sandbox></iframe>");
94 103
95 compositeFrame(); 104 compositeFrame();
96 105
97 histogramTester.expectBucketCount(kHistogramName, Created, 1); 106 histogramTester.expectBucketCount(kHistogramName, Created, 1);
98 histogramTester.expectBucketCount(kHistogramName, WouldLoadLeft, 1); 107 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
108 histogramTester.expectBucketCount(kHistogramName, WouldLoad1ScreenAway, 1);
109 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
110 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 1);
111 histogramTester.expectTotalCount(kHistogramName, 5);
99 } 112 }
100 113
101 TEST_F(DeferredLoadingTest, AboveAndLeft) { 114 TEST_F(DeferredLoadingTest, AboveAndLeft) {
102 HistogramTester histogramTester; 115 HistogramTester histogramTester;
103 std::unique_ptr<SimRequest> mainResource = createMainResource(); 116 std::unique_ptr<SimRequest> mainResource = createMainResource();
104 117
105 mainResource->complete( 118 mainResource->complete(
106 "<iframe style='position:absolute; left:-10000px; top:-10000px' sandbox>" 119 "<iframe style='position:absolute; left:-10000px; top:-10000px' sandbox>"
107 "</iframe>"); 120 "</iframe>");
108 121
109 compositeFrame(); 122 compositeFrame();
110 123
111 histogramTester.expectBucketCount(kHistogramName, Created, 1); 124 histogramTester.expectBucketCount(kHistogramName, Created, 1);
112 histogramTester.expectBucketCount(kHistogramName, WouldLoadAboveAndLeft, 1); 125 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
113 histogramTester.expectTotalCount(kHistogramName, 2); 126 histogramTester.expectTotalCount(kHistogramName, 5);
114 } 127 }
115 128
116 TEST_F(DeferredLoadingTest, ZeroByZero) { 129 TEST_F(DeferredLoadingTest, ZeroByZero) {
117 HistogramTester histogramTester; 130 HistogramTester histogramTester;
118 std::unique_ptr<SimRequest> mainResource = createMainResource(); 131 std::unique_ptr<SimRequest> mainResource = createMainResource();
119 132
120 mainResource->complete( 133 mainResource->complete(
121 "<iframe style='height:0px;width:0px;' sandbox></iframe>"); 134 "<iframe style='height:0px;width:0px;' sandbox></iframe>");
122 135
123 compositeFrame(); 136 compositeFrame();
124 137
125 histogramTester.expectBucketCount(kHistogramName, Created, 1); 138 histogramTester.expectBucketCount(kHistogramName, Created, 1);
126 histogramTester.expectBucketCount(kHistogramName, WouldLoadZeroByZero, 1); 139 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
127 } 140 }
128 141
129 TEST_F(DeferredLoadingTest, DisplayNone) { 142 TEST_F(DeferredLoadingTest, DisplayNone) {
130 HistogramTester histogramTester; 143 HistogramTester histogramTester;
131 std::unique_ptr<SimRequest> mainResource = createMainResource(); 144 std::unique_ptr<SimRequest> mainResource = createMainResource();
132 145
133 mainResource->complete("<iframe style='display:none' sandbox></iframe>"); 146 mainResource->complete("<iframe style='display:none' sandbox></iframe>");
134 147
135 compositeFrame(); 148 compositeFrame();
136 149
137 histogramTester.expectBucketCount(kHistogramName, Created, 1); 150 histogramTester.expectBucketCount(kHistogramName, Created, 1);
138 histogramTester.expectBucketCount(kHistogramName, WouldLoadDisplayNone, 1); 151 histogramTester.expectBucketCount(kHistogramName, WouldLoadNoParent, 1);
152 histogramTester.expectTotalCount(kHistogramName, 6);
139 } 153 }
140 154
141 TEST_F(DeferredLoadingTest, VisibleNestedInRight) { 155 TEST_F(DeferredLoadingTest, DisplayNoneIn2ScreensBelow) {
142 HistogramTester histogramTester; 156 HistogramTester histogramTester;
143 std::unique_ptr<SimRequest> mainResource = createMainResource(); 157 std::unique_ptr<SimRequest> mainResource = createMainResource();
144 SimRequest frameResource("https://example.com/iframe.html", "text/html"); 158 SimRequest frameResource("https://example.com/iframe.html", "text/html");
145 159
146 mainResource->complete( 160 mainResource->complete(
147 "<iframe style='position:absolute; left:105vw;' src='iframe.html' " 161 "<iframe style='position:absolute; top:205vh' "
148 "sandbox></iframe>"); 162 "src='iframe.html' sandbox></iframe>");
149 frameResource.complete("<iframe sandbox></iframe>"); 163 frameResource.complete("<iframe style='display:none' sandbox></iframe>");
150 164
151 compositeFrame(); 165 compositeFrame();
152 166
153 histogramTester.expectBucketCount(kHistogramName, Created, 2); 167 histogramTester.expectBucketCount(kHistogramName, Created, 2);
154 histogramTester.expectTotalCount(kHistogramName, 2); 168 histogramTester.expectBucketCount(kHistogramName, WouldLoadNoParent, 1);
169 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
170 histogramTester.expectBucketCount(kHistogramName, WouldLoad1ScreenAway, 1);
171 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 2);
172 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 2);
173 histogramTester.expectTotalCount(kHistogramName, 9);
155 } 174 }
156 175
157 TEST_F(DeferredLoadingTest, LeftNestedInBelow) { 176 TEST_F(DeferredLoadingTest, LeftNestedInBelow) {
158 HistogramTester histogramTester; 177 HistogramTester histogramTester;
159 std::unique_ptr<SimRequest> mainResource = createMainResource(); 178 std::unique_ptr<SimRequest> mainResource = createMainResource();
160 SimRequest frameResource("https://example.com/iframe.html", "text/html"); 179 SimRequest frameResource("https://example.com/iframe.html", "text/html");
161 180
162 mainResource->complete( 181 mainResource->complete(
163 "<iframe style='position:absolute; top:105vh;' src='iframe.html' " 182 "<iframe style='position:absolute; top:105vh;' src='iframe.html' "
164 "sandbox></iframe>"); 183 "sandbox></iframe>");
165 frameResource.complete( 184 frameResource.complete(
166 "<iframe style='position:absolute; left:-10000px;' sandbox></iframe>"); 185 "<iframe style='position:absolute; left:-10000px;' sandbox></iframe>");
167 186
168 compositeFrame(); 187 compositeFrame();
169 188
170 histogramTester.expectBucketCount(kHistogramName, Created, 2); 189 histogramTester.expectBucketCount(kHistogramName, Created, 2);
171 histogramTester.expectTotalCount(kHistogramName, 2); 190 histogramTester.expectBucketCount(kHistogramName, WouldLoad1ScreenAway, 2);
191 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 2);
192 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 2);
193 histogramTester.expectTotalCount(kHistogramName, 8);
194 }
195
196 TEST_F(DeferredLoadingTest, OneScreenBelowThenVisible) {
197 HistogramTester histogramTester;
198 std::unique_ptr<SimRequest> mainResource = createMainResource();
199
200 mainResource->start();
201 mainResource->write(
202 "<iframe id='theFrame' style='position:absolute; top:105vh;' "
203 "sandbox></iframe>");
204
205 compositeFrame();
206
207 histogramTester.expectBucketCount(kHistogramName, Created, 1);
208 histogramTester.expectTotalCount(kHistogramName, 4);
209
210 mainResource->write("<script>theFrame.style.top='10px'</script>");
211 mainResource->finish();
212
213 compositeFrame();
214
215 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
216 histogramTester.expectTotalCount(kHistogramName, 5);
217 }
218
219 TEST_F(DeferredLoadingTest, DisplayNoneThenTwoScreensAway) {
220 HistogramTester histogramTester;
221 std::unique_ptr<SimRequest> mainResource = createMainResource();
222
223 mainResource->start();
224 mainResource->write(
225 "<iframe id='theFrame' style='display:none' sandbox></iframe>");
226
227 compositeFrame();
228
229 histogramTester.expectBucketCount(kHistogramName, Created, 1);
230 histogramTester.expectTotalCount(kHistogramName, 6);
231
232 mainResource->write(
233 "<script>theFrame.style.top='200vh';"
234 "theFrame.style.position='absolute';"
235 "theFrame.style.display='block';</script>");
236 mainResource->finish();
237
238 compositeFrame();
239
240 histogramTester.expectBucketCount(kHistogramName, WouldLoadNoParent, 1);
241 histogramTester.expectTotalCount(kHistogramName, 6);
242 }
243
244 TEST_F(DeferredLoadingTest, DisplayNoneAsync) {
245 HistogramTester histogramTester;
246 std::unique_ptr<SimRequest> mainResource = createMainResource();
247
248 mainResource->start();
249 mainResource->write("some stuff");
250
251 compositeFrame();
252
253 mainResource->write(
254 "<script>frame = document.createElement('iframe');"
255 "frame.setAttribute('sandbox', true);"
256 "frame.style.display = 'none';"
257 "document.body.appendChild(frame);"
258 "</script>");
259 mainResource->finish();
260
261 compositeFrame();
262
263 histogramTester.expectBucketCount(kHistogramName, Created, 1);
264 histogramTester.expectBucketCount(kHistogramName, WouldLoadNoParent, 1);
265 histogramTester.expectTotalCount(kHistogramName, 6);
266 }
267
268 // Documents some weird counting with display:none frames: If a frame changes to
269 // display:none we don't count it as such until another frame is created. This
270 // is hopefully rare in practice though.
271 TEST_F(DeferredLoadingTest, TwoScreensAwayThenDisplayNoneThenNew) {
272 HistogramTester histogramTester;
273 std::unique_ptr<SimRequest> mainResource = createMainResource();
274
275 mainResource->start();
276 mainResource->write(
277 "<iframe id='theFrame' style='position:absolute; top:205vh' sandbox>"
278 "</iframe>");
279
280 compositeFrame();
281
282 histogramTester.expectBucketCount(kHistogramName, Created, 1);
283 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
284 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 1);
285 histogramTester.expectTotalCount(kHistogramName, 3);
286
287 mainResource->write("<script>theFrame.style.display='none'</script>");
288
289 compositeFrame();
290
291 histogramTester.expectTotalCount(kHistogramName, 3);
292
293 mainResource->write(
294 "<script>document.body.appendChild(document.createElement"
295 "('iframe'));</script>");
296 mainResource->finish();
297
298 compositeFrame();
299
300 histogramTester.expectBucketCount(kHistogramName, Created, 1);
301 histogramTester.expectBucketCount(kHistogramName, WouldLoadNoParent, 1);
302 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
303 histogramTester.expectBucketCount(kHistogramName, WouldLoad1ScreenAway, 1);
304 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
305 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 1);
306 histogramTester.expectTotalCount(kHistogramName, 6);
172 } 307 }
173 308
174 TEST_F(DeferredLoadingTest, SameOriginNotCounted) { 309 TEST_F(DeferredLoadingTest, SameOriginNotCounted) {
175 HistogramTester histogramTester; 310 HistogramTester histogramTester;
176 std::unique_ptr<SimRequest> mainResource = createMainResource(); 311 std::unique_ptr<SimRequest> mainResource = createMainResource();
177 SimRequest frameResource("https://example.com/iframe.html", "text/html"); 312 SimRequest frameResource("https://example.com/iframe.html", "text/html");
178 313
179 mainResource->complete("<iframe src='iframe.html'></iframe>"); 314 mainResource->complete("<iframe src='iframe.html'></iframe>");
180 frameResource.complete("<iframe></iframe>"); 315 frameResource.complete("<iframe></iframe>");
181 compositeFrame(); 316 compositeFrame();
182 317
183 histogramTester.expectTotalCount(kHistogramName, 0); 318 histogramTester.expectTotalCount(kHistogramName, 0);
184 } 319 }
185 320
321 TEST_F(DeferredLoadingTest, AboveNestedInThreeScreensBelow) {
322 HistogramTester histogramTester;
323 std::unique_ptr<SimRequest> mainResource = createMainResource();
324 SimRequest frameResource("https://example.com/iframe.html", "text/html");
325
326 mainResource->complete(
327 "<iframe style='position:absolute; top:300vh' src='iframe.html' "
328 "sandbox></iframe>");
329 frameResource.complete(
330 "<iframe style='position:absolute; top:-10000px;' sandbox></iframe>");
331
332 compositeFrame();
333
334 histogramTester.expectBucketCount(kHistogramName, Created, 2);
335 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 2);
336 histogramTester.expectTotalCount(kHistogramName, 4);
337 }
338
339 TEST_F(DeferredLoadingTest, VisibleNestedInTwoScreensBelow) {
340 HistogramTester histogramTester;
341 std::unique_ptr<SimRequest> mainResource = createMainResource();
342 SimRequest frameResource("https://example.com/iframe.html", "text/html");
343
344 mainResource->complete(
345 "<iframe style='position:absolute; top:205vh' src='iframe.html' "
346 "sandbox></iframe>");
347 frameResource.complete("<iframe sandbox></iframe>");
348
349 compositeFrame();
350
351 histogramTester.expectBucketCount(kHistogramName, Created, 2);
352 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 2);
353 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 2);
354 histogramTester.expectTotalCount(kHistogramName, 6);
355 }
356
357 TEST_F(DeferredLoadingTest, ThreeScreensBelowNestedInTwoScreensBelow) {
358 HistogramTester histogramTester;
359 std::unique_ptr<SimRequest> mainResource = createMainResource();
360 SimRequest frameResource("https://example.com/iframe.html", "text/html");
361
362 mainResource->complete(
363 "<iframe style='position:absolute; top:205vh' src='iframe.html' "
364 "sandbox></iframe>");
365 frameResource.complete(
366 "<iframe style='position:absolute; top:305vh' sandbox></iframe>");
367
368 compositeFrame();
369
370 histogramTester.expectBucketCount(kHistogramName, Created, 2);
371 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
372 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 2);
373 histogramTester.expectTotalCount(kHistogramName, 5);
374 }
375
376 TEST_F(DeferredLoadingTest, TriplyNested) {
377 HistogramTester histogramTester;
378 std::unique_ptr<SimRequest> mainResource = createMainResource();
379 SimRequest frameResource("https://example.com/iframe.html", "text/html");
380 SimRequest frameResource2("https://example.com/iframe2.html", "text/html");
381
382 mainResource->complete(
383 "<iframe style='position:absolute; top:300vh' src='iframe.html' "
384 "sandbox></iframe>");
385 frameResource.complete(
386 "<iframe style='position:absolute; top:200vh' src='iframe2.html' "
387 "sandbox></iframe>");
388 frameResource2.complete(
389 "<iframe style='position:absolute; top:100vh' sandbox></iframe>");
390
391 compositeFrame();
392
393 histogramTester.expectBucketCount(kHistogramName, Created, 3);
394 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 3);
395 histogramTester.expectTotalCount(kHistogramName, 6);
396 }
397
398 TEST_F(DeferredLoadingTest, QuadruplyNested) {
399 HistogramTester histogramTester;
400 std::unique_ptr<SimRequest> mainResource = createMainResource();
401 SimRequest frameResource("https://example.com/iframe.html", "text/html");
402 SimRequest frameResource2("https://example.com/iframe2.html", "text/html");
403 SimRequest frameResource3("https://example.com/iframe3.html", "text/html");
404
405 mainResource->complete(
406 "<iframe style='position:absolute; top:300vh' src='iframe.html' "
407 "sandbox></iframe>");
408 frameResource.complete(
409 "<iframe style='position:absolute; top:200vh' src='iframe2.html' "
410 "sandbox></iframe>");
411 frameResource2.complete(
412 "<iframe style='position:absolute; top:100vh' src='iframe3.html' "
413 "sandbox></iframe>");
414 frameResource3.complete(
415 "<iframe style='position:absolute; top:100vh' sandbox></iframe>");
416 compositeFrame();
417
418 histogramTester.expectBucketCount(kHistogramName, Created, 4);
419 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 4);
420 histogramTester.expectTotalCount(kHistogramName, 8);
421 }
422
423 TEST_F(DeferredLoadingTest, VisibleCrossOriginNestedInBelowFoldSameOrigin) {
424 HistogramTester histogramTester;
425 std::unique_ptr<SimRequest> mainResource = createMainResource();
426 SimRequest frameResource("https://example.com/iframe.html", "text/html");
427
428 mainResource->complete(
429 "<iframe style='position:absolute; top:105vh' src='iframe.html'>"
430 "</iframe>");
431 frameResource.complete("<iframe sandbox></iframe>");
432
433 compositeFrame();
434
435 histogramTester.expectBucketCount(kHistogramName, Created, 1);
436 histogramTester.expectBucketCount(kHistogramName, WouldLoadVisible, 1);
437 histogramTester.expectBucketCount(kHistogramName, WouldLoad1ScreenAway, 1);
438 histogramTester.expectBucketCount(kHistogramName, WouldLoad2ScreensAway, 1);
439 histogramTester.expectBucketCount(kHistogramName, WouldLoad3ScreensAway, 1);
440 histogramTester.expectTotalCount(kHistogramName, 5);
441 }
442
186 } // namespace blink 443 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698