Chromium Code Reviews| 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" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 const extensions::Extension* extension = | 23 const extensions::Extension* extension = |
| 24 LoadExtension(test_data_dir_.AppendASCII("mime_handler_view")); | 24 LoadExtension(test_data_dir_.AppendASCII("mime_handler_view")); |
| 25 if (!extension) | 25 if (!extension) |
| 26 return nullptr; | 26 return nullptr; |
| 27 | 27 |
| 28 CHECK_EQ(std::string(kExtensionId), extension->id()); | 28 CHECK_EQ(std::string(kExtensionId), extension->id()); |
| 29 | 29 |
| 30 return extension; | 30 return extension; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void RunTest(const std::string& path) { | 33 void RunTestWithUrl(const GURL& url) { |
| 34 const extensions::Extension* extension = LoadTestExtension(); | 34 const extensions::Extension* extension = LoadTestExtension(); |
| 35 ASSERT_TRUE(extension); | 35 ASSERT_TRUE(extension); |
| 36 | 36 |
| 37 extensions::ResultCatcher catcher; | |
| 38 ui_test_utils::NavigateToURL(browser(), url); | |
| 39 | |
| 40 if (!catcher.GetNextResult()) | |
| 41 FAIL() << catcher.message(); | |
| 42 } | |
| 43 | |
| 44 void RunTest(const std::string& path) { | |
| 37 ASSERT_TRUE(StartEmbeddedTestServer()); | 45 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 38 embedded_test_server()->ServeFilesFromDirectory( | 46 embedded_test_server()->ServeFilesFromDirectory( |
| 39 test_data_dir_.AppendASCII("mime_handler_view")); | 47 test_data_dir_.AppendASCII("mime_handler_view")); |
| 40 | 48 |
| 41 extensions::ResultCatcher catcher; | 49 RunTestWithUrl(embedded_test_server()->GetURL("/" + path)); |
| 42 | |
| 43 ui_test_utils::NavigateToURL(browser(), | |
| 44 embedded_test_server()->GetURL("/" + path)); | |
| 45 | |
| 46 if (!catcher.GetNextResult()) | |
| 47 FAIL() << catcher.message(); | |
| 48 } | 50 } |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, PostMessage) { | 53 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, PostMessage) { |
| 52 RunTest("test_postmessage.html"); | 54 RunTest("test_postmessage.html"); |
| 53 } | 55 } |
| 54 | 56 |
| 55 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Basic) { | 57 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Basic) { |
| 56 RunTest("testBasic.csv"); | 58 RunTest("testBasic.csv"); |
| 57 } | 59 } |
| 58 | 60 |
| 59 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Embedded) { | 61 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Embedded) { |
| 60 RunTest("test_embedded.html"); | 62 RunTest("test_embedded.html"); |
| 61 } | 63 } |
| 62 | 64 |
| 63 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Iframe) { | 65 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Iframe) { |
| 64 RunTest("test_iframe.html"); | 66 RunTest("test_iframe.html"); |
| 65 } | 67 } |
| 66 | 68 |
| 67 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Abort) { | 69 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Abort) { |
| 68 RunTest("testAbort.csv"); | 70 RunTest("testAbort.csv"); |
| 69 } | 71 } |
| 72 | |
| 73 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, DataUrl) { | |
| 74 const char* kDataUrlCsv = "data:text/csv;base64,Y29udGVudCB0byByZWFkCg=="; | |
|
Sam McNally
2015/04/22 04:05:03
Would this navigation have bypassed the browser pr
raymes
2015/04/22 04:11:48
No, this one would have worked. The one below woul
| |
| 75 RunTestWithUrl(GURL(kDataUrlCsv)); | |
| 76 } | |
| 77 | |
| 78 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, EmbeddedDataUrl) { | |
| 79 RunTest("test_embedded_data_url.html"); | |
| 80 } | |
| OLD | NEW |