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

Side by Side 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 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
« no previous file with comments | « Source/core/loader/FrameLoader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4425 matching lines...) Expand 10 before | Expand all | Expand 10 after
4436 // Make sure that a modal dialog forces us to notify right away. 4436 // Make sure that a modal dialog forces us to notify right away.
4437 newView->mainFrame()->executeScript( 4437 newView->mainFrame()->executeScript(
4438 WebScriptSource("window.opener.confirm('Modal');")); 4438 WebScriptSource("window.opener.confirm('Modal');"));
4439 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); 4439 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
4440 4440
4441 // Ensure that we don't notify again later. 4441 // Ensure that we don't notify again later.
4442 runPendingTasks(); 4442 runPendingTasks();
4443 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); 4443 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
4444 } 4444 }
4445 4445
4446 TEST_F(WebFrameTest, DidWriteToInitialDocumentBeforeModalDialog)
4447 {
4448 TestAccessInitialDocumentWebFrameClient webFrameClient;
4449 FrameTestHelpers::WebViewHelper webViewHelper;
4450 webViewHelper.initialize(true, &webFrameClient);
4451 runPendingTasks();
4452 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
4453
4454 // Create another window that will try to access it.
4455 FrameTestHelpers::WebViewHelper newWebViewHelper;
4456 WebView* newView = newWebViewHelper.initialize(true);
4457 newView->mainFrame()->setOpener(webViewHelper.webView()->mainFrame());
4458 runPendingTasks();
4459 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
4460
4461 // Access the initial document with document.write, which moves us past the
4462 // initial empty document state of the state machine. We normally set a
4463 // timer to notify the client.
4464 newView->mainFrame()->executeScript(
4465 WebScriptSource("window.opener.document.write('Modified');"));
4466 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
4467
4468 // Make sure that a modal dialog forces us to notify right away.
4469 newView->mainFrame()->executeScript(
4470 WebScriptSource("window.opener.confirm('Modal');"));
4471 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
4472
4473 // Ensure that we don't notify again later.
4474 runPendingTasks();
4475 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
4476 }
4477
4446 class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient { 4478 class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient {
4447 public: 4479 public:
4448 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); } 4480 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); }
4449 void reset() 4481 void reset()
4450 { 4482 {
4451 m_didScrollMainFrame = false; 4483 m_didScrollMainFrame = false;
4452 m_wasProgrammaticScroll = false; 4484 m_wasProgrammaticScroll = false;
4453 } 4485 }
4454 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat icScroll; } 4486 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat icScroll; }
4455 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro grammaticScroll; } 4487 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro grammaticScroll; }
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4884 4916
4885 FrameTestHelpers::loadFrame(frame, 4917 FrameTestHelpers::loadFrame(frame,
4886 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html ')"); 4918 "javascript:window.frames[1].location.assign('" + m_baseURL + "find.html ')");
4887 runPendingTasks(); 4919 runPendingTasks();
4888 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(); 4920 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
4889 EXPECT_EQ(client.frame(), iframe); 4921 EXPECT_EQ(client.frame(), iframe);
4890 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 4922 EXPECT_FALSE(client.replacesCurrentHistoryItem());
4891 } 4923 }
4892 4924
4893 } // namespace 4925 } // namespace
OLDNEW
« 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