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 7455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7466 localFrame->setCommittedFirstRealLoad(); | 7466 localFrame->setCommittedFirstRealLoad(); |
7467 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7467 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7468 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 7468 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
7469 | 7469 |
7470 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7470 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7471 // TestWebFrameClient. | 7471 // TestWebFrameClient. |
7472 reset(); | 7472 reset(); |
7473 remoteFrame->close(); | 7473 remoteFrame->close(); |
7474 } | 7474 } |
7475 | 7475 |
| 7476 // The uniqueName should be preserved when swapping to a RemoteFrame and back, |
| 7477 // whether the frame has a name or not. |
| 7478 TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap) |
| 7479 { |
| 7480 // Start with a named frame. |
| 7481 WebFrame* targetFrame = mainFrame()->firstChild(); |
| 7482 ASSERT_TRUE(targetFrame); |
| 7483 WebString uniqueName = targetFrame->uniqueName(); |
| 7484 EXPECT_EQ("frame1", uniqueName.utf8()); |
| 7485 |
| 7486 // Swap to a RemoteFrame. |
| 7487 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; |
| 7488 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient); |
| 7489 targetFrame->swap(remoteFrame); |
| 7490 ASSERT_TRUE(mainFrame()->firstChild()); |
| 7491 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); |
| 7492 EXPECT_EQ(uniqueName.utf8(), remoteFrame->uniqueName().utf8()); |
| 7493 |
| 7494 // Swap back to a LocalFrame. |
| 7495 RemoteToLocalSwapWebFrameClient client(remoteFrame); |
| 7496 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document
, &client); |
| 7497 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "frame1", WebSandbox
Flags::None, WebFrameOwnerProperties()); |
| 7498 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); |
| 7499 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| 7500 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); |
| 7501 |
| 7502 // Repeat with no name on the frame. |
| 7503 localFrame->setName(""); |
| 7504 WebString uniqueName2 = localFrame->uniqueName(); |
| 7505 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8()); |
| 7506 |
| 7507 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
| 7508 WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Docu
ment, &remoteFrameClient2); |
| 7509 localFrame->swap(remoteFrame2); |
| 7510 ASSERT_TRUE(mainFrame()->firstChild()); |
| 7511 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); |
| 7512 EXPECT_EQ(uniqueName2.utf8(), remoteFrame2->uniqueName().utf8()); |
| 7513 |
| 7514 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); |
| 7515 WebLocalFrame* localFrame2 = WebLocalFrame::create(WebTreeScopeType::Documen
t, &client2); |
| 7516 localFrame2->initializeToReplaceRemoteFrame(remoteFrame2, "", WebSandboxFlag
s::None, WebFrameOwnerProperties()); |
| 7517 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); |
| 7518 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); |
| 7519 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); |
| 7520 |
| 7521 // Manually reset to break WebViewHelper's dependency on the stack allocated |
| 7522 // TestWebFrameClient. |
| 7523 reset(); |
| 7524 remoteFrame->close(); |
| 7525 remoteFrame2->close(); |
| 7526 } |
| 7527 |
7476 class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient
{ | 7528 class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient
{ |
7477 public: | 7529 public: |
7478 void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry)
override | 7530 void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry)
override |
7479 { | 7531 { |
7480 m_lastRequest = request; | 7532 m_lastRequest = request; |
7481 } | 7533 } |
7482 | 7534 |
7483 const WebURLRequest& lastRequest() const { return m_lastRequest; } | 7535 const WebURLRequest& lastRequest() const { return m_lastRequest; } |
7484 | 7536 |
7485 private: | 7537 private: |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8323 | 8375 |
8324 TEST_F(WebFrameTest, CallbackOrdering) | 8376 TEST_F(WebFrameTest, CallbackOrdering) |
8325 { | 8377 { |
8326 registerMockedHttpURLLoad("foo.html"); | 8378 registerMockedHttpURLLoad("foo.html"); |
8327 FrameTestHelpers::WebViewHelper webViewHelper; | 8379 FrameTestHelpers::WebViewHelper webViewHelper; |
8328 CallbackOrderingWebFrameClient client; | 8380 CallbackOrderingWebFrameClient client; |
8329 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); | 8381 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); |
8330 } | 8382 } |
8331 | 8383 |
8332 } // namespace blink | 8384 } // namespace blink |
OLD | NEW |