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