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

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

Issue 2420413005: Collect @viewport before constructing RuleSets. (Closed)
Patch Set: Rebased Created 4 years, 2 months 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after
2689 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5); 2689 webViewHelper.webView()->setDefaultPageScaleLimits(0.25f, 5);
2690 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); 2690 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true);
2691 webViewHelper.webView()->settings()->setUseWideViewport(false); 2691 webViewHelper.webView()->settings()->setUseWideViewport(false);
2692 webViewHelper.resize(WebSize(viewportWidth, viewportHeight)); 2692 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
2693 2693
2694 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f); 2694 EXPECT_NEAR(1.0f, webViewHelper.webView()->pageScaleFactor(), 0.01f);
2695 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f); 2695 EXPECT_NEAR(1.0f, webViewHelper.webView()->minimumPageScaleFactor(), 0.01f);
2696 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f); 2696 EXPECT_NEAR(5.0f, webViewHelper.webView()->maximumPageScaleFactor(), 0.01f);
2697 } 2697 }
2698 2698
2699 // TODO(rune@opera.com): Does not pass until we collect author @viewport rules 2699 TEST_P(ParameterizedWebFrameTest, AtViewportInsideAtMediaInitialViewport) {
2700 // before constructing the RuleSets. https://crbug.com/332763
2701 TEST_P(ParameterizedWebFrameTest,
2702 DISABLED_AtViewportInsideAtMediaInitialViewport) {
2703 registerMockedHttpURLLoad("viewport-inside-media.html"); 2700 registerMockedHttpURLLoad("viewport-inside-media.html");
2704 2701
2705 FixedLayoutTestWebViewClient client; 2702 FixedLayoutTestWebViewClient client;
2706 FrameTestHelpers::WebViewHelper webViewHelper; 2703 FrameTestHelpers::WebViewHelper webViewHelper;
2707 webViewHelper.initializeAndLoad(m_baseURL + "viewport-inside-media.html", 2704 webViewHelper.initializeAndLoad(m_baseURL + "viewport-inside-media.html",
2708 true, nullptr, &client, nullptr, 2705 true, nullptr, &client, nullptr,
2709 enableViewportSettings); 2706 enableViewportSettings);
2710 webViewHelper.resize(WebSize(640, 480)); 2707 webViewHelper.resize(WebSize(640, 480));
2711 2708
2712 EXPECT_EQ(2000, webViewHelper.webView() 2709 EXPECT_EQ(2000, webViewHelper.webView()
2713 ->mainFrameImpl() 2710 ->mainFrameImpl()
2714 ->frameView() 2711 ->frameView()
2715 ->layoutSize() 2712 ->layoutSize()
2716 .width()); 2713 .width());
2717 } 2714 }
2718 2715
2716 TEST_P(ParameterizedWebFrameTest, AtViewportAffectingAtMediaRecalcCount) {
2717 registerMockedHttpURLLoad("viewport-and-media.html");
2718
2719 FixedLayoutTestWebViewClient client;
2720 FrameTestHelpers::WebViewHelper webViewHelper;
2721 webViewHelper.initialize(true, nullptr, &client, nullptr,
2722 enableViewportSettings);
2723 webViewHelper.resize(WebSize(640, 480));
2724 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(),
2725 m_baseURL + "viewport-and-media.html");
2726
2727 Document* document =
2728 webViewHelper.webView()->mainFrameImpl()->frame()->document();
2729 EXPECT_EQ(2000, webViewHelper.webView()
2730 ->mainFrameImpl()
2731 ->frameView()
2732 ->layoutSize()
2733 .width());
2734
2735 // The styleForElementCount() should match the number of elements for a single
2736 // pass of computed styles construction for the document.
2737 EXPECT_EQ(10u, document->styleEngine().styleForElementCount());
2738 EXPECT_EQ(Color(0, 128, 0),
2739 document->body()->computedStyle()->visitedDependentColor(
2740 CSSPropertyColor));
2741 }
2742
2743 TEST_P(ParameterizedWebFrameTest, AtViewportWithViewportLengths) {
2744 registerMockedHttpURLLoad("viewport-lengths.html");
2745
2746 FixedLayoutTestWebViewClient client;
2747 FrameTestHelpers::WebViewHelper webViewHelper;
2748 webViewHelper.initialize(true, nullptr, &client, nullptr,
2749 enableViewportSettings);
2750 webViewHelper.resize(WebSize(800, 600));
2751 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(),
2752 m_baseURL + "viewport-lengths.html");
2753
2754 FrameView* view = webViewHelper.webView()->mainFrameImpl()->frameView();
2755 EXPECT_EQ(400, view->layoutSize().width());
2756 EXPECT_EQ(300, view->layoutSize().height());
2757
2758 webViewHelper.resize(WebSize(1000, 400));
2759
2760 EXPECT_EQ(500, view->layoutSize().width());
2761 EXPECT_EQ(200, view->layoutSize().height());
2762 }
2763
2719 class WebFrameResizeTest : public ParameterizedWebFrameTest { 2764 class WebFrameResizeTest : public ParameterizedWebFrameTest {
2720 protected: 2765 protected:
2721 static FloatSize computeRelativeOffset(const IntPoint& absoluteOffset, 2766 static FloatSize computeRelativeOffset(const IntPoint& absoluteOffset,
2722 const LayoutRect& rect) { 2767 const LayoutRect& rect) {
2723 FloatSize relativeOffset = 2768 FloatSize relativeOffset =
2724 FloatPoint(absoluteOffset) - FloatPoint(rect.location()); 2769 FloatPoint(absoluteOffset) - FloatPoint(rect.location());
2725 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height()); 2770 relativeOffset.scale(1.f / rect.width(), 1.f / rect.height());
2726 return relativeOffset; 2771 return relativeOffset;
2727 } 2772 }
2728 2773
(...skipping 7478 matching lines...) Expand 10 before | Expand all | Expand 10 after
10207 webViewHelper.webView()->handleInputEvent(endEvent); 10252 webViewHelper.webView()->handleInputEvent(endEvent);
10208 webViewHelper.webView()->handleInputEvent(updateEvent); 10253 webViewHelper.webView()->handleInputEvent(updateEvent);
10209 10254
10210 // Try a full Begin/Update/End cycle. 10255 // Try a full Begin/Update/End cycle.
10211 webViewHelper.webView()->handleInputEvent(beginEvent); 10256 webViewHelper.webView()->handleInputEvent(beginEvent);
10212 webViewHelper.webView()->handleInputEvent(updateEvent); 10257 webViewHelper.webView()->handleInputEvent(updateEvent);
10213 webViewHelper.webView()->handleInputEvent(endEvent); 10258 webViewHelper.webView()->handleInputEvent(endEvent);
10214 } 10259 }
10215 10260
10216 } // namespace blink 10261 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/Page.cpp ('k') | third_party/WebKit/Source/web/tests/data/viewport-and-media.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698