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

Unified Diff: Source/web/tests/WebFrameTest.cpp

Issue 86413004: Notify the client of a document access even if document.write is used. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index b240e69a745ca39d28020bdf2d99665650a3ed1a..3e395a9444f830d3c7861c0b318d42fed50b7b6e 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -4443,6 +4443,38 @@ TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog)
EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
}
+TEST_F(WebFrameTest, DidWriteToInitialDocumentBeforeModalDialog)
+{
+ TestAccessInitialDocumentWebFrameClient webFrameClient;
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initialize(true, &webFrameClient);
+ runPendingTasks();
+ EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
+
+ // Create another window that will try to access it.
+ FrameTestHelpers::WebViewHelper newWebViewHelper;
+ WebView* newView = newWebViewHelper.initialize(true);
+ newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame());
+ runPendingTasks();
+ EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
+
+ // Access the initial document with document.write, which moves us past the
+ // initial empty document state of the state machine. We normally set a
+ // timer to notify the client.
+ newView->mainFrame()->executeScript(
+ WebScriptSource("window.opener.document.write('Modified');"));
+ EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
+
+ // Make sure that a modal dialog forces us to notify right away.
+ newView->mainFrame()->executeScript(
+ WebScriptSource("window.opener.confirm('Modal');"));
+ EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
+
+ // Ensure that we don't notify again later.
+ runPendingTasks();
+ EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
+}
+
class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient {
public:
TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); }
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698