| 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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
| 6 #include "net/dns/mock_host_resolver.h" | 6 #include "net/dns/mock_host_resolver.h" |
| 7 | 7 |
| 8 class ExecuteScriptApiTest : public ExtensionApiTest { | 8 class ExecuteScriptApiTest : public ExtensionApiTest { |
| 9 protected: | 9 protected: |
| 10 void SetupDelayedHostResolver() { | 10 void SetupDelayedHostResolver() { |
| 11 // We need a.com to be a little bit slow to trigger a race condition. | 11 // We need a.com to be a little bit slow to trigger a race condition. |
| 12 host_resolver()->AddRuleWithLatency("a.com", "127.0.0.1", 500); | 12 host_resolver()->AddRuleWithLatency("a.com", "127.0.0.1", 500); |
| 13 host_resolver()->AddRule("b.com", "127.0.0.1"); | 13 host_resolver()->AddRule("b.com", "127.0.0.1"); |
| 14 host_resolver()->AddRule("c.com", "127.0.0.1"); | 14 host_resolver()->AddRule("c.com", "127.0.0.1"); |
| 15 } | 15 } |
| 16 }; | 16 }; |
| 17 | 17 |
| 18 // If failing, mark disabled and update http://crbug.com/92105. | 18 // If failing, mark disabled and update http://crbug.com/92105. |
| 19 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptBasic) { | 19 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptBasic) { |
| 20 SetupDelayedHostResolver(); | 20 SetupDelayedHostResolver(); |
| 21 ASSERT_TRUE(StartTestServer()); | 21 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 22 ASSERT_TRUE(RunExtensionTest("executescript/basic")) << message_; | 22 ASSERT_TRUE(RunExtensionTest("executescript/basic")) << message_; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // If failing, mark disabled and update http://crbug.com/92105. | 25 // If failing, mark disabled and update http://crbug.com/92105. |
| 26 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptInFrame) { | 26 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptInFrame) { |
| 27 SetupDelayedHostResolver(); | 27 SetupDelayedHostResolver(); |
| 28 ASSERT_TRUE(StartTestServer()); | 28 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 29 ASSERT_TRUE(RunExtensionTest("executescript/in_frame")) << message_; | 29 ASSERT_TRUE(RunExtensionTest("executescript/in_frame")) << message_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Fails often on Windows. | 32 // Fails often on Windows. |
| 33 // http://crbug.com/174715 | 33 // http://crbug.com/174715 |
| 34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 35 #define MAYBE_ExecuteScriptPermissions DISABLED_ExecuteScriptPermissions | 35 #define MAYBE_ExecuteScriptPermissions DISABLED_ExecuteScriptPermissions |
| 36 #else | 36 #else |
| 37 #define MAYBE_ExecuteScriptPermissions ExecuteScriptPermissions | 37 #define MAYBE_ExecuteScriptPermissions ExecuteScriptPermissions |
| 38 #endif // defined(OS_WIN) | 38 #endif // defined(OS_WIN) |
| 39 | 39 |
| 40 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, MAYBE_ExecuteScriptPermissions) { | 40 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, MAYBE_ExecuteScriptPermissions) { |
| 41 SetupDelayedHostResolver(); | 41 SetupDelayedHostResolver(); |
| 42 ASSERT_TRUE(StartTestServer()); | 42 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 43 ASSERT_TRUE(RunExtensionTest("executescript/permissions")) << message_; | 43 ASSERT_TRUE(RunExtensionTest("executescript/permissions")) << message_; |
| 44 } | 44 } |
| 45 | 45 |
| 46 // If failing, mark disabled and update http://crbug.com/84760. | 46 // If failing, mark disabled and update http://crbug.com/84760. |
| 47 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptFileAfterClose) { | 47 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptFileAfterClose) { |
| 48 host_resolver()->AddRule("b.com", "127.0.0.1"); | 48 host_resolver()->AddRule("b.com", "127.0.0.1"); |
| 49 ASSERT_TRUE(StartTestServer()); | 49 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 50 ASSERT_TRUE(RunExtensionTest("executescript/file_after_close")) << message_; | 50 ASSERT_TRUE(RunExtensionTest("executescript/file_after_close")) << message_; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // If crashing, mark disabled and update http://crbug.com/67774. | 53 // If crashing, mark disabled and update http://crbug.com/67774. |
| 54 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptFragmentNavigation) { | 54 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptFragmentNavigation) { |
| 55 ASSERT_TRUE(StartTestServer()); | 55 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 56 const char* extension_name = "executescript/fragment"; | 56 const char* extension_name = "executescript/fragment"; |
| 57 ASSERT_TRUE(RunExtensionTest(extension_name)) << message_; | 57 ASSERT_TRUE(RunExtensionTest(extension_name)) << message_; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Fails often on Windows dbg bots. http://crbug.com/177163 | 60 // Fails often on Windows dbg bots. http://crbug.com/177163 |
| 61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 62 #define MAYBE_NavigationRaceExecuteScript DISABLED_NavigationRaceExecuteScript | 62 #define MAYBE_NavigationRaceExecuteScript DISABLED_NavigationRaceExecuteScript |
| 63 #else | 63 #else |
| 64 #define MAYBE_NavigationRaceExecuteScript NavigationRaceExecuteScript | 64 #define MAYBE_NavigationRaceExecuteScript NavigationRaceExecuteScript |
| 65 #endif // defined(OS_WIN) | 65 #endif // defined(OS_WIN) |
| 66 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, | 66 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, |
| 67 MAYBE_NavigationRaceExecuteScript) { | 67 MAYBE_NavigationRaceExecuteScript) { |
| 68 host_resolver()->AddRule("a.com", "127.0.0.1"); | 68 host_resolver()->AddRule("a.com", "127.0.0.1"); |
| 69 host_resolver()->AddRule("b.com", "127.0.0.1"); | 69 host_resolver()->AddRule("b.com", "127.0.0.1"); |
| 70 ASSERT_TRUE(StartTestServer()); | 70 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 71 ASSERT_TRUE(RunExtensionSubtest("executescript/navigation_race", | 71 ASSERT_TRUE(RunExtensionSubtest("executescript/navigation_race", |
| 72 "execute_script.html")) << message_; | 72 "execute_script.html")) << message_; |
| 73 } | 73 } |
| 74 | 74 |
| 75 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, NavigationRaceJavaScriptURL) { | 75 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, NavigationRaceJavaScriptURL) { |
| 76 host_resolver()->AddRule("a.com", "127.0.0.1"); | 76 host_resolver()->AddRule("a.com", "127.0.0.1"); |
| 77 host_resolver()->AddRule("b.com", "127.0.0.1"); | 77 host_resolver()->AddRule("b.com", "127.0.0.1"); |
| 78 ASSERT_TRUE(StartTestServer()); | 78 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 79 ASSERT_TRUE(RunExtensionSubtest("executescript/navigation_race", | 79 ASSERT_TRUE(RunExtensionSubtest("executescript/navigation_race", |
| 80 "javascript_url.html")) << message_; | 80 "javascript_url.html")) << message_; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // If failing, mark disabled and update http://crbug.com/92105. | 83 // If failing, mark disabled and update http://crbug.com/92105. |
| 84 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptFrameAfterLoad) { | 84 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptFrameAfterLoad) { |
| 85 SetupDelayedHostResolver(); | 85 SetupDelayedHostResolver(); |
| 86 ASSERT_TRUE(StartTestServer()); | 86 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 87 ASSERT_TRUE(RunExtensionTest("executescript/frame_after_load")) << message_; | 87 ASSERT_TRUE(RunExtensionTest("executescript/frame_after_load")) << message_; |
| 88 } | 88 } |
| 89 | 89 |
| 90 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptRunAt) { | 90 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptRunAt) { |
| 91 SetupDelayedHostResolver(); | 91 SetupDelayedHostResolver(); |
| 92 ASSERT_TRUE(StartTestServer()); | 92 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 93 ASSERT_TRUE(RunExtensionTest("executescript/run_at")) << message_; | 93 ASSERT_TRUE(RunExtensionTest("executescript/run_at")) << message_; |
| 94 } | 94 } |
| 95 | 95 |
| 96 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptCallback) { | 96 IN_PROC_BROWSER_TEST_F(ExecuteScriptApiTest, ExecuteScriptCallback) { |
| 97 SetupDelayedHostResolver(); | 97 SetupDelayedHostResolver(); |
| 98 ASSERT_TRUE(StartTestServer()); | 98 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 99 ASSERT_TRUE(RunExtensionTest("executescript/callback")) << message_; | 99 ASSERT_TRUE(RunExtensionTest("executescript/callback")) << message_; |
| 100 } | 100 } |
| OLD | NEW |