Index: chrome/browser/ui/webui/javascript2webui.js |
diff --git a/chrome/browser/ui/webui/javascript2webui.js b/chrome/browser/ui/webui/javascript2webui.js |
index 3f748cf6bb349c5dfbf835323915be9b9d7d4f96..b2624ebbe315e5b20670d792c138db480824e2e9 100644 |
--- a/chrome/browser/ui/webui/javascript2webui.js |
+++ b/chrome/browser/ui/webui/javascript2webui.js |
@@ -4,36 +4,45 @@ |
if (arguments.length < 3) { |
print('usage: ' + |
arguments[0] + ' path-to-testfile.js testfile.js [output.cc]'); |
- quit(); |
-} |
-var js_file = arguments[1]; |
-var js_file_base = arguments[2]; |
-var outputfile = arguments[3]; |
-var prevfuncs = {}; |
-for (var func in this) { |
- if (this[func] instanceof Function) |
- prevfuncs[func] = func; |
-} |
-var js = load(js_file); |
-if (!('test_fixture' in this)) { |
- print(js_file + ' did not define test_fixture.'); |
quit(-1); |
} |
-if (!('test_add_library' in this)) { |
- this['test_add_library'] = true; |
-} |
+var jsFile = arguments[1]; |
+var jsFileBase = arguments[2]; |
+var outputFile = arguments[3]; |
+var prevFunctions = {}; |
+ |
+// Generate the file to stdout. |
print('// GENERATED FILE'); |
print('// ' + arguments.join(' ')); |
print('// PLEASE DO NOT HAND EDIT!'); |
print(); |
-for (var func in this) { |
- if (!prevfuncs[func] && this[func] instanceof Function) { |
- print('IN_PROC_BROWSER_TEST_F(' + test_fixture + ', ' + func + ') {'); |
- if (test_add_library) |
- print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + js_file_base + |
- '")));'); |
- print(' ASSERT_TRUE(RunJavascriptTest("' + func + '"));'); |
- print('}'); |
- print(); |
+print('#include "chrome/browser/ui/webui/web_ui_browsertest.h"'); |
+print(); |
+ |
+function GEN(code) { |
+ print(code); |
+} |
+ |
+function TEST_F(testFixture, testFunction, testBody) { |
+ var testBrowsePreload = this[testFixture].prototype.browsePreload; |
+ var testBrowsePrintPreload = this[testFixture].prototype.browsePrintPreload; |
+ |
+ print('IN_PROC_BROWSER_TEST_F(' + testFixture + ', ' + testFunction + ') {'); |
+ print(' AddLibrary(FilePath(FILE_PATH_LITERAL("' + jsFileBase + '")));'); |
+ if (testBrowsePreload) { |
+ print(' BrowsePreload(GURL("' + testBrowsePreload + '"), "' + testFixture + |
+ '", "' + testFunction + '");'); |
+ } |
+ if (testBrowsePrintPreload) { |
+ print(' BrowsePrintPreload(GURL(WebUITestDataPathToURL(\n' + |
+ ' FILE_PATH_LITERAL("' + testBrowsePrintPreload + '"))),\n' + |
+ ' "' + testFixture + '", "' + testFunction + '");'); |
} |
+ print(' ASSERT_TRUE(RunJavascriptTestF("' + testFixture + '", "' + |
+ testFunction + '"));'); |
+ print('}'); |
+ print(); |
} |
+ |
+var js = read(jsFile); |
+eval(js); |