Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 3012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3023 // With OOPIFs, this navigation used a cross-process transfer. Ensure that | 3023 // With OOPIFs, this navigation used a cross-process transfer. Ensure that |
| 3024 // the iframe's old RFH still has correct origin, even though it's pending | 3024 // the iframe's old RFH still has correct origin, even though it's pending |
| 3025 // deletion. | 3025 // deletion. |
| 3026 if (AreAllSitesIsolatedForTesting()) { | 3026 if (AreAllSitesIsolatedForTesting()) { |
| 3027 EXPECT_FALSE(child_rfh_b->is_active()); | 3027 EXPECT_FALSE(child_rfh_b->is_active()); |
| 3028 EXPECT_NE(child_rfh_b, child->current_frame_host()); | 3028 EXPECT_NE(child_rfh_b, child->current_frame_host()); |
| 3029 EXPECT_EQ(url::Origin(url_b), child_rfh_b->GetLastCommittedOrigin()); | 3029 EXPECT_EQ(url::Origin(url_b), child_rfh_b->GetLastCommittedOrigin()); |
| 3030 } | 3030 } |
| 3031 } | 3031 } |
| 3032 | 3032 |
| 3033 // Ensure that loading a page with a cross-site coreferencing iframe | |
|
alexmos
2017/01/06 02:27:29
nit: s/a cross-site coreferencing iframe/cross-sit
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3034 // does not cause an infinite number of nested iframes to be created. | |
| 3035 // TODO(davidsac): This test should be broken until issue 527367 is resolved. | |
|
alexmos
2017/01/06 02:27:29
I think we can also remove the TODO, right? I don
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3036 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, CoReferencingFrames) { | |
| 3037 // Load a page with a cross-site coreferencing iframe. | |
|
alexmos
2017/01/06 02:27:29
Perhaps add a comment here to clarify what "corefe
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3038 StartEmbeddedServer(); | |
| 3039 GURL url_1( | |
| 3040 embedded_test_server()->GetURL("a.com", "/coreferencingframe_1.html")); | |
| 3041 EXPECT_TRUE(NavigateToURL(shell(), url_1)); | |
| 3042 | |
| 3043 WebContentsImpl* web_contents = | |
| 3044 static_cast<WebContentsImpl*>(shell()->web_contents()); | |
| 3045 | |
| 3046 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
| 3047 | |
| 3048 // The FrameTree contains two successful instances of each site plus an | |
| 3049 // unsuccessfully-navigated third instance of B with a blank URL. The | |
|
alexmos
2017/01/06 02:27:29
nit: I'd move "when outside of site-per-process mo
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3050 // FrameTreeVisualizer depicts all nodes as referencing Site A because iframes | |
| 3051 // are identified with their root site when outside of site-per-process mode. | |
| 3052 if (AreAllSitesIsolatedForTesting()) { | |
| 3053 EXPECT_EQ( | |
| 3054 " Site A ------------ proxies for B\n" | |
| 3055 " +--Site B ------- proxies for A\n" | |
| 3056 " +--Site A -- proxies for B\n" | |
| 3057 " +--Site B -- proxies for A\n" | |
| 3058 " +--Site B -- proxies for A\n" | |
| 3059 "Where A = http://a.com/\n" | |
| 3060 " B = http://b.com/", | |
| 3061 FrameTreeVisualizer().DepictFrameTree(root)); | |
| 3062 } else { | |
| 3063 EXPECT_EQ( | |
| 3064 " Site A\n" | |
| 3065 " +--Site A\n" | |
| 3066 " +--Site A\n" | |
| 3067 " +--Site A\n" | |
| 3068 " +--Site A\n" | |
| 3069 "Where A = http://a.com/", | |
| 3070 FrameTreeVisualizer().DepictFrameTree(root)); | |
| 3071 } | |
| 3072 | |
| 3073 EXPECT_TRUE(root->child_at(0) | |
|
alexmos
2017/01/06 02:27:29
You could declare "FrameTreeNode* bottom_child = r
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3074 ->child_at(0) | |
| 3075 ->child_at(0) | |
| 3076 ->child_at(0) | |
| 3077 ->current_url() | |
| 3078 .is_empty()); | |
| 3079 | |
| 3080 EXPECT_FALSE(root->child_at(0) | |
| 3081 ->child_at(0) | |
| 3082 ->child_at(0) | |
| 3083 ->child_at(0) | |
| 3084 ->has_committed_real_load()); | |
| 3085 } | |
| 3086 | |
| 3087 // Ensure that loading a page with fragments | |
|
alexmos
2017/01/06 02:27:29
Finish the comment to explain what the test is doi
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3088 // TODO(davidsac): This test should be broken until issue 527367 is resolved. | |
| 3089 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | |
| 3090 SelfReferencingFragmentFrames) { | |
| 3091 StartEmbeddedServer(); | |
| 3092 GURL url(embedded_test_server()->GetURL("a.com", "/iframe.html#123")); | |
| 3093 EXPECT_TRUE(NavigateToURL(shell(), url)); | |
| 3094 | |
| 3095 WebContentsImpl* web_contents = | |
| 3096 static_cast<WebContentsImpl*>(shell()->web_contents()); | |
| 3097 | |
| 3098 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
| 3099 FrameTreeNode* child = root->child_at(0); | |
| 3100 | |
| 3101 TestFrameNavigationObserver observer1(child); | |
|
alexmos
2017/01/06 02:27:29
Let's add a comment that it's important to use ren
davidsac (gone - try alexmos)
2017/01/19 18:26:23
Done.
| |
| 3102 EXPECT_TRUE( | |
| 3103 ExecuteScript(child, "location.href = '" + url.spec() + "456" + "';")); | |
| 3104 observer1.Wait(); | |
| 3105 | |
| 3106 FrameTreeNode* grandchild = child->child_at(0); | |
| 3107 | |
| 3108 TestFrameNavigationObserver observer2(grandchild); | |
|
alexmos
2017/01/06 02:27:29
Add a comment that this navigation should be block
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3109 EXPECT_TRUE(ExecuteScript( | |
| 3110 grandchild, "location.href = '" + url.spec() + "456789" + "';")); | |
| 3111 observer2.Wait(); | |
| 3112 | |
| 3113 // The FrameTree contains two successful instances of the url plus an | |
| 3114 // unsuccessfully-navigated third instance with a blank URL. | |
| 3115 EXPECT_EQ( | |
| 3116 " Site A\n" | |
| 3117 " +--Site A\n" | |
| 3118 " +--Site A\n" | |
| 3119 "Where A = http://a.com/", | |
| 3120 FrameTreeVisualizer().DepictFrameTree(root)); | |
| 3121 | |
|
alexmos
2017/01/06 02:27:29
Can you include an EXPECT_EQ() for the grandchild'
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3122 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); | |
| 3123 } | |
| 3124 | |
| 3125 // Ensure that loading a page with a meta refresh iframe | |
|
alexmos
2017/01/06 02:27:29
nit: rewrap comment to 80 lines. Your editor shou
davidsac (gone - try alexmos)
2017/01/19 18:26:24
Done.
| |
| 3126 // does not cause an infinite number of nested iframes to be created. | |
| 3127 // TODO(davidsac): This test should be broken until issue 527367 is resolved. | |
|
alexmos
2017/01/06 02:27:29
Instead of TODO, just reference https://crbug.com/
davidsac (gone - try alexmos)
2017/01/19 18:26:23
Done.
| |
| 3128 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, MetaRefreshFrames) { | |
|
alexmos
2017/01/06 02:27:29
Perhaps add "SelfReferencing" prefix to the test n
davidsac (gone - try alexmos)
2017/01/19 18:26:23
Done.
| |
| 3129 // Load a page with a cross-site coreferencing iframe. | |
| 3130 StartEmbeddedServer(); | |
| 3131 GURL url_1(embedded_test_server()->GetURL( | |
| 3132 "a.com", "/page_with_meta_refresh_frame.html")); | |
| 3133 // TODO(davidsac): add in an expect true here for something? | |
| 3134 NavigateToURLBlockUntilNavigationsComplete(shell(), url_1, 3); | |
| 3135 | |
| 3136 WebContentsImpl* web_contents = | |
| 3137 static_cast<WebContentsImpl*>(shell()->web_contents()); | |
| 3138 | |
| 3139 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
| 3140 | |
| 3141 // The third navigation should fail and be cancelled, leaving a FrameTree with | |
| 3142 // a height of 2. | |
| 3143 EXPECT_EQ( | |
| 3144 " Site A\n" | |
| 3145 " +--Site A\n" | |
| 3146 " +--Site A\n" | |
| 3147 "Where A = http://a.com/", | |
| 3148 FrameTreeVisualizer().DepictFrameTree(root)); | |
| 3149 | |
| 3150 EXPECT_FALSE(root->child_at(0)->current_url().is_empty()); | |
|
alexmos
2017/01/06 02:27:29
Instead of this, can we check that current_url() i
davidsac (gone - try alexmos)
2017/01/19 18:26:23
Done.
| |
| 3151 | |
| 3152 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); | |
| 3153 } | |
| 3154 | |
| 3155 // Ensure that navigating a subframe to the same url as its parent twice in a | |
| 3156 // row is not blocked by the self-reference check. | |
| 3157 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, SameOriginRenavigation) { | |
| 3158 StartEmbeddedServer(); | |
| 3159 GURL url(embedded_test_server()->GetURL("a.com", "/iframe.html")); | |
| 3160 EXPECT_TRUE(NavigateToURL(shell(), url)); | |
| 3161 | |
| 3162 WebContentsImpl* web_contents = | |
| 3163 static_cast<WebContentsImpl*>(shell()->web_contents()); | |
| 3164 | |
| 3165 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
| 3166 FrameTreeNode* child = root->child_at(0); | |
| 3167 | |
| 3168 TestFrameNavigationObserver observer1(child); | |
| 3169 EXPECT_TRUE( | |
| 3170 ExecuteScript(child, "location.href = '" + url.spec() + "#123';")); | |
| 3171 observer1.Wait(); | |
| 3172 | |
| 3173 EXPECT_EQ( | |
| 3174 " Site A\n" | |
| 3175 " +--Site A\n" | |
| 3176 " +--Site A\n" | |
| 3177 "Where A = http://a.com/", | |
| 3178 FrameTreeVisualizer().DepictFrameTree(root)); | |
| 3179 | |
| 3180 GURL url_expected( | |
| 3181 embedded_test_server()->GetURL("a.com", "/iframe.html#123")); | |
| 3182 EXPECT_EQ(child->current_url(), url_expected); | |
| 3183 | |
| 3184 TestFrameNavigationObserver observer2(child); | |
|
alexmos
2017/01/06 02:27:29
This setup is very similar to the test in SelfRefe
davidsac (gone - try alexmos)
2017/01/19 18:26:24
I feel like that would make it a bit confusing wha
alexmos
2017/01/19 23:45:53
Acknowledged.
| |
| 3185 EXPECT_TRUE(ExecuteScript(child, "location.href = '" + url.spec() + "';")); | |
| 3186 observer2.Wait(); | |
| 3187 | |
| 3188 // The FrameTree doesn't change between both loads. | |
| 3189 EXPECT_EQ( | |
| 3190 " Site A\n" | |
| 3191 " +--Site A\n" | |
| 3192 " +--Site A\n" | |
| 3193 "Where A = http://a.com/", | |
| 3194 FrameTreeVisualizer().DepictFrameTree(root)); | |
| 3195 | |
| 3196 EXPECT_EQ(child->current_url(), url); | |
| 3197 } | |
| 3198 | |
| 3033 } // namespace content | 3199 } // namespace content |
| OLD | NEW |