OLD | NEW |
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 3288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3299 | 3299 |
3300 // Access the initial document from a javascript: URL. | 3300 // Access the initial document from a javascript: URL. |
3301 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Modified'))"); | 3301 FrameTestHelpers::loadFrame(m_webView->mainFrame(), "javascript:document.bod
y.appendChild(document.createTextNode('Modified'))"); |
3302 runPendingTasks(); | 3302 runPendingTasks(); |
3303 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 3303 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
3304 | 3304 |
3305 m_webView->close(); | 3305 m_webView->close(); |
3306 m_webView = 0; | 3306 m_webView = 0; |
3307 } | 3307 } |
3308 | 3308 |
| 3309 TEST_F(WebFrameTest, DidAccessInitialDocumentBodyBeforeModalDialog) |
| 3310 { |
| 3311 TestAccessInitialDocumentWebFrameClient webFrameClient; |
| 3312 m_webView = FrameTestHelpers::createWebView(true, &webFrameClient); |
| 3313 runPendingTasks(); |
| 3314 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 3315 |
| 3316 // Create another window that will try to access it. |
| 3317 WebView* newView = FrameTestHelpers::createWebView(true); |
| 3318 newView->mainFrame()->setOpener(m_webView->mainFrame()); |
| 3319 runPendingTasks(); |
| 3320 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 3321 |
| 3322 // Access the initial document by modifying the body. We normally set a |
| 3323 // timer to notify the client. |
| 3324 newView->mainFrame()->executeScript( |
| 3325 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
| 3326 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
| 3327 |
| 3328 // Make sure that a modal dialog forces us to notify right away. |
| 3329 newView->mainFrame()->executeScript( |
| 3330 WebScriptSource("window.opener.confirm('Modal');")); |
| 3331 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
| 3332 |
| 3333 // Ensure that we don't notify again later. |
| 3334 runPendingTasks(); |
| 3335 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
| 3336 |
| 3337 newView->close(); |
| 3338 m_webView->close(); |
| 3339 m_webView = 0; |
| 3340 } |
| 3341 |
3309 class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient { | 3342 class TestMainFrameUserOrProgrammaticScrollFrameClient : public WebFrameClient { |
3310 public: | 3343 public: |
3311 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); } | 3344 TestMainFrameUserOrProgrammaticScrollFrameClient() { reset(); } |
3312 void reset() | 3345 void reset() |
3313 { | 3346 { |
3314 m_didScrollMainFrame = false; | 3347 m_didScrollMainFrame = false; |
3315 m_wasProgrammaticScroll = false; | 3348 m_wasProgrammaticScroll = false; |
3316 } | 3349 } |
3317 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } | 3350 bool wasUserScroll() const { return m_didScrollMainFrame && !m_wasProgrammat
icScroll; } |
3318 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } | 3351 bool wasProgrammaticScroll() const { return m_didScrollMainFrame && m_wasPro
grammaticScroll; } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3593 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); | 3626 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h
tml", true, 0, &client); |
3594 runPendingTasks(); | 3627 runPendingTasks(); |
3595 | 3628 |
3596 EXPECT_EQ(client.startLoadingCount(), 2); | 3629 EXPECT_EQ(client.startLoadingCount(), 2); |
3597 EXPECT_EQ(client.stopLoadingCount(), 2); | 3630 EXPECT_EQ(client.stopLoadingCount(), 2); |
3598 m_webView->close(); | 3631 m_webView->close(); |
3599 m_webView = 0; | 3632 m_webView = 0; |
3600 } | 3633 } |
3601 | 3634 |
3602 } // namespace | 3635 } // namespace |
OLD | NEW |