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

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

Issue 2580703003: Make sure pages that are closing but not yet closed are still suspended. (Closed)
Patch Set: comments 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 /* 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 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 4031 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
4032 frame->setAutofillClient(0); 4032 frame->setAutofillClient(0);
4033 } 4033 }
4034 4034
4035 // Verify that a WebView created with a ScopedPageSuspender already on the 4035 // Verify that a WebView created with a ScopedPageSuspender already on the
4036 // stack defers its loads. 4036 // stack defers its loads.
4037 TEST_P(WebViewTest, CreatedDuringPageSuspension) { 4037 TEST_P(WebViewTest, CreatedDuringPageSuspension) {
4038 { 4038 {
4039 WebViewImpl* webView = m_webViewHelper.initialize(); 4039 WebViewImpl* webView = m_webViewHelper.initialize();
4040 EXPECT_FALSE(webView->page()->suspended()); 4040 EXPECT_FALSE(webView->page()->suspended());
4041 m_webViewHelper.reset();
4041 } 4042 }
4042 4043
4043 { 4044 {
4044 ScopedPageSuspender suspender; 4045 ScopedPageSuspender suspender;
4045 WebViewImpl* webView = m_webViewHelper.initialize(); 4046 WebViewImpl* webView = m_webViewHelper.initialize();
4046 EXPECT_TRUE(webView->page()->suspended()); 4047 EXPECT_TRUE(webView->page()->suspended());
4047 } 4048 }
4048 } 4049 }
4049 4050
4050 // Make sure the SubframeBeforeUnloadUseCounter is only incremented on subframe 4051 // Make sure the SubframeBeforeUnloadUseCounter is only incremented on subframe
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4103 ScopedPageSuspender suspender2; 4104 ScopedPageSuspender suspender2;
4104 EXPECT_TRUE(webView->page()->suspended()); 4105 EXPECT_TRUE(webView->page()->suspended());
4105 } 4106 }
4106 4107
4107 EXPECT_TRUE(webView->page()->suspended()); 4108 EXPECT_TRUE(webView->page()->suspended());
4108 } 4109 }
4109 4110
4110 EXPECT_FALSE(webView->page()->suspended()); 4111 EXPECT_FALSE(webView->page()->suspended());
4111 } 4112 }
4112 4113
4114 TEST_P(WebViewTest, ClosingPageIsSuspended) {
4115 WebViewImpl* webView = m_webViewHelper.initialize();
4116 Page* page = m_webViewHelper.webView()->page();
4117 EXPECT_FALSE(page->suspended());
4118
4119 webView->setOpenedByDOM();
4120
4121 LocalFrame* mainFrame = toLocalFrame(page->mainFrame());
4122 EXPECT_FALSE(mainFrame->domWindow()->closed());
4123
4124 mainFrame->domWindow()->close(nullptr);
4125 // The window should be marked closed...
4126 EXPECT_TRUE(mainFrame->domWindow()->closed());
4127 // EXPECT_TRUE(page->isClosing());
4128 // ...but not yet detached.
4129 EXPECT_TRUE(mainFrame->host());
4130
4131 {
4132 ScopedPageSuspender suspender;
4133 EXPECT_TRUE(page->suspended());
4134 }
4135 }
4136
4113 TEST_P(WebViewTest, ForceAndResetViewport) { 4137 TEST_P(WebViewTest, ForceAndResetViewport) {
4114 URLTestHelpers::registerMockedURLFromBaseURL( 4138 URLTestHelpers::registerMockedURLFromBaseURL(
4115 WebString::fromUTF8(m_baseURL.c_str()), 4139 WebString::fromUTF8(m_baseURL.c_str()),
4116 WebString::fromUTF8("200-by-300.html")); 4140 WebString::fromUTF8("200-by-300.html"));
4117 WebViewImpl* webViewImpl = 4141 WebViewImpl* webViewImpl =
4118 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html"); 4142 m_webViewHelper.initializeAndLoad(m_baseURL + "200-by-300.html");
4119 webViewImpl->resize(WebSize(100, 150)); 4143 webViewImpl->resize(WebSize(100, 150));
4120 webViewImpl->layerTreeView()->setViewportSize(WebSize(100, 150)); 4144 webViewImpl->layerTreeView()->setViewportSize(WebSize(100, 150));
4121 VisualViewport* visualViewport = 4145 VisualViewport* visualViewport =
4122 &webViewImpl->page()->frameHost().visualViewport(); 4146 &webViewImpl->page()->frameHost().visualViewport();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
4245 .translate(50, 55) 4269 .translate(50, 55)
4246 .scale(1. / 2.f); 4270 .scale(1. / 2.f);
4247 EXPECT_EQ(expectedMatrix, 4271 EXPECT_EQ(expectedMatrix,
4248 webViewImpl->getDeviceEmulationTransformForTesting()); 4272 webViewImpl->getDeviceEmulationTransformForTesting());
4249 // visibleContentRect doesn't change. 4273 // visibleContentRect doesn't change.
4250 EXPECT_EQ(IntRect(50, 55, 50, 75), 4274 EXPECT_EQ(IntRect(50, 55, 50, 75),
4251 *devToolsEmulator->visibleContentRectForPainting()); 4275 *devToolsEmulator->visibleContentRectForPainting());
4252 } 4276 }
4253 4277
4254 } // namespace blink 4278 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698