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

Side by Side Diff: third_party/WebKit/Source/core/page/PrintContextTest.cpp

Issue 2504573002: Don't call isURLAllowed() from layout. (Closed)
Patch Set: Fix everything Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/page/PrintContext.h" 5 #include "core/page/PrintContext.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/html/HTMLElement.h" 9 #include "core/html/HTMLElement.h"
10 #include "core/layout/LayoutTestHelper.h" 10 #include "core/layout/LayoutTestHelper.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 "<img style='width: 200px; height: 100px'>")); 294 "<img style='width: 200px; height: 100px'>"));
295 printSinglePage(canvas); 295 printSinglePage(canvas);
296 296
297 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); 297 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations();
298 ASSERT_EQ(1u, operations.size()); 298 ASSERT_EQ(1u, operations.size());
299 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); 299 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type);
300 EXPECT_SKRECT_EQ(50, 60, 200, 100, operations[0].rect); 300 EXPECT_SKRECT_EQ(50, 60, 200, 100, operations[0].rect);
301 } 301 }
302 302
303 TEST_F(PrintContextFrameTest, WithSubframe) { 303 TEST_F(PrintContextFrameTest, WithSubframe) {
304 MockCanvas canvas; 304 setChildFrameHTML(
305 absoluteBlockHtmlForLink(50, 60, 70, 80, "#fragment") +
306 absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com") +
307 absoluteBlockHtmlForLink(250, 260, 270, 280,
308 "http://www.google.com#fragment"));
309
305 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); 310 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/"));
306 setBodyInnerHTML( 311 setBodyInnerHTML(
307 "<style>::-webkit-scrollbar { display: none }</style>" 312 "<style>::-webkit-scrollbar { display: none }</style>"
308 "<iframe id='frame' src='http://b.com/' width='500' height='500'" 313 "<iframe src='http://b.com/' width='500' height='500'"
309 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; " 314 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; "
310 "left: 90px'></iframe>"); 315 "left: 90px'></iframe>");
311 316
312 setupChildIframe( 317 MockCanvas canvas;
313 "frame", absoluteBlockHtmlForLink(50, 60, 70, 80, "#fragment") +
314 absoluteBlockHtmlForLink(150, 160, 170, 180,
315 "http://www.google.com") +
316 absoluteBlockHtmlForLink(250, 260, 270, 280,
317 "http://www.google.com#fragment"));
318
319 printSinglePage(canvas); 318 printSinglePage(canvas);
320 319
321 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); 320 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations();
322 ASSERT_EQ(2u, operations.size()); 321 ASSERT_EQ(2u, operations.size());
323 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); 322 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type);
324 EXPECT_SKRECT_EQ(250, 260, 170, 180, operations[0].rect); 323 EXPECT_SKRECT_EQ(250, 260, 170, 180, operations[0].rect);
325 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); 324 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type);
326 EXPECT_SKRECT_EQ(350, 360, 270, 280, operations[1].rect); 325 EXPECT_SKRECT_EQ(350, 360, 270, 280, operations[1].rect);
327 } 326 }
328 327
329 TEST_F(PrintContextFrameTest, WithScrolledSubframe) { 328 TEST_F(PrintContextFrameTest, WithScrolledSubframe) {
330 MockCanvas canvas; 329 setChildFrameHTML(
330 absoluteBlockHtmlForLink(10, 10, 20, 20, "http://invisible.com") +
331 absoluteBlockHtmlForLink(50, 60, 70, 80, "http://partly.visible.com") +
332 absoluteBlockHtmlForLink(150, 160, 170, 180, "http://www.google.com") +
333 absoluteBlockHtmlForLink(250, 260, 270, 280,
334 "http://www.google.com#fragment") +
335 absoluteBlockHtmlForLink(850, 860, 70, 80,
336 "http://another.invisible.com"));
331 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/")); 337 document().setBaseURLOverride(KURL(ParsedURLString, "http://a.com/"));
332 setBodyInnerHTML( 338 setBodyInnerHTML(
333 "<style>::-webkit-scrollbar { display: none }</style>" 339 "<style>::-webkit-scrollbar { display: none }</style>"
334 "<iframe id='frame' src='http://b.com/' width='500' height='500'" 340 "<iframe src='http://b.com/' width='500' height='500'"
335 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; " 341 " style='border-width: 5px; margin: 5px; position: absolute; top: 90px; "
336 "left: 90px'></iframe>"); 342 "left: 90px'></iframe>");
337 343
338 Document& frameDocument = setupChildIframe( 344 childDocument().domWindow()->scrollTo(100, 100);
339 "frame",
340 absoluteBlockHtmlForLink(10, 10, 20, 20, "http://invisible.com") +
341 absoluteBlockHtmlForLink(50, 60, 70, 80,
342 "http://partly.visible.com") +
343 absoluteBlockHtmlForLink(150, 160, 170, 180,
344 "http://www.google.com") +
345 absoluteBlockHtmlForLink(250, 260, 270, 280,
346 "http://www.google.com#fragment") +
347 absoluteBlockHtmlForLink(850, 860, 70, 80,
348 "http://another.invisible.com"));
349 345
350 frameDocument.domWindow()->scrollTo(100, 100); 346 MockCanvas canvas;
351
352 printSinglePage(canvas); 347 printSinglePage(canvas);
353 348
354 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations(); 349 const Vector<MockCanvas::Operation>& operations = canvas.recordedOperations();
355 ASSERT_EQ(3u, operations.size()); 350 ASSERT_EQ(3u, operations.size());
356 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type); 351 EXPECT_EQ(MockCanvas::DrawRect, operations[0].type);
357 EXPECT_SKRECT_EQ(50, 60, 70, 80, 352 EXPECT_SKRECT_EQ(50, 60, 70, 80,
358 operations[0].rect); // FIXME: the rect should be clipped. 353 operations[0].rect); // FIXME: the rect should be clipped.
359 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type); 354 EXPECT_EQ(MockCanvas::DrawRect, operations[1].type);
360 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect); 355 EXPECT_SKRECT_EQ(150, 160, 170, 180, operations[1].rect);
361 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type); 356 EXPECT_EQ(MockCanvas::DrawRect, operations[2].type);
362 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect); 357 EXPECT_SKRECT_EQ(250, 260, 270, 280, operations[2].rect);
363 } 358 }
364 359
365 } // namespace blink 360 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698