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 "content/test/layout_browsertest.h" | 5 #include "content/test/layout_browsertest.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 void ScrapeResultFromBrowser(content::Shell* window, std::string* actual_text) { | 60 void ScrapeResultFromBrowser(content::Shell* window, std::string* actual_text) { |
61 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( | 61 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString( |
62 window->web_contents()->GetRenderViewHost(), | 62 window->web_contents()->GetRenderViewHost(), |
63 L"", | 63 L"", |
64 L"window.domAutomationController.send(document.body.innerText);", | 64 L"window.domAutomationController.send(document.body.innerText);", |
65 actual_text)); | 65 actual_text)); |
66 } | 66 } |
67 | 67 |
68 static const std::string preamble = | 68 static const std::string preamble = |
69 "\n<script>\n" | 69 "\n<script>\n" |
70 "function LayoutTestController() {\n" | 70 "function TestRunner() {\n" |
71 " this.wait_until_done_ = false;\n" | 71 " this.wait_until_done_ = false;\n" |
72 " this.dumpAsText = function () {};\n" | 72 " this.dumpAsText = function () {};\n" |
73 " this.waitUntilDone = function () {\n" | 73 " this.waitUntilDone = function () {\n" |
74 " this.wait_until_done_ = true;\n" | 74 " this.wait_until_done_ = true;\n" |
75 " }\n" | 75 " }\n" |
76 " this.notifyDone = function () {\n" | 76 " this.notifyDone = function () {\n" |
77 " document.title = 'done';\n" | 77 " document.title = 'done';\n" |
78 " }\n" | 78 " }\n" |
79 " this.overridePreference = function () {}\n" | 79 " this.overridePreference = function () {}\n" |
80 " this.OnEvent = function () {\n" | 80 " this.OnEvent = function () {\n" |
81 " if (!layoutTestController.wait_until_done_)\n" | 81 " if (!testRunner.wait_until_done_)\n" |
82 " layoutTestController.notifyDone();\n" | 82 " testRunner.notifyDone();\n" |
83 " }\n" | 83 " }\n" |
84 " this.workerThreadCount = 0; \n" | 84 " this.workerThreadCount = 0; \n" |
85 "}\n" | 85 "}\n" |
86 "window.layoutTestController = new LayoutTestController();\n" | 86 "window.testRunner = new TestRunner();\n" |
87 "window.testRunner = window.layoutTestController;\n" | 87 "window.addEventListener('load', testRunner.OnEvent, false);\n" |
88 "window.addEventListener('load', layoutTestController.OnEvent, false);\n" | |
89 "</script>"; | 88 "</script>"; |
90 | 89 |
91 } | 90 } |
92 | 91 |
93 InProcessBrowserLayoutTest::InProcessBrowserLayoutTest( | 92 InProcessBrowserLayoutTest::InProcessBrowserLayoutTest( |
94 const FilePath& test_parent_dir, const FilePath& test_case_dir) | 93 const FilePath& test_parent_dir, const FilePath& test_case_dir) |
95 : test_parent_dir_(test_parent_dir), test_case_dir_(test_case_dir), | 94 : test_parent_dir_(test_parent_dir), test_case_dir_(test_case_dir), |
96 port_(-2) { | 95 port_(-2) { |
97 } | 96 } |
98 | 97 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 ASSERT_TRUE(file_util::ReadFileToString(path_to_single_test, &test_html)); | 249 ASSERT_TRUE(file_util::ReadFileToString(path_to_single_test, &test_html)); |
251 | 250 |
252 size_t insertion_position = FindInsertPosition(test_html); | 251 size_t insertion_position = FindInsertPosition(test_html); |
253 test_html.insert(insertion_position, preamble); | 252 test_html.insert(insertion_position, preamble); |
254 *test_path = our_layout_test_temp_dir_.Append(test_case_dir_); | 253 *test_path = our_layout_test_temp_dir_.Append(test_case_dir_); |
255 *test_path = test_path->AppendASCII(test_case_file_name); | 254 *test_path = test_path->AppendASCII(test_case_file_name); |
256 ASSERT_TRUE(file_util::WriteFile(*test_path, | 255 ASSERT_TRUE(file_util::WriteFile(*test_path, |
257 &test_html.at(0), | 256 &test_html.at(0), |
258 static_cast<int>(test_html.size()))); | 257 static_cast<int>(test_html.size()))); |
259 } | 258 } |
OLD | NEW |