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 5523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5534 // WebViewHelper destructor. | 5534 // WebViewHelper destructor. |
5535 FrameTestHelpers::TestWebViewClient webViewClient; | 5535 FrameTestHelpers::TestWebViewClient webViewClient; |
5536 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5536 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5537 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5537 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5538 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5538 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5539 runPendingTasks(); | 5539 runPendingTasks(); |
5540 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5540 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5541 | 5541 |
5542 // Create another window that will try to access it. | 5542 // Create another window that will try to access it. |
5543 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5543 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
5544 WebView* newView = newWebViewHelper.initialize(true); | 5544 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5545 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | |
5546 runPendingTasks(); | 5545 runPendingTasks(); |
5547 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5546 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5548 | 5547 |
5549 // Access the initial document by modifying the body. | 5548 // Access the initial document by modifying the body. |
5550 newView->mainFrame()->executeScript( | 5549 newView->mainFrame()->executeScript( |
5551 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 5550 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
5552 runPendingTasks(); | 5551 runPendingTasks(); |
5553 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5552 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5554 | 5553 |
5555 // Access the initial document again, to ensure we don't notify twice. | 5554 // Access the initial document again, to ensure we don't notify twice. |
(...skipping 10 matching lines...) Expand all Loading... |
5566 // WebViewHelper destructor. | 5565 // WebViewHelper destructor. |
5567 FrameTestHelpers::TestWebViewClient webViewClient; | 5566 FrameTestHelpers::TestWebViewClient webViewClient; |
5568 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5567 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5569 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5568 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5570 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5569 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5571 runPendingTasks(); | 5570 runPendingTasks(); |
5572 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5571 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5573 | 5572 |
5574 // Create another window that will try to access it. | 5573 // Create another window that will try to access it. |
5575 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5574 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
5576 WebView* newView = newWebViewHelper.initialize(true); | 5575 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5577 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | |
5578 runPendingTasks(); | 5576 runPendingTasks(); |
5579 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5577 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5580 | 5578 |
5581 // Access the initial document to get to the navigator object. | 5579 // Access the initial document to get to the navigator object. |
5582 newView->mainFrame()->executeScript( | 5580 newView->mainFrame()->executeScript( |
5583 WebScriptSource("console.log(window.opener.navigator);")); | 5581 WebScriptSource("console.log(window.opener.navigator);")); |
5584 runPendingTasks(); | 5582 runPendingTasks(); |
5585 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5583 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5586 } | 5584 } |
5587 | 5585 |
(...skipping 22 matching lines...) Expand all Loading... |
5610 // WebViewHelper destructor. | 5608 // WebViewHelper destructor. |
5611 FrameTestHelpers::TestWebViewClient webViewClient; | 5609 FrameTestHelpers::TestWebViewClient webViewClient; |
5612 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5610 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5613 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5611 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5614 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5612 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5615 runPendingTasks(); | 5613 runPendingTasks(); |
5616 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5614 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5617 | 5615 |
5618 // Create another window that will try to access it. | 5616 // Create another window that will try to access it. |
5619 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5617 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
5620 WebView* newView = newWebViewHelper.initialize(true); | 5618 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5621 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | |
5622 runPendingTasks(); | 5619 runPendingTasks(); |
5623 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5620 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5624 | 5621 |
5625 // Access the initial document by modifying the body. We normally set a | 5622 // Access the initial document by modifying the body. We normally set a |
5626 // timer to notify the client. | 5623 // timer to notify the client. |
5627 newView->mainFrame()->executeScript( | 5624 newView->mainFrame()->executeScript( |
5628 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 5625 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
5629 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5626 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5630 | 5627 |
5631 // Make sure that a modal dialog forces us to notify right away. | 5628 // Make sure that a modal dialog forces us to notify right away. |
(...skipping 18 matching lines...) Expand all Loading... |
5650 // WebViewHelper destructor. | 5647 // WebViewHelper destructor. |
5651 FrameTestHelpers::TestWebViewClient webViewClient; | 5648 FrameTestHelpers::TestWebViewClient webViewClient; |
5652 TestAccessInitialDocumentWebFrameClient webFrameClient; | 5649 TestAccessInitialDocumentWebFrameClient webFrameClient; |
5653 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5650 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5654 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5651 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5655 runPendingTasks(); | 5652 runPendingTasks(); |
5656 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5653 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5657 | 5654 |
5658 // Create another window that will try to access it. | 5655 // Create another window that will try to access it. |
5659 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5656 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
5660 WebView* newView = newWebViewHelper.initialize(true); | 5657 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5661 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame()); | |
5662 runPendingTasks(); | 5658 runPendingTasks(); |
5663 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5659 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5664 | 5660 |
5665 // Access the initial document with document.write, which moves us past the | 5661 // Access the initial document with document.write, which moves us past the |
5666 // initial empty document state of the state machine. We normally set a | 5662 // initial empty document state of the state machine. We normally set a |
5667 // timer to notify the client. | 5663 // timer to notify the client. |
5668 newView->mainFrame()->executeScript( | 5664 newView->mainFrame()->executeScript( |
5669 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); | 5665 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); |
5670 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5666 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5671 | 5667 |
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7260 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient1); | 7256 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum
ent, &remoteFrameClient1); |
7261 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); | 7257 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); |
7262 EXPECT_TRUE(targetFrame); | 7258 EXPECT_TRUE(targetFrame); |
7263 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); | 7259 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); |
7264 | 7260 |
7265 targetFrame = mainFrame()->firstChild()->nextSibling(); | 7261 targetFrame = mainFrame()->firstChild()->nextSibling(); |
7266 EXPECT_TRUE(targetFrame); | 7262 EXPECT_TRUE(targetFrame); |
7267 | 7263 |
7268 // Create child frames in the target frame before testing the swap. | 7264 // Create child frames in the target frame before testing the swap. |
7269 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; | 7265 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; |
7270 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco
peType::Document, "", "uniqueName0", WebSandboxFlags::None, &remoteFrameClient2)
; | 7266 WebRemoteFrame* childRemoteFrame = FrameTestHelpers::createRemoteChild(remot
eFrame, &remoteFrameClient2); |
7271 | 7267 |
7272 FrameTestHelpers::TestWebFrameClient client; | 7268 FrameTestHelpers::TestWebFrameClient client; |
7273 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); | 7269 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote
Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); |
7274 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); | 7270 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); |
7275 | 7271 |
7276 // FIXME: This almost certainly fires more load events on the iframe element | 7272 // FIXME: This almost certainly fires more load events on the iframe element |
7277 // than it should. | 7273 // than it should. |
7278 // Finally, make sure an embedder triggered load in the local frame swapped | 7274 // Finally, make sure an embedder triggered load in the local frame swapped |
7279 // back in works. | 7275 // back in works. |
7280 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); | 7276 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7843 EXPECT_FALSE(client.failed()); | 7839 EXPECT_FALSE(client.failed()); |
7844 } | 7840 } |
7845 | 7841 |
7846 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame) | 7842 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame) |
7847 { | 7843 { |
7848 FrameTestHelpers::TestWebViewClient viewClient; | 7844 FrameTestHelpers::TestWebViewClient viewClient; |
7849 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; | 7845 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
7850 WebView* view = WebView::create(&viewClient); | 7846 WebView* view = WebView::create(&viewClient); |
7851 view->setMainFrame(remoteClient.frame()); | 7847 view->setMainFrame(remoteClient.frame()); |
7852 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; | 7848 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; |
7853 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe
moteChild(WebTreeScopeType::Document, "", "uniqueName1", WebSandboxFlags::None,
&childFrameClient); | 7849 WebRemoteFrame* childFrame = FrameTestHelpers::createRemoteChild(view->mainF
rame()->toWebRemoteFrame(), &childFrameClient); |
7854 childFrame->detach(); | 7850 childFrame->detach(); |
7855 view->close(); | 7851 view->close(); |
7856 childFrame->close(); | 7852 childFrame->close(); |
7857 } | 7853 } |
7858 | 7854 |
7859 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 7855 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
7860 public: | 7856 public: |
7861 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const
WebString& sourceName, unsigned sourceLine, const WebString& stackTrace) | 7857 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const
WebString& sourceName, unsigned sourceLine, const WebString& stackTrace) |
7862 { | 7858 { |
7863 messages.append(message); | 7859 messages.append(message); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8519 } | 8515 } |
8520 | 8516 |
8521 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) | 8517 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) |
8522 { | 8518 { |
8523 swapLocalFrameToRemoteFrame(); | 8519 swapLocalFrameToRemoteFrame(); |
8524 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); | 8520 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p
arentElement.style.display = 'none';")); |
8525 EXPECT_FALSE(remoteFrameClient()->isVisible()); | 8521 EXPECT_FALSE(remoteFrameClient()->isVisible()); |
8526 } | 8522 } |
8527 | 8523 |
8528 } // namespace blink | 8524 } // namespace blink |
OLD | NEW |