| 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(); }
|
|
|