| OLD | NEW |
| 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 7330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7341 nullptr, FrameLoader::resourceRequestFromHistoryItem( | 7341 nullptr, FrameLoader::resourceRequestFromHistoryItem( |
| 7342 item.get(), WebCachePolicy::UseProtocolCachePolicy)), | 7342 item.get(), WebCachePolicy::UseProtocolCachePolicy)), |
| 7343 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); | 7343 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); |
| 7344 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 7344 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
| 7345 } | 7345 } |
| 7346 | 7346 |
| 7347 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 7347 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 7348 public: | 7348 public: |
| 7349 TestHistoryWebFrameClient() { | 7349 TestHistoryWebFrameClient() { |
| 7350 m_replacesCurrentHistoryItem = false; | 7350 m_replacesCurrentHistoryItem = false; |
| 7351 m_frame = nullptr; | |
| 7352 } | 7351 } |
| 7353 | 7352 |
| 7354 void didStartProvisionalLoad(WebLocalFrame* frame) { | 7353 void didStartProvisionalLoad(WebDataSource* dataSource) { |
| 7355 WebDataSource* ds = frame->provisionalDataSource(); | 7354 m_replacesCurrentHistoryItem = dataSource->replacesCurrentHistoryItem(); |
| 7356 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); | |
| 7357 m_frame = frame; | |
| 7358 } | 7355 } |
| 7359 | 7356 |
| 7360 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } | 7357 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } |
| 7361 WebFrame* frame() { return m_frame; } | |
| 7362 | 7358 |
| 7363 private: | 7359 private: |
| 7364 bool m_replacesCurrentHistoryItem; | 7360 bool m_replacesCurrentHistoryItem; |
| 7365 WebFrame* m_frame; | |
| 7366 }; | 7361 }; |
| 7367 | 7362 |
| 7368 // Tests that the first navigation in an initially blank subframe will result in | 7363 // Tests that the first navigation in an initially blank subframe will result in |
| 7369 // a history entry being replaced and not a new one being added. | 7364 // a history entry being replaced and not a new one being added. |
| 7370 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { | 7365 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) { |
| 7371 registerMockedHttpURLLoad("history.html"); | 7366 registerMockedHttpURLLoad("history.html"); |
| 7372 registerMockedHttpURLLoad("find.html"); | 7367 registerMockedHttpURLLoad("find.html"); |
| 7373 | 7368 |
| 7374 TestHistoryWebFrameClient client; | 7369 TestHistoryWebFrameClient client; |
| 7375 FrameTestHelpers::WebViewHelper webViewHelper; | 7370 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7376 webViewHelper.initializeAndLoad("about:blank", true, &client); | 7371 webViewHelper.initializeAndLoad("about:blank", true, &client); |
| 7377 | 7372 |
| 7378 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7373 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 7379 | 7374 |
| 7380 frame->executeScript(WebScriptSource(WebString::fromUTF8( | 7375 frame->executeScript(WebScriptSource(WebString::fromUTF8( |
| 7381 "document.body.appendChild(document.createElement('iframe'))"))); | 7376 "document.body.appendChild(document.createElement('iframe'))"))); |
| 7382 | 7377 |
| 7383 WebFrame* iframe = frame->firstChild(); | 7378 WebFrame* iframe = frame->firstChild(); |
| 7384 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); | 7379 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); |
| 7385 EXPECT_EQ(iframe, client.frame()); | |
| 7386 | 7380 |
| 7387 std::string url1 = m_baseURL + "history.html"; | 7381 std::string url1 = m_baseURL + "history.html"; |
| 7388 FrameTestHelpers::loadFrame(iframe, url1); | 7382 FrameTestHelpers::loadFrame(iframe, url1); |
| 7389 EXPECT_EQ(iframe, client.frame()); | |
| 7390 EXPECT_EQ(url1, iframe->document().url().string().utf8()); | 7383 EXPECT_EQ(url1, iframe->document().url().string().utf8()); |
| 7391 EXPECT_TRUE(client.replacesCurrentHistoryItem()); | 7384 EXPECT_TRUE(client.replacesCurrentHistoryItem()); |
| 7392 | 7385 |
| 7393 std::string url2 = m_baseURL + "find.html"; | 7386 std::string url2 = m_baseURL + "find.html"; |
| 7394 FrameTestHelpers::loadFrame(iframe, url2); | 7387 FrameTestHelpers::loadFrame(iframe, url2); |
| 7395 EXPECT_EQ(iframe, client.frame()); | |
| 7396 EXPECT_EQ(url2, iframe->document().url().string().utf8()); | 7388 EXPECT_EQ(url2, iframe->document().url().string().utf8()); |
| 7397 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 7389 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| 7398 } | 7390 } |
| 7399 | 7391 |
| 7400 // Tests that a navigation in a frame with a non-blank initial URL will create | 7392 // Tests that a navigation in a frame with a non-blank initial URL will create |
| 7401 // a new history item, unlike the case above. | 7393 // a new history item, unlike the case above. |
| 7402 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { | 7394 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) { |
| 7403 registerMockedHttpURLLoad("history.html"); | 7395 registerMockedHttpURLLoad("history.html"); |
| 7404 registerMockedHttpURLLoad("find.html"); | 7396 registerMockedHttpURLLoad("find.html"); |
| 7405 | 7397 |
| 7406 TestHistoryWebFrameClient client; | 7398 TestHistoryWebFrameClient client; |
| 7407 FrameTestHelpers::WebViewHelper webViewHelper; | 7399 FrameTestHelpers::WebViewHelper webViewHelper; |
| 7408 webViewHelper.initializeAndLoad("about:blank", true, &client); | 7400 webViewHelper.initializeAndLoad("about:blank", true, &client); |
| 7409 | 7401 |
| 7410 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 7402 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 7411 | 7403 |
| 7412 std::string url1 = m_baseURL + "history.html"; | 7404 std::string url1 = m_baseURL + "history.html"; |
| 7413 FrameTestHelpers::loadFrame( | 7405 FrameTestHelpers::loadFrame( |
| 7414 frame, | 7406 frame, |
| 7415 "javascript:var f = document.createElement('iframe'); " | 7407 "javascript:var f = document.createElement('iframe'); " |
| 7416 "f.src = '" + | 7408 "f.src = '" + |
| 7417 url1 + | 7409 url1 + |
| 7418 "';" | 7410 "';" |
| 7419 "document.body.appendChild(f)"); | 7411 "document.body.appendChild(f)"); |
| 7420 | 7412 |
| 7421 WebFrame* iframe = frame->firstChild(); | 7413 WebFrame* iframe = frame->firstChild(); |
| 7422 EXPECT_EQ(iframe, client.frame()); | |
| 7423 EXPECT_EQ(url1, iframe->document().url().string().utf8()); | 7414 EXPECT_EQ(url1, iframe->document().url().string().utf8()); |
| 7424 | 7415 |
| 7425 std::string url2 = m_baseURL + "find.html"; | 7416 std::string url2 = m_baseURL + "find.html"; |
| 7426 FrameTestHelpers::loadFrame(iframe, url2); | 7417 FrameTestHelpers::loadFrame(iframe, url2); |
| 7427 EXPECT_EQ(iframe, client.frame()); | |
| 7428 EXPECT_EQ(url2, iframe->document().url().string().utf8()); | 7418 EXPECT_EQ(url2, iframe->document().url().string().utf8()); |
| 7429 EXPECT_FALSE(client.replacesCurrentHistoryItem()); | 7419 EXPECT_FALSE(client.replacesCurrentHistoryItem()); |
| 7430 } | 7420 } |
| 7431 | 7421 |
| 7432 // Test verifies that layout will change a layer's scrollable attibutes | 7422 // Test verifies that layout will change a layer's scrollable attibutes |
| 7433 TEST_F(WebFrameTest, overflowHiddenRewrite) { | 7423 TEST_F(WebFrameTest, overflowHiddenRewrite) { |
| 7434 registerMockedHttpURLLoad("non-scrollable.html"); | 7424 registerMockedHttpURLLoad("non-scrollable.html"); |
| 7435 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = | 7425 std::unique_ptr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = |
| 7436 WTF::makeUnique<FakeCompositingWebViewClient>(); | 7426 WTF::makeUnique<FakeCompositingWebViewClient>(); |
| 7437 FrameTestHelpers::WebViewHelper webViewHelper; | 7427 FrameTestHelpers::WebViewHelper webViewHelper; |
| (...skipping 2638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10076 | 10066 |
| 10077 class CallbackOrderingWebFrameClient | 10067 class CallbackOrderingWebFrameClient |
| 10078 : public FrameTestHelpers::TestWebFrameClient { | 10068 : public FrameTestHelpers::TestWebFrameClient { |
| 10079 public: | 10069 public: |
| 10080 CallbackOrderingWebFrameClient() : m_callbackCount(0) {} | 10070 CallbackOrderingWebFrameClient() : m_callbackCount(0) {} |
| 10081 | 10071 |
| 10082 void didStartLoading(bool toDifferentDocument) override { | 10072 void didStartLoading(bool toDifferentDocument) override { |
| 10083 EXPECT_EQ(0, m_callbackCount++); | 10073 EXPECT_EQ(0, m_callbackCount++); |
| 10084 FrameTestHelpers::TestWebFrameClient::didStartLoading(toDifferentDocument); | 10074 FrameTestHelpers::TestWebFrameClient::didStartLoading(toDifferentDocument); |
| 10085 } | 10075 } |
| 10086 void didStartProvisionalLoad(WebLocalFrame*) override { | 10076 void didStartProvisionalLoad(WebDataSource*) override { |
| 10087 EXPECT_EQ(1, m_callbackCount++); | 10077 EXPECT_EQ(1, m_callbackCount++); |
| 10088 } | 10078 } |
| 10089 void didCommitProvisionalLoad(WebLocalFrame*, | 10079 void didCommitProvisionalLoad(WebLocalFrame*, |
| 10090 const WebHistoryItem&, | 10080 const WebHistoryItem&, |
| 10091 WebHistoryCommitType) override { | 10081 WebHistoryCommitType) override { |
| 10092 EXPECT_EQ(2, m_callbackCount++); | 10082 EXPECT_EQ(2, m_callbackCount++); |
| 10093 } | 10083 } |
| 10094 void didFinishDocumentLoad(WebLocalFrame*) override { | 10084 void didFinishDocumentLoad(WebLocalFrame*) override { |
| 10095 EXPECT_EQ(3, m_callbackCount++); | 10085 EXPECT_EQ(3, m_callbackCount++); |
| 10096 } | 10086 } |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11257 | 11247 |
| 11258 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11248 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
| 11259 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11249 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
| 11260 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11250 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
| 11261 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11251 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
| 11262 | 11252 |
| 11263 webViewHelper.reset(); | 11253 webViewHelper.reset(); |
| 11264 } | 11254 } |
| 11265 | 11255 |
| 11266 } // namespace blink | 11256 } // namespace blink |
| OLD | NEW |