| 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 "content/public/renderer/render_frame.h" | 6 #include "content/public/renderer/render_frame.h" |
| 6 #include "content/public/test/frame_load_waiter.h" | 7 #include "content/public/test/frame_load_waiter.h" |
| 7 #include "content/public/test/render_view_test.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::WebFrame; | 13 using blink::WebFrame; |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class ScriptContextTest : public content::RenderViewTest { | 18 class ScriptContextTest : public ChromeRenderViewTest { |
| 19 protected: | 19 protected: |
| 20 GURL GetEffectiveDocumentURL(const WebFrame* frame) { | 20 GURL GetEffectiveDocumentURL(const WebFrame* frame) { |
| 21 return ScriptContext::GetEffectiveDocumentURL( | 21 return ScriptContext::GetEffectiveDocumentURL( |
| 22 frame, frame->document().url(), true); | 22 frame, frame->document().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/"); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 EXPECT_EQ(GetEffectiveDocumentURL(frame2_1), blank_url); | 82 EXPECT_EQ(GetEffectiveDocumentURL(frame2_1), blank_url); |
| 83 | 83 |
| 84 // top -> different origin = different origin | 84 // top -> different origin = different origin |
| 85 EXPECT_EQ(GetEffectiveDocumentURL(frame3), different_url); | 85 EXPECT_EQ(GetEffectiveDocumentURL(frame3), different_url); |
| 86 // top -> different origin -> about:blank = inherit | 86 // top -> different origin -> about:blank = inherit |
| 87 EXPECT_EQ(GetEffectiveDocumentURL(frame3_1), different_url); | 87 EXPECT_EQ(GetEffectiveDocumentURL(frame3_1), different_url); |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace | 90 } // namespace |
| 91 } // namespace extensions | 91 } // namespace extensions |
| OLD | NEW |