OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2534 " C = http://bar.com/\n" | 2534 " C = http://bar.com/\n" |
2535 " D = http://baz.com/", | 2535 " D = http://baz.com/", |
2536 DepictFrameTree(popup_root)); | 2536 DepictFrameTree(popup_root)); |
2537 | 2537 |
2538 // Send a message from first subframe on main page to the first popup and | 2538 // Send a message from first subframe on main page to the first popup and |
2539 // wait for a reply back. The reply verifies that the proxy for the opener | 2539 // wait for a reply back. The reply verifies that the proxy for the opener |
2540 // tab's subframe is targeted properly. | 2540 // tab's subframe is targeted properly. |
2541 PostMessageAndWaitForReply(root->child_at(0), "postToPopup('subframe-msg')", | 2541 PostMessageAndWaitForReply(root->child_at(0), "postToPopup('subframe-msg')", |
2542 "\"done-subframe1\""); | 2542 "\"done-subframe1\""); |
2543 | 2543 |
2544 // TODO(alexmos): Once we propagate subframe opener information to new | 2544 // Send a postMessage from the popup to window.opener and ensure that it |
2545 // RenderViews, try sending a postMessage from the popup to window.opener and | 2545 // reaches subframe1. This verifies that the subframe opener information |
2546 // ensure that it reaches subframe1. | 2546 // propagated to the popup's RenderViews. Wait for subframe1 to send a reply |
nasko
2015/07/07 16:26:21
RenderViews? I thought we are tracking openers per
alexmos
2015/07/08 04:42:18
Oops, fixed.
| |
2547 // message to the popup. | |
2548 EXPECT_TRUE(ExecuteScript(popup->web_contents(), "window.name = 'popup';")); | |
2549 PostMessageAndWaitForReply(popup_root, "postToOpener('subframe-msg', '*')", | |
2550 "\"done-popup\""); | |
2547 | 2551 |
2548 // Verify the total number of received messages for each subframe. First | 2552 // Second a postMessage from popup2 to window.opener.opener, which should |
2549 // subframe and popup should have one message each, and other frames | 2553 // resolve to subframe1. This tests opener chains of length greater than 1. |
2550 // shouldn't have received any messages. | 2554 // As before, subframe1 will send a reply to popup2. |
2555 FrameTreeNode* popup2_root = | |
2556 static_cast<WebContentsImpl*>(popup2->web_contents()) | |
2557 ->GetFrameTree() | |
2558 ->root(); | |
2559 EXPECT_TRUE(ExecuteScript(popup2->web_contents(), "window.name = 'popup2';")); | |
2560 PostMessageAndWaitForReply(popup2_root, | |
2561 "postToOpenerOfOpener('subframe-msg', '*')", | |
2562 "\"done-popup2\""); | |
2563 | |
2564 // Verify the total number of received messages for each subframe: | |
2565 // - 3 for first subframe (two from first popup, one from second popup) | |
2566 // - 2 for popup (both from first subframe) | |
2567 // - 1 for popup2 (reply from first subframe) | |
2568 // - 0 for other frames | |
2551 EXPECT_EQ(0, GetReceivedMessages(root)); | 2569 EXPECT_EQ(0, GetReceivedMessages(root)); |
2552 EXPECT_EQ(1, GetReceivedMessages(root->child_at(0))); | 2570 EXPECT_EQ(3, GetReceivedMessages(root->child_at(0))); |
2553 EXPECT_EQ(0, GetReceivedMessages(root->child_at(1))); | 2571 EXPECT_EQ(0, GetReceivedMessages(root->child_at(1))); |
2554 EXPECT_EQ(1, GetReceivedMessages(popup_root)); | 2572 EXPECT_EQ(2, GetReceivedMessages(popup_root)); |
2573 EXPECT_EQ(1, GetReceivedMessages(popup2_root)); | |
2555 } | 2574 } |
2556 | 2575 |
2557 // Check that parent.frames[num] references correct sibling frames when the | 2576 // Check that parent.frames[num] references correct sibling frames when the |
2558 // parent is remote. See https://crbug.com/478792. | 2577 // parent is remote. See https://crbug.com/478792. |
2559 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, IndexedFrameAccess) { | 2578 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, IndexedFrameAccess) { |
2560 // Start on a page with three same-site subframes. | 2579 // Start on a page with three same-site subframes. |
2561 GURL main_url( | 2580 GURL main_url( |
2562 embedded_test_server()->GetURL("a.com", "/frame_tree/top.html")); | 2581 embedded_test_server()->GetURL("a.com", "/frame_tree/top.html")); |
2563 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2582 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2564 | 2583 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2689 " |--Site A\n" | 2708 " |--Site A\n" |
2690 " +--Site A\n" | 2709 " +--Site A\n" |
2691 " |--Site A\n" | 2710 " |--Site A\n" |
2692 " +--Site A\n" | 2711 " +--Site A\n" |
2693 " +--Site A\n" | 2712 " +--Site A\n" |
2694 "Where A = http://127.0.0.1/", | 2713 "Where A = http://127.0.0.1/", |
2695 DepictFrameTree(root)); | 2714 DepictFrameTree(root)); |
2696 } | 2715 } |
2697 | 2716 |
2698 } // namespace content | 2717 } // namespace content |
OLD | NEW |