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 5525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5536 webViewHelper.initialize(true, &webFrameClient, &webViewClient); | 5536 webViewHelper.initialize(true, &webFrameClient, &webViewClient); |
5537 runPendingTasks(); | 5537 runPendingTasks(); |
5538 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5538 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5539 | 5539 |
5540 // Create another window that will try to access it. | 5540 // Create another window that will try to access it. |
5541 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5541 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
5542 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); | 5542 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5543 runPendingTasks(); | 5543 runPendingTasks(); |
5544 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5544 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5545 | 5545 |
5546 // Access the initial document by modifying the body. We normally set a | 5546 // Access the initial document by modifying the body. |
5547 // timer to notify the client. | |
5548 newView->mainFrame()->executeScript( | 5547 newView->mainFrame()->executeScript( |
5549 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; | 5548 WebScriptSource("window.opener.document.body.innerHTML += 'Modified';"))
; |
5550 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5549 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5551 | 5550 |
5552 // Make sure that a modal dialog forces us to notify right away. | 5551 // Run a modal dialog, which used to run a nested message loop and require |
| 5552 // a special case for notifying about the access. |
5553 newView->mainFrame()->executeScript( | 5553 newView->mainFrame()->executeScript( |
5554 WebScriptSource("window.opener.confirm('Modal');")); | 5554 WebScriptSource("window.opener.confirm('Modal');")); |
5555 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5555 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5556 | 5556 |
5557 // Ensure that we don't notify again later. | 5557 // Ensure that we don't notify again later. |
5558 runPendingTasks(); | 5558 runPendingTasks(); |
5559 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5559 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5560 } | 5560 } |
5561 | 5561 |
5562 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 | 5562 // Fails on the WebKit XP (deps) bot. http://crbug.com/312192 |
(...skipping 13 matching lines...) Expand all Loading... |
5576 runPendingTasks(); | 5576 runPendingTasks(); |
5577 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5577 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5578 | 5578 |
5579 // Create another window that will try to access it. | 5579 // Create another window that will try to access it. |
5580 FrameTestHelpers::WebViewHelper newWebViewHelper(this); | 5580 FrameTestHelpers::WebViewHelper newWebViewHelper(this); |
5581 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); | 5581 WebView* newView = newWebViewHelper.initializeWithOpener(webViewHelper.webVi
ew()->mainFrame(), true); |
5582 runPendingTasks(); | 5582 runPendingTasks(); |
5583 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5583 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); |
5584 | 5584 |
5585 // Access the initial document with document.write, which moves us past the | 5585 // Access the initial document with document.write, which moves us past the |
5586 // initial empty document state of the state machine. We normally set a | 5586 // initial empty document state of the state machine. |
5587 // timer to notify the client. | |
5588 newView->mainFrame()->executeScript( | 5587 newView->mainFrame()->executeScript( |
5589 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); | 5588 WebScriptSource("window.opener.document.write('Modified'); window.opener
.document.close();")); |
5590 EXPECT_FALSE(webFrameClient.m_didAccessInitialDocument); | 5589 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5591 | 5590 |
5592 // Make sure that a modal dialog forces us to notify right away. | 5591 // Run a modal dialog, which used to run a nested message loop and require |
| 5592 // a special case for notifying about the access. |
5593 newView->mainFrame()->executeScript( | 5593 newView->mainFrame()->executeScript( |
5594 WebScriptSource("window.opener.confirm('Modal');")); | 5594 WebScriptSource("window.opener.confirm('Modal');")); |
5595 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5595 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5596 | 5596 |
5597 // Ensure that we don't notify again later. | 5597 // Ensure that we don't notify again later. |
5598 runPendingTasks(); | 5598 runPendingTasks(); |
5599 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); | 5599 EXPECT_TRUE(webFrameClient.m_didAccessInitialDocument); |
5600 } | 5600 } |
5601 | 5601 |
5602 class TestScrolledFrameClient : public FrameTestHelpers::TestWebFrameClient { | 5602 class TestScrolledFrameClient : public FrameTestHelpers::TestWebFrameClient { |
(...skipping 3266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8869 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); | 8869 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); |
8870 helper.webView()->mainFrameImpl()->loadRequest(request); | 8870 helper.webView()->mainFrameImpl()->loadRequest(request); |
8871 | 8871 |
8872 // Normally, the result of the JS url replaces the existing contents on the | 8872 // Normally, the result of the JS url replaces the existing contents on the |
8873 // Document. However, if the JS triggers a navigation, the contents should | 8873 // Document. However, if the JS triggers a navigation, the contents should |
8874 // not be replaced. | 8874 // not be replaced. |
8875 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame())->document(
)->documentElement()->innerText()); | 8875 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame())->document(
)->documentElement()->innerText()); |
8876 } | 8876 } |
8877 | 8877 |
8878 } // namespace blink | 8878 } // namespace blink |
OLD | NEW |