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 7454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7465 localFrame->setCommittedFirstRealLoad(); | 7465 localFrame->setCommittedFirstRealLoad(); |
7466 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7466 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
7467 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); | 7467 EXPECT_EQ(WebStandardCommit, client.historyCommitType()); |
7468 | 7468 |
7469 // Manually reset to break WebViewHelper's dependency on the stack allocated | 7469 // Manually reset to break WebViewHelper's dependency on the stack allocated |
7470 // TestWebFrameClient. | 7470 // TestWebFrameClient. |
7471 reset(); | 7471 reset(); |
7472 remoteFrame->close(); | 7472 remoteFrame->close(); |
7473 } | 7473 } |
7474 | 7474 |
7475 // The uniqueName should be preserved when swapping to a RemoteFrame and back, | |
7476 // whether the frame has a name or not. | |
7477 TEST_F(WebFrameSwapTest, UniqueNameAfterRemoteToLocalSwap) | |
7478 { | |
7479 // Start with a named frame. | |
7480 WebFrame* targetFrame = mainFrame()->firstChild(); | |
7481 ASSERT_TRUE(targetFrame); | |
7482 WebString uniqueName = targetFrame->uniqueName(); | |
7483 EXPECT_EQ("frame1", uniqueName.utf8()); | |
7484 | |
7485 // Swap to a RemoteFrame. | |
7486 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient; | |
7487 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient); | |
7488 targetFrame->swap(remoteFrame); | |
7489 ASSERT_TRUE(mainFrame()->firstChild()); | |
7490 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame); | |
7491 EXPECT_EQ(uniqueName.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame)->fr ame()->tree().uniqueName()).utf8()); | |
7492 | |
7493 // Swap back to a LocalFrame. | |
dcheng
2015/11/25 23:43:26
Do we actually swap the local frame back in?
Charlie Reis
2015/11/25 23:54:59
Yep. I just confirmed that the FrameTestHelpers::
dcheng
2015/11/26 01:01:50
Looking around more, it seems like some tests expl
dcheng
2015/11/26 02:02:34
OK, I see how this works now. This is fine (it hap
| |
7494 RemoteToLocalSwapWebFrameClient client(remoteFrame); | |
7495 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , &client); | |
7496 localFrame->initializeToReplaceRemoteFrame(remoteFrame, "frame1", WebSandbox Flags::None, WebFrameOwnerProperties()); | |
7497 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | |
7498 EXPECT_EQ(uniqueName.utf8(), localFrame->uniqueName().utf8()); | |
7499 EXPECT_EQ(uniqueName.utf8(), WebString(toWebLocalFrameImpl(localFrame)->fram e()->loader().currentItem()->target()).utf8()); | |
7500 | |
7501 // Repeat with no name on the frame. | |
7502 localFrame->setName(""); | |
7503 WebString uniqueName2 = localFrame->uniqueName(); | |
7504 EXPECT_EQ("<!--framePath //<!--frame2-->-->", uniqueName2.utf8()); | |
7505 | |
7506 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | |
7507 WebRemoteFrame* remoteFrame2 = WebRemoteFrame::create(WebTreeScopeType::Docu ment, &remoteFrameClient2); | |
7508 localFrame->swap(remoteFrame2); | |
7509 ASSERT_TRUE(mainFrame()->firstChild()); | |
7510 ASSERT_EQ(mainFrame()->firstChild(), remoteFrame2); | |
7511 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebRemoteFrameImpl(remoteFrame2)-> frame()->tree().uniqueName()).utf8()); | |
7512 | |
7513 RemoteToLocalSwapWebFrameClient client2(remoteFrame2); | |
7514 WebLocalFrame* localFrame2 = WebLocalFrame::create(WebTreeScopeType::Documen t, &client2); | |
7515 localFrame2->initializeToReplaceRemoteFrame(remoteFrame2, "", WebSandboxFlag s::None, WebFrameOwnerProperties()); | |
7516 FrameTestHelpers::loadFrame(localFrame2, m_baseURL + "subframe-hello.html"); | |
7517 EXPECT_EQ(uniqueName2.utf8(), localFrame2->uniqueName().utf8()); | |
7518 EXPECT_EQ(uniqueName2.utf8(), WebString(toWebLocalFrameImpl(localFrame2)->fr ame()->loader().currentItem()->target()).utf8()); | |
7519 | |
7520 // Manually reset to break WebViewHelper's dependency on the stack allocated | |
7521 // TestWebFrameClient. | |
7522 reset(); | |
7523 remoteFrame->close(); | |
7524 remoteFrame2->close(); | |
7525 } | |
7526 | |
7475 class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient { | 7527 class RemoteNavigationClient : public FrameTestHelpers::TestWebRemoteFrameClient { |
7476 public: | 7528 public: |
7477 void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry) override | 7529 void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry) override |
7478 { | 7530 { |
7479 m_lastRequest = request; | 7531 m_lastRequest = request; |
7480 } | 7532 } |
7481 | 7533 |
7482 const WebURLRequest& lastRequest() const { return m_lastRequest; } | 7534 const WebURLRequest& lastRequest() const { return m_lastRequest; } |
7483 | 7535 |
7484 private: | 7536 private: |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8322 | 8374 |
8323 TEST_F(WebFrameTest, CallbackOrdering) | 8375 TEST_F(WebFrameTest, CallbackOrdering) |
8324 { | 8376 { |
8325 registerMockedHttpURLLoad("foo.html"); | 8377 registerMockedHttpURLLoad("foo.html"); |
8326 FrameTestHelpers::WebViewHelper webViewHelper; | 8378 FrameTestHelpers::WebViewHelper webViewHelper; |
8327 CallbackOrderingWebFrameClient client; | 8379 CallbackOrderingWebFrameClient client; |
8328 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); | 8380 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); |
8329 } | 8381 } |
8330 | 8382 |
8331 } // namespace blink | 8383 } // namespace blink |
OLD | NEW |