OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/test/base/chrome_render_view_test.h" | 5 #include "chrome/test/base/chrome_render_view_test.h" |
6 #include "content/public/renderer/render_frame.h" | 6 #include "content/public/renderer/render_frame.h" |
7 #include "content/public/test/frame_load_waiter.h" | 7 #include "content/public/test/frame_load_waiter.h" |
8 #include "extensions/renderer/script_context.h" | 8 #include "extensions/renderer/script_context.h" |
9 #include "third_party/WebKit/public/web/WebDocument.h" | 9 #include "third_party/WebKit/public/web/WebDocument.h" |
10 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 10 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
12 | 12 |
13 using blink::WebLocalFrame; | 13 using blink::WebLocalFrame; |
14 | 14 |
15 namespace extensions { | 15 namespace extensions { |
16 namespace { | 16 namespace { |
17 | 17 |
18 class ScriptContextTest : public ChromeRenderViewTest { | 18 class ScriptContextTest : public ChromeRenderViewTest { |
19 protected: | 19 protected: |
20 GURL GetEffectiveDocumentURL(const WebLocalFrame* frame) { | 20 GURL GetEffectiveDocumentURL(WebLocalFrame* frame) { |
21 return ScriptContext::GetEffectiveDocumentURL( | 21 return ScriptContext::GetEffectiveDocumentURL( |
22 frame, frame->GetDocument().Url(), true); | 22 frame, frame->GetDocument().Url(), true); |
23 } | 23 } |
24 }; | 24 }; |
25 | 25 |
26 TEST_F(ScriptContextTest, GetEffectiveDocumentURL) { | 26 TEST_F(ScriptContextTest, GetEffectiveDocumentURL) { |
27 GURL top_url("http://example.com/"); | 27 GURL top_url("http://example.com/"); |
28 GURL different_url("http://example.net/"); | 28 GURL different_url("http://example.net/"); |
29 GURL blank_url("about:blank"); | 29 GURL blank_url("about:blank"); |
30 GURL srcdoc_url("about:srcdoc"); | 30 GURL srcdoc_url("about:srcdoc"); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 EXPECT_EQ(GetEffectiveDocumentURL(frame2_1), blank_url); | 89 EXPECT_EQ(GetEffectiveDocumentURL(frame2_1), blank_url); |
90 | 90 |
91 // top -> different origin = different origin | 91 // top -> different origin = different origin |
92 EXPECT_EQ(GetEffectiveDocumentURL(frame3), different_url); | 92 EXPECT_EQ(GetEffectiveDocumentURL(frame3), different_url); |
93 // top -> different origin -> about:blank = inherit | 93 // top -> different origin -> about:blank = inherit |
94 EXPECT_EQ(GetEffectiveDocumentURL(frame3_1), different_url); | 94 EXPECT_EQ(GetEffectiveDocumentURL(frame3_1), different_url); |
95 } | 95 } |
96 | 96 |
97 } // namespace | 97 } // namespace |
98 } // namespace extensions | 98 } // namespace extensions |
OLD | NEW |