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

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

Issue 23710021: Merge 157196 "Don't wait to notify client of spoof attempt if a ..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1599/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/page/PageGroupLoadDeferrer.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 3305 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 3316
3317 // Access the initial document from a javascript: URL. 3317 // Access the initial document from a javascript: URL.
3318 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod y.appendChild(document.createTextNode('Modified'))"); 3318 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod y.appendChild(document.createTextNode('Modified'))");
3319 runPendingTasks(); 3319 runPendingTasks();
3320 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); 3320 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
3321 3321
3322 m_webView->close(); 3322 m_webView->close();
3323 m_webView = 0; 3323 m_webView = 0;
3324 } 3324 }
3325 3325
3326 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog)
3327 {
3328 TestAccessInitialDocumentWebFrameClient webFrameClient;
3329 m_webView = FrameTestHelpers::createWebView(true, &webFrameClient);
3330 runPendingTasks();
3331 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
3332
3333 // Create another window that will try to access it.
3334 WebView* newView = FrameTestHelpers::createWebView(true);
3335 newView->mainFrame()->setOpener(m_webView->mainFrame());
3336 runPendingTasks();
3337 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
3338
3339 // Access the initial document by modifying the body. We normally set a
3340 // timer to notify the client.
3341 newView->mainFrame()->executeScript(
3342 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';")) ;
3343 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument);
3344
3345 // Make sure that a modal dialog forces us to notify right away.
3346 newView->mainFrame()->executeScript(
3347 WebScriptSource("window.opener.confirm('Modal');"));
3348 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
3349
3350 // Ensure that we don't notify again later.
3351 runPendingTasks();
3352 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument);
3353
3354 newView->close();
3355 m_webView->close();
3356 m_webView = 0;
3357 }
3358
3326 class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient { 3359 class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient {
3327 public: 3360 public:
3328 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); } 3361 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); }
3329 void reset() 3362 void reset()
3330 { 3363 {
3331 m_didScrollMainFrame = false; 3364 m_didScrollMainFrame = false;
3332 m_wasProgrammaticScroll = false; 3365 m_wasProgrammaticScroll = false;
3333 } 3366 }
3334 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat icScroll; } 3367 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat icScroll; }
3335 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro grammaticScroll; } 3368 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro grammaticScroll; }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h tml", true, 0, &client); 3647 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h tml", true, 0, &client);
3615 runPendingTasks(); 3648 runPendingTasks();
3616 3649
3617 EXPECT_EQ(client.startLoadingCount(), 2); 3650 EXPECT_EQ(client.startLoadingCount(), 2);
3618 EXPECT_EQ(client.stopLoadingCount(), 2); 3651 EXPECT_EQ(client.stopLoadingCount(), 2);
3619 m_webView->close(); 3652 m_webView->close();
3620 m_webView = 0; 3653 m_webView = 0;
3621 } 3654 }
3622 3655
3623 } // namespace 3656 } // namespace
OLDNEW
« no previous file with comments | « Source/core/page/PageGroupLoadDeferrer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698