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 "base/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
11 #include "extensions/browser/extension_registry.h" | 11 #include "extensions/browser/extension_registry.h" |
12 #include "extensions/test/result_catcher.h" | 12 #include "extensions/test/result_catcher.h" |
| 13 #include "net/test/embedded_test_server/embedded_test_server.h" |
13 | 14 |
14 // The test extension id is set by the key value in the manifest. | 15 // The test extension id is set by the key value in the manifest. |
15 const char* kExtensionId = "oickdpebdnfbgkcaoklfcdhjniefkcji"; | 16 const char* kExtensionId = "oickdpebdnfbgkcaoklfcdhjniefkcji"; |
16 | 17 |
17 class MimeHandlerViewTest : public ExtensionApiTest { | 18 class MimeHandlerViewTest : public ExtensionApiTest { |
18 public: | 19 public: |
19 ~MimeHandlerViewTest() override {} | 20 ~MimeHandlerViewTest() override {} |
20 | 21 |
21 const extensions::Extension* LoadTestExtension() { | 22 const extensions::Extension* LoadTestExtension() { |
22 const extensions::Extension* extension = LoadExtension( | 23 const extensions::Extension* extension = |
23 test_data_dir_.AppendASCII("mime_handler_view")); | 24 LoadExtension(test_data_dir_.AppendASCII("mime_handler_view")); |
24 if (!extension) | 25 if (!extension) |
25 return nullptr; | 26 return nullptr; |
26 | 27 |
27 CHECK_EQ(std::string(kExtensionId), extension->id()); | 28 CHECK_EQ(std::string(kExtensionId), extension->id()); |
28 | 29 |
29 return extension; | 30 return extension; |
30 } | 31 } |
31 | 32 |
32 void RunTest(const std::string& path) { | 33 void RunTest(const std::string& path) { |
33 const extensions::Extension* extension = LoadTestExtension(); | 34 const extensions::Extension* extension = LoadTestExtension(); |
34 ASSERT_TRUE(extension); | 35 ASSERT_TRUE(extension); |
35 | 36 |
| 37 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 38 embedded_test_server()->ServeFilesFromDirectory( |
| 39 test_data_dir_.AppendASCII("mime_handler_view")); |
| 40 |
36 extensions::ResultCatcher catcher; | 41 extensions::ResultCatcher catcher; |
37 | 42 |
38 GURL extension_url("chrome-extension://" + std::string(kExtensionId) + "/" + | 43 ui_test_utils::NavigateToURL(browser(), |
39 path); | 44 embedded_test_server()->GetURL("/" + path)); |
40 ui_test_utils::NavigateToURL(browser(), extension_url); | |
41 | 45 |
42 if (!catcher.GetNextResult()) | 46 if (!catcher.GetNextResult()) |
43 FAIL() << catcher.message(); | 47 FAIL() << catcher.message(); |
44 } | 48 } |
45 }; | 49 }; |
46 | 50 |
47 // Not working on Windows because of crbug.com/443466. | 51 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, PostMessage) { |
48 #if defined(OS_WIN) | |
49 #define MAYBE_PostMessage DISABLED_PostMessage | |
50 #define MAYBE_Basic DISABLED_Basic | |
51 #define MAYBE_Embedded DISABLED_Embedded | |
52 #define MAYBE_Abort DISABLED_Abort | |
53 #else | |
54 #define MAYBE_PostMessage PostMessage | |
55 #define MAYBE_Basic Basic | |
56 #define MAYBE_Embedded Embedded | |
57 #define MAYBE_Abort Abort | |
58 #endif | |
59 | |
60 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, MAYBE_PostMessage) { | |
61 RunTest("test_postmessage.html"); | 52 RunTest("test_postmessage.html"); |
62 } | 53 } |
63 | 54 |
64 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, MAYBE_Basic) { | 55 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Basic) { |
65 RunTest("testBasic.csv"); | 56 RunTest("testBasic.csv"); |
66 } | 57 } |
67 | 58 |
68 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, MAYBE_Embedded) { | 59 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Embedded) { |
69 RunTest("test_embedded.html"); | 60 RunTest("test_embedded.html"); |
70 } | 61 } |
71 | 62 |
72 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, MAYBE_Abort) { | 63 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Iframe) { |
| 64 RunTest("test_iframe.html"); |
| 65 } |
| 66 |
| 67 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Abort) { |
73 RunTest("testAbort.csv"); | 68 RunTest("testAbort.csv"); |
74 } | 69 } |
OLD | NEW |