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

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

Issue 1930363002: Avoid clobbering state in viewport tag initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review comments Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need sLayout()); 1513 EXPECT_FALSE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->need sLayout());
1514 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1514 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height());
1515 1515
1516 webViewHelper.resize(WebSize(viewportWidth * 2, viewportHeight)); 1516 webViewHelper.resize(WebSize(viewportWidth * 2, viewportHeight));
1517 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height()); 1517 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->layo utSize().height());
1518 1518
1519 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false); 1519 webViewHelper.webView()->settings()->setForceZeroLayoutHeight(false);
1520 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->layoutSize().height()); 1520 EXPECT_LE(viewportHeight, webViewHelper.webViewImpl()->mainFrameImpl()->fram eView()->layoutSize().height());
1521 } 1521 }
1522 1522
1523 TEST_F(WebFrameTest, ToggleViewportMetaOnOff)
1524 {
1525 registerMockedHttpURLLoad("viewport-device-width.html");
1526
1527 FixedLayoutTestWebViewClient client;
1528 client.m_screenInfo.deviceScaleFactor = 1;
1529 int viewportWidth = 640;
1530 int viewportHeight = 480;
1531
1532 FrameTestHelpers::WebViewHelper webViewHelper;
1533 webViewHelper.initializeAndLoad(m_baseURL + "viewport-device-width.html", tr ue, 0, &client);
1534 WebSettings* settings = webViewHelper.webView()->settings();
1535 settings->setViewportMetaEnabled(false);
1536 settings->setViewportEnabled(true);
1537 settings->setMainFrameResizesAreOrientationChanges(true);
1538 settings->setShrinksViewportContentToFit(true);
1539 webViewHelper.resize(WebSize(viewportWidth, viewportHeight));
1540
1541 Document* document = toLocalFrame(webViewHelper.webViewImpl()->page()->mainF rame())->document();
1542 EXPECT_FALSE(document->viewportDescription().isLegacyViewportType());
1543
1544 settings->setViewportMetaEnabled(true);
1545 EXPECT_TRUE(document->viewportDescription().isLegacyViewportType());
1546
1547 settings->setViewportMetaEnabled(false);
1548 EXPECT_FALSE(document->viewportDescription().isLegacyViewportType());
1549 }
1550
1523 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged ) 1551 TEST_F(WebFrameTest, SetForceZeroLayoutHeightWorksWithRelayoutsWhenHeightChanged )
1524 { 1552 {
1525 // this unit test is an attempt to target a real world case where an app cou ld 1553 // this unit test is an attempt to target a real world case where an app cou ld
1526 // 1. call resize(width, 0) and setForceZeroLayoutHeight(true) 1554 // 1. call resize(width, 0) and setForceZeroLayoutHeight(true)
1527 // 2. load content (hoping that the viewport height would increase 1555 // 2. load content (hoping that the viewport height would increase
1528 // as more content is added) 1556 // as more content is added)
1529 // 3. fail to register touch events aimed at the loaded content 1557 // 3. fail to register touch events aimed at the loaded content
1530 // because the layout is only updated if either width or height is changed 1558 // because the layout is only updated if either width or height is changed
1531 registerMockedHttpURLLoad("button.html"); 1559 registerMockedHttpURLLoad("button.html");
1532 1560
(...skipping 7022 matching lines...) Expand 10 before | Expand all | Expand 10 after
8555 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); 8583 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame();
8556 v8::HandleScope scope(v8::Isolate::GetCurrent()); 8584 v8::HandleScope scope(v8::Isolate::GetCurrent());
8557 mainFrame->executeScript(WebScriptSource("hello = 'world';")); 8585 mainFrame->executeScript(WebScriptSource("hello = 'world';"));
8558 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); 8586 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page");
8559 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello")); 8587 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri ptSource("hello"));
8560 ASSERT_TRUE(result->IsString()); 8588 ASSERT_TRUE(result->IsString());
8561 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked())); 8589 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC ontext()).ToLocalChecked()));
8562 } 8590 }
8563 8591
8564 } // namespace blink 8592 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698