| 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 5503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5514 // WebViewHelper destructor. | 5514 // WebViewHelper destructor. |
| 5515 FrameTestHelpers::TestWebViewClient webViewClient; | 5515 FrameTestHelpers::TestWebViewClient webViewClient; |
| 5516 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5516 TestAccessInitialDocumentWebFrameClient webFrameClient; |
| 5517 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5517 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 5518 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5518 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
| 5519 runPendingTasks(); | 5519 runPendingTasks(); |
| 5520 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5520 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5521 | 5521 |
| 5522 // Create another window that will try to access it. | 5522 // Create another window that will try to access it. |
| 5523 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5523 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
| 5524 WebView* newView = newWebViewHelper.initialize(true); | 5524 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
| 5525 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | |
| 5526 runPendingTasks(); | 5525 runPendingTasks(); |
| 5527 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5526 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5528 | 5527 |
| 5529 // Access the initial document to get to the navigator object. | 5528 // Access the initial document to get to the navigator object. |
| 5530 newView->mainFrame()->executeScript( | 5529 newView->mainFrame()->executeScript( |
| 5531 WebScriptSource("console.log(window.opener.navigator);")); | 5530 WebScriptSource("console.log(window.opener.navigator);")); |
| 5532 runPendingTasks(); | 5531 runPendingTasks(); |
| 5533 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5532 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
| 5534 } | 5533 } |
| 5535 | 5534 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5558 // WebViewHelper destructor. | 5557 // WebViewHelper destructor. |
| 5559 FrameTestHelpers::TestWebViewClient webViewClient; | 5558 FrameTestHelpers::TestWebViewClient webViewClient; |
| 5560 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5559 TestAccessInitialDocumentWebFrameClient webFrameClient; |
| 5561 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5560 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 5562 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5561 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
| 5563 runPendingTasks(); | 5562 runPendingTasks(); |
| 5564 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5563 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5565 | 5564 |
| 5566 // Create another window that will try to access it. | 5565 // Create another window that will try to access it. |
| 5567 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5566 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
| 5568 WebView* newView = newWebViewHelper.initialize(true); | 5567 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
| 5569 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | |
| 5570 runPendingTasks(); | 5568 runPendingTasks(); |
| 5571 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5569 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5572 | 5570 |
| 5573 // Access the initial document by modifying the body. We normally set a | 5571 // Access the initial document by modifying the body. We normally set a |
| 5574 // timer to notify the client. | 5572 // timer to notify the client. |
| 5575 newView->mainFrame()->executeScript( | 5573 newView->mainFrame()->executeScript( |
| 5576 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 5574 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
| 5577 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5575 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5578 | 5576 |
| 5579 // Make sure that a modal dialog forces us to notify right away. | 5577 // Make sure that a modal dialog forces us to notify right away. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5598 // WebViewHelper destructor. | 5596 // WebViewHelper destructor. |
| 5599 FrameTestHelpers::TestWebViewClient webViewClient; | 5597 FrameTestHelpers::TestWebViewClient webViewClient; |
| 5600 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5598 TestAccessInitialDocumentWebFrameClient webFrameClient; |
| 5601 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5599 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 5602 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5600 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
| 5603 runPendingTasks(); | 5601 runPendingTasks(); |
| 5604 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5602 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5605 | 5603 |
| 5606 // Create another window that will try to access it. | 5604 // Create another window that will try to access it. |
| 5607 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5605 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
| 5608 WebView* newView = newWebViewHelper.initialize(true); | 5606 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
| 5609 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | |
| 5610 runPendingTasks(); | 5607 runPendingTasks(); |
| 5611 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5608 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5612 | 5609 |
| 5613 // Access the initial document with document.write, which moves us past the | 5610 // Access the initial document with document.write, which moves us past the |
| 5614 // initial empty document state of the state machine. We normally set a | 5611 // initial empty document state of the state machine. We normally set a |
| 5615 // timer to notify the client. | 5612 // timer to notify the client. |
| 5616 newView->mainFrame()->executeScript( | 5613 newView->mainFrame()->executeScript( |
| 5617 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); | 5614 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); |
| 5618 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5615 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 5619 | 5616 |
| (...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7208 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient1); | 7205 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient1); |
| 7209 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); | 7206 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); |
| 7210 EXPECT_TRUE(targetFrame); | 7207 EXPECT_TRUE(targetFrame); |
| 7211 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); | 7208 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); |
| 7212 | 7209 |
| 7213 targetFrame = mainFrame()->firstChild()->nextSibling(); | 7210 targetFrame = mainFrame()->firstChild()->nextSibling(); |
| 7214 EXPECT_TRUE(targetFrame); | 7211 EXPECT_TRUE(targetFrame); |
| 7215 | 7212 |
| 7216 // Create child frames in the target frame before testing the swap. | 7213 // Create child frames in the target frame before testing the swap. |
| 7217 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | 7214 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
| 7218 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco
peType::Document, "", "uniqueName0", WebSandboxFlags::None, &remoteFrameClient2)
; | 7215 WebRemoteFrame* childRemoteFrame = FrameTestHelpers::createRemoteChild(remot
eFrame, &remoteFrameClient2); |
| 7219 | 7216 |
| 7220 FrameTestHelpers::TestWebFrameClient client; | 7217 FrameTestHelpers::TestWebFrameClient client; |
| 7221 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7218 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); |
| 7222 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); | 7219 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
| 7223 | 7220 |
| 7224 // FIXME: This almost certainly fires more load events on the iframe element | 7221 // FIXME: This almost certainly fires more load events on the iframe element |
| 7225 // than it should. | 7222 // than it should. |
| 7226 // Finally, make sure an embedder triggered load in the local frame swapped | 7223 // Finally, make sure an embedder triggered load in the local frame swapped |
| 7227 // back in works. | 7224 // back in works. |
| 7228 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7225 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7791 EXPECT_FALSE(client.failed()); | 7788 EXPECT_FALSE(client.failed()); |
| 7792 } | 7789 } |
| 7793 | 7790 |
| 7794 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame) | 7791 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame) |
| 7795 { | 7792 { |
| 7796 FrameTestHelpers::TestWebViewClient viewClient; | 7793 FrameTestHelpers::TestWebViewClient viewClient; |
| 7797 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7794 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
| 7798 WebView* view = WebView::create(&viewClient); | 7795 WebView* view = WebView::create(&viewClient); |
| 7799 view->setMainFrame(remoteClient.frame()); | 7796 view->setMainFrame(remoteClient.frame()); |
| 7800 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; | 7797 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; |
| 7801 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild(WebTreeScopeType::Document, "", "uniqueName1", WebSandboxFlags::None,
&childFrameClient); | 7798 WebRemoteFrame* childFrame = FrameTestHelpers::createRemoteChild(view->mainF
rame()->toWebRemoteFrame(), &childFrameClient); |
| 7802 childFrame->detach(); | 7799 childFrame->detach(); |
| 7803 view->close(); | 7800 view->close(); |
| 7804 childFrame->close(); | 7801 childFrame->close(); |
| 7805 } | 7802 } |
| 7806 | 7803 |
| 7807 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 7804 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
| 7808 public: | 7805 public: |
| 7809 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const
WebString& sourceName, unsigned sourceLine, const WebString& stackTrace) | 7806 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const
WebString& sourceName, unsigned sourceLine, const WebString& stackTrace) |
| 7810 { | 7807 { |
| 7811 messages.append(message); | 7808 messages.append(message); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8434 } | 8431 } |
| 8435 | 8432 |
| 8436 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) | 8433 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) |
| 8437 { | 8434 { |
| 8438 swapLocalFrameToRemoteFrame(); | 8435 swapLocalFrameToRemoteFrame(); |
| 8439 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); | 8436 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); |
| 8440 EXPECT_FALSE(remoteFrameClient()->isVisible()); | 8437 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
| 8441 } | 8438 } |
| 8442 | 8439 |
| 8443 } // namespace blink | 8440 } // namespace blink |
| OLD | NEW |