| 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 6966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6977 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t
o | 6977 // FIXME: Refactor some of this logic into WebViewHelper to make it easier t
o |
| 6978 // write tests with a top-level remote frame. | 6978 // write tests with a top-level remote frame. |
| 6979 FrameTestHelpers::TestWebViewClient viewClient; | 6979 FrameTestHelpers::TestWebViewClient viewClient; |
| 6980 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 6980 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
| 6981 WebView* view = WebView::create(&viewClient); | 6981 WebView* view = WebView::create(&viewClient); |
| 6982 view->setMainFrame(remoteClient.frame()); | 6982 view->setMainFrame(remoteClient.frame()); |
| 6983 FrameTestHelpers::TestWebFrameClient childFrameClient; | 6983 FrameTestHelpers::TestWebFrameClient childFrameClient; |
| 6984 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr, WebFrameOwnerProperties()); | 6984 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr, WebFrameOwnerProperties()); |
| 6985 | 6985 |
| 6986 // Purposely keep the LocalFrame alive so it's the last thing to be destroye
d. | 6986 // Purposely keep the LocalFrame alive so it's the last thing to be destroye
d. |
| 6987 RefPtrWillBePersistent<Frame> childCoreFrame = toCoreFrame(childFrame); | 6987 RefPtrWillBePersistent<Frame> childCoreFrame = childFrame->toImplBase()->fra
me(); |
| 6988 view->close(); | 6988 view->close(); |
| 6989 childCoreFrame.clear(); | 6989 childCoreFrame.clear(); |
| 6990 } | 6990 } |
| 6991 | 6991 |
| 6992 class WebFrameSwapTest : public WebFrameTest { | 6992 class WebFrameSwapTest : public WebFrameTest { |
| 6993 protected: | 6993 protected: |
| 6994 WebFrameSwapTest() | 6994 WebFrameSwapTest() |
| 6995 { | 6995 { |
| 6996 registerMockedHttpURLLoad("frame-a-b-c.html"); | 6996 registerMockedHttpURLLoad("frame-a-b-c.html"); |
| 6997 registerMockedHttpURLLoad("subframe-a.html"); | 6997 registerMockedHttpURLLoad("subframe-a.html"); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7519 | 7519 |
| 7520 KURL destination = toKURL("data:text/html:destination"); | 7520 KURL destination = toKURL("data:text/html:destination"); |
| 7521 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow)
; | 7521 mainWindow->open(destination.string(), "frame1", "", mainWindow, mainWindow)
; |
| 7522 ASSERT_FALSE(remoteClient.lastRequest().isNull()); | 7522 ASSERT_FALSE(remoteClient.lastRequest().isNull()); |
| 7523 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); | 7523 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); |
| 7524 | 7524 |
| 7525 // Pointing a named frame to an empty URL should just return a reference to | 7525 // Pointing a named frame to an empty URL should just return a reference to |
| 7526 // the frame's window without navigating it. | 7526 // the frame's window without navigating it. |
| 7527 RefPtrWillBeRawPtr<DOMWindow> result = mainWindow->open("", "frame1", "", ma
inWindow, mainWindow); | 7527 RefPtrWillBeRawPtr<DOMWindow> result = mainWindow->open("", "frame1", "", ma
inWindow, mainWindow); |
| 7528 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); | 7528 EXPECT_EQ(remoteClient.lastRequest().url(), WebURL(destination)); |
| 7529 EXPECT_EQ(result, toCoreFrame(remoteFrame)->domWindow()); | 7529 EXPECT_EQ(result, remoteFrame->toImplBase()->frame()->domWindow()); |
| 7530 | 7530 |
| 7531 reset(); | 7531 reset(); |
| 7532 } | 7532 } |
| 7533 | 7533 |
| 7534 class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient { | 7534 class RemoteWindowCloseClient : public FrameTestHelpers::TestWebViewClient { |
| 7535 public: | 7535 public: |
| 7536 RemoteWindowCloseClient() | 7536 RemoteWindowCloseClient() |
| 7537 : m_closed(false) | 7537 : m_closed(false) |
| 7538 { | 7538 { |
| 7539 } | 7539 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7550 }; | 7550 }; |
| 7551 | 7551 |
| 7552 TEST_F(WebFrameTest, WindowOpenRemoteClose) | 7552 TEST_F(WebFrameTest, WindowOpenRemoteClose) |
| 7553 { | 7553 { |
| 7554 FrameTestHelpers::WebViewHelper mainWebView; | 7554 FrameTestHelpers::WebViewHelper mainWebView; |
| 7555 mainWebView.initialize(true); | 7555 mainWebView.initialize(true); |
| 7556 | 7556 |
| 7557 // Create a remote window that will be closed later in the test. | 7557 // Create a remote window that will be closed later in the test. |
| 7558 RemoteWindowCloseClient viewClient; | 7558 RemoteWindowCloseClient viewClient; |
| 7559 FrameTestHelpers::TestWebRemoteFrameClient frameClient; | 7559 FrameTestHelpers::TestWebRemoteFrameClient frameClient; |
| 7560 WebRemoteFrame* webRemoteFrame = frameClient.frame(); | 7560 WebRemoteFrameImpl* webRemoteFrame = frameClient.frame(); |
| 7561 | 7561 |
| 7562 WebView* view = WebView::create(&viewClient); | 7562 WebView* view = WebView::create(&viewClient); |
| 7563 view->setMainFrame(webRemoteFrame); | 7563 view->setMainFrame(webRemoteFrame); |
| 7564 view->mainFrame()->setOpener(mainWebView.webView()->mainFrame()); | 7564 view->mainFrame()->setOpener(mainWebView.webView()->mainFrame()); |
| 7565 webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("htt
p://127.0.0.1")); | 7565 webRemoteFrame->setReplicatedOrigin(WebSecurityOrigin::createFromString("htt
p://127.0.0.1")); |
| 7566 | 7566 |
| 7567 LocalFrame* localFrame = toLocalFrame(toCoreFrame(mainWebView.webView()->mai
nFrame())); | 7567 LocalFrame* localFrame = toLocalFrame(mainWebView.webView()->mainFrame()->to
ImplBase()->frame()); |
| 7568 RemoteFrame* remoteFrame = toRemoteFrame(toCoreFrame(frameClient.frame())); | 7568 RemoteFrame* remoteFrame = webRemoteFrame->frame(); |
| 7569 | 7569 |
| 7570 // Attempt to close the window, which should fail as it isn't opened | 7570 // Attempt to close the window, which should fail as it isn't opened |
| 7571 // by a script. | 7571 // by a script. |
| 7572 remoteFrame->domWindow()->close(localFrame->document()); | 7572 remoteFrame->domWindow()->close(localFrame->document()); |
| 7573 EXPECT_FALSE(viewClient.closed()); | 7573 EXPECT_FALSE(viewClient.closed()); |
| 7574 | 7574 |
| 7575 // Marking it as opened by a script should now allow it to be closed. | 7575 // Marking it as opened by a script should now allow it to be closed. |
| 7576 remoteFrame->page()->setOpenedByDOM(); | 7576 remoteFrame->page()->setOpenedByDOM(); |
| 7577 remoteFrame->domWindow()->close(localFrame->document()); | 7577 remoteFrame->domWindow()->close(localFrame->document()); |
| 7578 EXPECT_TRUE(viewClient.closed()); | 7578 EXPECT_TRUE(viewClient.closed()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7648 private: | 7648 private: |
| 7649 WebHistoryCommitType m_historyCommitType; | 7649 WebHistoryCommitType m_historyCommitType; |
| 7650 }; | 7650 }; |
| 7651 | 7651 |
| 7652 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) | 7652 TEST_P(ParameterizedWebFrameTest, RemoteFrameInitialCommitType) |
| 7653 { | 7653 { |
| 7654 FrameTestHelpers::TestWebViewClient viewClient; | 7654 FrameTestHelpers::TestWebViewClient viewClient; |
| 7655 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7655 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
| 7656 WebView* view = WebView::create(&viewClient); | 7656 WebView* view = WebView::create(&viewClient); |
| 7657 view->setMainFrame(remoteClient.frame()); | 7657 view->setMainFrame(remoteClient.frame()); |
| 7658 toRemoteFrame(toCoreFrame(view->mainFrame()))->securityContext()->setReplica
tedOrigin(SecurityOrigin::create(toKURL(m_baseURL))); | 7658 remoteClient.frame()->setReplicatedOrigin(WebSecurityOrigin::createFromStrin
g(WebString::fromUTF8(m_baseURL))); |
| 7659 | 7659 |
| 7660 // If an iframe has a remote main frame, ensure the inital commit is correct
ly identified as WebInitialCommitInChildFrame. | 7660 // If an iframe has a remote main frame, ensure the inital commit is correct
ly identified as WebInitialCommitInChildFrame. |
| 7661 CommitTypeWebFrameClient childFrameClient; | 7661 CommitTypeWebFrameClient childFrameClient; |
| 7662 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr, WebFrameOwnerProperties()); | 7662 WebLocalFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createLoc
alChild(WebTreeScopeType::Document, "", WebSandboxFlags::None, &childFrameClient
, nullptr, WebFrameOwnerProperties()); |
| 7663 registerMockedHttpURLLoad("foo.html"); | 7663 registerMockedHttpURLLoad("foo.html"); |
| 7664 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); | 7664 FrameTestHelpers::loadFrame(childFrame, m_baseURL + "foo.html"); |
| 7665 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType()
); | 7665 EXPECT_EQ(WebInitialCommitInChildFrame, childFrameClient.historyCommitType()
); |
| 7666 view->close(); | 7666 view->close(); |
| 7667 } | 7667 } |
| 7668 | 7668 |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8322 | 8322 |
| 8323 TEST_F(WebFrameTest, CallbackOrdering) | 8323 TEST_F(WebFrameTest, CallbackOrdering) |
| 8324 { | 8324 { |
| 8325 registerMockedHttpURLLoad("foo.html"); | 8325 registerMockedHttpURLLoad("foo.html"); |
| 8326 FrameTestHelpers::WebViewHelper webViewHelper; | 8326 FrameTestHelpers::WebViewHelper webViewHelper; |
| 8327 CallbackOrderingWebFrameClient client; | 8327 CallbackOrderingWebFrameClient client; |
| 8328 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); | 8328 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true, &client); |
| 8329 } | 8329 } |
| 8330 | 8330 |
| 8331 } // namespace blink | 8331 } // namespace blink |
| OLD | NEW |