| 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 "content/public/test/render_view_test.h" | 5 #include "content/public/test/render_view_test.h" |
| 6 #include "extensions/renderer/script_context.h" | 6 #include "extensions/renderer/script_context.h" |
| 7 #include "third_party/WebKit/public/web/WebDocument.h" | 7 #include "third_party/WebKit/public/web/WebDocument.h" |
| 8 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 8 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 10 | 10 |
| 11 using blink::WebFrame; | 11 using blink::WebFrame; |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class ScriptContextTest : public content::RenderViewTest { | 16 class ScriptContextTest : public content::RenderViewTest { |
| 17 protected: | 17 protected: |
| 18 GURL GetEffectiveDocumentURL(const WebFrame* frame) { | 18 GURL GetEffectiveDocumentURL(const WebFrame* frame) { |
| 19 return ScriptContext::GetEffectiveDocumentURL( | 19 return ScriptContext::GetEffectiveDocumentURL( |
| 20 frame, frame->document().url(), true); | 20 frame, frame->document().url(), true); |
| 21 } | 21 } |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 // ScriptContextTest.GetEffectiveDocumentURL is flaky on Windows | 24 // http://crbug.com/391894 |
| 25 // (http://crbug.com/391894) | 25 TEST_F(ScriptContextTest, DISABLED_GetEffectiveDocumentURL) { |
| 26 #if defined(OS_WIN) | |
| 27 #define MAYBE_GetEffectiveDocumentURL DISABLED_GetEffectiveDocumentURL | |
| 28 #else | |
| 29 #define MAYBE_GetEffectiveDocumentURL GetEffectiveDocumentURL | |
| 30 #endif | |
| 31 | |
| 32 TEST_F(ScriptContextTest, MAYBE_GetEffectiveDocumentURL) { | |
| 33 GURL top_url("http://example.com/"); | 26 GURL top_url("http://example.com/"); |
| 34 GURL different_url("http://example.net/"); | 27 GURL different_url("http://example.net/"); |
| 35 GURL blank_url("about:blank"); | 28 GURL blank_url("about:blank"); |
| 36 GURL srcdoc_url("about:srcdoc"); | 29 GURL srcdoc_url("about:srcdoc"); |
| 37 | 30 |
| 38 const char frame_html[] = | 31 const char frame_html[] = |
| 39 "<iframe name='frame1' srcdoc=\"" | 32 "<iframe name='frame1' srcdoc=\"" |
| 40 " <iframe name='frame1_1'></iframe>" | 33 " <iframe name='frame1_1'></iframe>" |
| 41 " <iframe name='frame1_2' sandbox=''></iframe>" | 34 " <iframe name='frame1_2' sandbox=''></iframe>" |
| 42 "\"></iframe>" | 35 "\"></iframe>" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 EXPECT_EQ(GetEffectiveDocumentURL(frame2_1), blank_url); | 85 EXPECT_EQ(GetEffectiveDocumentURL(frame2_1), blank_url); |
| 93 | 86 |
| 94 // top -> different origin = different origin | 87 // top -> different origin = different origin |
| 95 EXPECT_EQ(GetEffectiveDocumentURL(frame3), different_url); | 88 EXPECT_EQ(GetEffectiveDocumentURL(frame3), different_url); |
| 96 // top -> different origin -> about:blank = inherit | 89 // top -> different origin -> about:blank = inherit |
| 97 EXPECT_EQ(GetEffectiveDocumentURL(frame3_1), different_url); | 90 EXPECT_EQ(GetEffectiveDocumentURL(frame3_1), different_url); |
| 98 } | 91 } |
| 99 | 92 |
| 100 } // namespace | 93 } // namespace |
| 101 } // namespace extensions | 94 } // namespace extensions |
| OLD | NEW |