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

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

Issue 2591733003: Fix use-after-scope issue in WebFrameTest. (Closed)
Patch Set: Fix a few more similar cases 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
« no previous file with comments | « no previous file | 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 4100 matching lines...) Expand 10 before | Expand all | Expand 10 after
4111 const std::string secondURL = "content-width-1000.html"; 4111 const std::string secondURL = "content-width-1000.html";
4112 const std::string thirdURL = "very_tall_div.html"; 4112 const std::string thirdURL = "very_tall_div.html";
4113 const float pageScaleFactor = 1.1684f; 4113 const float pageScaleFactor = 1.1684f;
4114 const int pageWidth = 120; 4114 const int pageWidth = 120;
4115 const int pageHeight = 100; 4115 const int pageHeight = 100;
4116 4116
4117 registerMockedHttpURLLoad(firstURL); 4117 registerMockedHttpURLLoad(firstURL);
4118 registerMockedHttpURLLoad(secondURL); 4118 registerMockedHttpURLLoad(secondURL);
4119 registerMockedHttpURLLoad(thirdURL); 4119 registerMockedHttpURLLoad(thirdURL);
4120 4120
4121 ClearScrollStateOnCommitWebFrameClient client;
4121 FrameTestHelpers::WebViewHelper webViewHelper; 4122 FrameTestHelpers::WebViewHelper webViewHelper;
4122 ClearScrollStateOnCommitWebFrameClient client;
4123 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client); 4123 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client);
4124 webViewHelper.resize(WebSize(pageWidth, pageHeight)); 4124 webViewHelper.resize(WebSize(pageWidth, pageHeight));
4125 webViewHelper.webView()->mainFrame()->setScrollOffset( 4125 webViewHelper.webView()->mainFrame()->setScrollOffset(
4126 WebSize(pageWidth / 4, pageHeight / 4)); 4126 WebSize(pageWidth / 4, pageHeight / 4));
4127 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor); 4127 webViewHelper.webView()->setPageScaleFactor(pageScaleFactor);
4128 4128
4129 WebSize previousOffset = 4129 WebSize previousOffset =
4130 webViewHelper.webView()->mainFrame()->getScrollOffset(); 4130 webViewHelper.webView()->mainFrame()->getScrollOffset();
4131 float previousScale = webViewHelper.webView()->pageScaleFactor(); 4131 float previousScale = webViewHelper.webView()->pageScaleFactor();
4132 4132
(...skipping 3258 matching lines...) Expand 10 before | Expand all | Expand 10 after
7391 bool m_replacesCurrentHistoryItem; 7391 bool m_replacesCurrentHistoryItem;
7392 WebFrame* m_frame; 7392 WebFrame* m_frame;
7393 }; 7393 };
7394 7394
7395 // Tests that the first navigation in an initially blank subframe will result in 7395 // Tests that the first navigation in an initially blank subframe will result in
7396 // a history entry being replaced and not a new one being added. 7396 // a history entry being replaced and not a new one being added.
7397 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { 7397 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) {
7398 registerMockedHttpURLLoad("history.html"); 7398 registerMockedHttpURLLoad("history.html");
7399 registerMockedHttpURLLoad("find.html"); 7399 registerMockedHttpURLLoad("find.html");
7400 7400
7401 TestHistoryWebFrameClient client;
7401 FrameTestHelpers::WebViewHelper webViewHelper; 7402 FrameTestHelpers::WebViewHelper webViewHelper;
7402 TestHistoryWebFrameClient client;
7403 webViewHelper.initializeAndLoad("about:blank", true, &client); 7403 webViewHelper.initializeAndLoad("about:blank", true, &client);
7404 7404
7405 WebFrame* frame = webViewHelper.webView()->mainFrame(); 7405 WebFrame* frame = webViewHelper.webView()->mainFrame();
7406 7406
7407 frame->executeScript(WebScriptSource(WebString::fromUTF8( 7407 frame->executeScript(WebScriptSource(WebString::fromUTF8(
7408 "document.body.appendChild(document.createElement('iframe'))"))); 7408 "document.body.appendChild(document.createElement('iframe'))")));
7409 7409
7410 WebFrame* iframe = frame->firstChild(); 7410 WebFrame* iframe = frame->firstChild();
7411 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); 7411 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client());
7412 EXPECT_EQ(iframe, client.frame()); 7412 EXPECT_EQ(iframe, client.frame());
(...skipping 10 matching lines...) Expand all
7423 EXPECT_EQ(url2, iframe->document().url().string().utf8()); 7423 EXPECT_EQ(url2, iframe->document().url().string().utf8());
7424 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 7424 EXPECT_FALSE(client.replacesCurrentHistoryItem());
7425 } 7425 }
7426 7426
7427 // Tests that a navigation in a frame with a non-blank initial URL will create 7427 // Tests that a navigation in a frame with a non-blank initial URL will create
7428 // a new history item, unlike the case above. 7428 // a new history item, unlike the case above.
7429 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { 7429 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) {
7430 registerMockedHttpURLLoad("history.html"); 7430 registerMockedHttpURLLoad("history.html");
7431 registerMockedHttpURLLoad("find.html"); 7431 registerMockedHttpURLLoad("find.html");
7432 7432
7433 TestHistoryWebFrameClient client;
7433 FrameTestHelpers::WebViewHelper webViewHelper; 7434 FrameTestHelpers::WebViewHelper webViewHelper;
7434 TestHistoryWebFrameClient client;
7435 webViewHelper.initializeAndLoad("about:blank", true, &client); 7435 webViewHelper.initializeAndLoad("about:blank", true, &client);
7436 7436
7437 WebFrame* frame = webViewHelper.webView()->mainFrame(); 7437 WebFrame* frame = webViewHelper.webView()->mainFrame();
7438 7438
7439 std::string url1 = m_baseURL + "history.html"; 7439 std::string url1 = m_baseURL + "history.html";
7440 FrameTestHelpers::loadFrame( 7440 FrameTestHelpers::loadFrame(
7441 frame, 7441 frame,
7442 "javascript:var f = document.createElement('iframe'); " 7442 "javascript:var f = document.createElement('iframe'); "
7443 "f.src = '" + 7443 "f.src = '" +
7444 url1 + 7444 url1 +
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
8439 bool didNotify() const { return m_didNotify; } 8439 bool didNotify() const { return m_didNotify; }
8440 8440
8441 private: 8441 private:
8442 virtual void didChangeThemeColor() { m_didNotify = true; } 8442 virtual void didChangeThemeColor() { m_didNotify = true; }
8443 8443
8444 bool m_didNotify; 8444 bool m_didNotify;
8445 }; 8445 };
8446 8446
8447 TEST_P(ParameterizedWebFrameTest, ThemeColor) { 8447 TEST_P(ParameterizedWebFrameTest, ThemeColor) {
8448 registerMockedHttpURLLoad("theme_color_test.html"); 8448 registerMockedHttpURLLoad("theme_color_test.html");
8449 ThemeColorTestWebFrameClient client;
8449 FrameTestHelpers::WebViewHelper webViewHelper; 8450 FrameTestHelpers::WebViewHelper webViewHelper;
8450 ThemeColorTestWebFrameClient client;
8451 webViewHelper.initializeAndLoad(m_baseURL + "theme_color_test.html", true, 8451 webViewHelper.initializeAndLoad(m_baseURL + "theme_color_test.html", true,
8452 &client); 8452 &client);
8453 EXPECT_TRUE(client.didNotify()); 8453 EXPECT_TRUE(client.didNotify());
8454 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl(); 8454 WebLocalFrameImpl* frame = webViewHelper.webView()->mainFrameImpl();
8455 EXPECT_EQ(0xff0000ff, frame->document().themeColor()); 8455 EXPECT_EQ(0xff0000ff, frame->document().themeColor());
8456 // Change color by rgb. 8456 // Change color by rgb.
8457 client.reset(); 8457 client.reset();
8458 frame->executeScript( 8458 frame->executeScript(
8459 WebScriptSource("document.getElementById('tc1').setAttribute('content', " 8459 WebScriptSource("document.getElementById('tc1').setAttribute('content', "
8460 "'rgb(0, 0, 0)');")); 8460 "'rgb(0, 0, 0)');"));
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
10101 EXPECT_EQ(6, m_callbackCount++); 10101 EXPECT_EQ(6, m_callbackCount++);
10102 FrameTestHelpers::TestWebFrameClient::didStopLoading(); 10102 FrameTestHelpers::TestWebFrameClient::didStopLoading();
10103 } 10103 }
10104 10104
10105 private: 10105 private:
10106 int m_callbackCount; 10106 int m_callbackCount;
10107 }; 10107 };
10108 10108
10109 TEST_F(WebFrameTest, CallbackOrdering) { 10109 TEST_F(WebFrameTest, CallbackOrdering) {
10110 registerMockedHttpURLLoad("foo.html"); 10110 registerMockedHttpURLLoad("foo.html");
10111 CallbackOrderingWebFrameClient client;
10111 FrameTestHelpers::WebViewHelper webViewHelper; 10112 FrameTestHelpers::WebViewHelper webViewHelper;
10112 CallbackOrderingWebFrameClient client;
10113 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); 10113 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client);
10114 } 10114 }
10115 10115
10116 class TestWebRemoteFrameClientForVisibility 10116 class TestWebRemoteFrameClientForVisibility
10117 : public FrameTestHelpers::TestWebRemoteFrameClient { 10117 : public FrameTestHelpers::TestWebRemoteFrameClient {
10118 public: 10118 public:
10119 TestWebRemoteFrameClientForVisibility() : m_visible(true) {} 10119 TestWebRemoteFrameClientForVisibility() : m_visible(true) {}
10120 void visibilityChanged(bool visible) override { m_visible = visible; } 10120 void visibilityChanged(bool visible) override { m_visible = visible; }
10121 10121
10122 bool isVisible() const { return m_visible; } 10122 bool isVisible() const { return m_visible; }
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
11161 11161
11162 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); 11162 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached());
11163 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); 11163 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading());
11164 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); 11164 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad());
11165 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); 11165 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents());
11166 11166
11167 webViewHelper.reset(); 11167 webViewHelper.reset();
11168 } 11168 }
11169 11169
11170 } // namespace blink 11170 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698