Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 1685003002: Plumb the correct owner document through DocumentInit::m_owner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
7269 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient1); 7265 WebRemoteFrame* remoteFrame = WebRemoteFrame::create(WebTreeScopeType::Docum ent, &remoteFrameClient1);
7270 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling(); 7266 WebFrame* targetFrame = mainFrame()->firstChild()->nextSibling();
7271 EXPECT_TRUE(targetFrame); 7267 EXPECT_TRUE(targetFrame);
7272 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame); 7268 swapAndVerifySubframeConsistency("local->remote", targetFrame, remoteFrame);
7273 7269
7274 targetFrame = mainFrame()->firstChild()->nextSibling(); 7270 targetFrame = mainFrame()->firstChild()->nextSibling();
7275 EXPECT_TRUE(targetFrame); 7271 EXPECT_TRUE(targetFrame);
7276 7272
7277 // Create child frames in the target frame before testing the swap. 7273 // Create child frames in the target frame before testing the swap.
7278 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2; 7274 FrameTestHelpers::TestWebRemoteFrameClient remoteFrameClient2;
7279 WebRemoteFrame* childRemoteFrame = remoteFrame->createRemoteChild(WebTreeSco peType::Document, "", "uniqueName0", WebSandboxFlags::None, &remoteFrameClient2) ; 7275 WebRemoteFrame* childRemoteFrame = FrameTestHelpers::createRemoteChild(remot eFrame, &remoteFrameClient2);
7280 7276
7281 FrameTestHelpers::TestWebFrameClient client; 7277 FrameTestHelpers::TestWebFrameClient client;
7282 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties()); 7278 WebLocalFrame* localFrame = WebLocalFrame::createProvisional(&client, remote Frame, WebSandboxFlags::None, WebFrameOwnerProperties());
7283 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame); 7279 swapAndVerifySubframeConsistency("remote->local", targetFrame, localFrame);
7284 7280
7285 // FIXME: This almost certainly fires more load events on the iframe element 7281 // FIXME: This almost certainly fires more load events on the iframe element
7286 // than it should. 7282 // than it should.
7287 // Finally, make sure an embedder triggered load in the local frame swapped 7283 // Finally, make sure an embedder triggered load in the local frame swapped
7288 // back in works. 7284 // back in works.
7289 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html"); 7285 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "subframe-hello.html");
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
7852 EXPECT_FALSE(client.failed()); 7848 EXPECT_FALSE(client.failed());
7853 } 7849 }
7854 7850
7855 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame) 7851 TEST_P(ParameterizedWebFrameTest, DetachRemoteFrame)
7856 { 7852 {
7857 FrameTestHelpers::TestWebViewClient viewClient; 7853 FrameTestHelpers::TestWebViewClient viewClient;
7858 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7854 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7859 WebView* view = WebView::create(&viewClient); 7855 WebView* view = WebView::create(&viewClient);
7860 view->setMainFrame(remoteClient.frame()); 7856 view->setMainFrame(remoteClient.frame());
7861 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient; 7857 FrameTestHelpers::TestWebRemoteFrameClient childFrameClient;
7862 WebRemoteFrame* childFrame = view->mainFrame()->toWebRemoteFrame()->createRe moteChild(WebTreeScopeType::Document, "", "uniqueName1", WebSandboxFlags::None, &childFrameClient); 7858 WebRemoteFrame* childFrame = FrameTestHelpers::createRemoteChild(view->mainF rame()->toWebRemoteFrame(), &childFrameClient);
7863 childFrame->detach(); 7859 childFrame->detach();
7864 view->close(); 7860 view->close();
7865 childFrame->close(); 7861 childFrame->close();
7866 } 7862 }
7867 7863
7868 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient { 7864 class TestConsoleMessageWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient {
7869 public: 7865 public:
7870 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine, const WebString& stackTrace) 7866 virtual void didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine, const WebString& stackTrace)
7871 { 7867 {
7872 messages.append(message); 7868 messages.append(message);
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
8528 } 8524 }
8529 8525
8530 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) 8526 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange)
8531 { 8527 {
8532 swapLocalFrameToRemoteFrame(); 8528 swapLocalFrameToRemoteFrame();
8533 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';")); 8529 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';"));
8534 EXPECT_FALSE(remoteFrameClient()->isVisible()); 8530 EXPECT_FALSE(remoteFrameClient()->isVisible());
8535 } 8531 }
8536 8532
8537 } // namespace blink 8533 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698