Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/renderer/extensions/json_schema_unittest.cc

Issue 12647017: Lazily require types when validating Extensions API calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/common/chrome_paths.h" 8 #include "chrome/common/chrome_paths.h"
9 #include "chrome/test/base/v8_unit_test.h" 9 #include "chrome/test/base/v8_unit_test.h"
10 #include "grit/renderer_resources.h" 10 #include "grit/renderer_resources.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // Add the json schema code to the context. 26 // Add the json schema code to the context.
27 std::string code = ResourceBundle::GetSharedInstance().GetRawDataResource( 27 std::string code = ResourceBundle::GetSharedInstance().GetRawDataResource(
28 IDR_JSON_SCHEMA_JS).as_string(); 28 IDR_JSON_SCHEMA_JS).as_string();
29 29
30 // json_schema.js expects to have require() and requireNative() defined. 30 // json_schema.js expects to have require() and requireNative() defined.
31 ExecuteScriptInContext( 31 ExecuteScriptInContext(
32 "function requireNative(id) {" 32 "function requireNative(id) {"
33 " return {" 33 " return {"
34 " GetChromeHidden: function() { return {}; }," 34 " GetChromeHidden: function() { return {}; },"
35 " CHECK: function(foo, bar) { return undefined; },"
35 " };" 36 " };"
36 "}" 37 "}"
37 "function require(id) {" 38 "function require(id) {"
38 " return {" 39 " return {"
39 " loadRefDependency: function(foo) { return {}; }," 40 " loadTypeSchema: function(foo) { return undefined; },"
40 " };" 41 " };"
41 "}", 42 "}",
42 "test-code"); 43 "test-code");
43 ExecuteScriptInContext(code, kJsonSchema); 44 ExecuteScriptInContext(code, kJsonSchema);
44 45
45 // Add the test functions to the context. 46 // Add the test functions to the context.
46 base::FilePath test_js_file_path; 47 base::FilePath test_js_file_path;
47 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_js_file_path)); 48 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_js_file_path));
48 test_js_file_path = test_js_file_path.AppendASCII("extensions"); 49 test_js_file_path = test_js_file_path.AppendASCII("extensions");
49 test_js_file_path = test_js_file_path.AppendASCII(kJsonSchemaTest); 50 test_js_file_path = test_js_file_path.AppendASCII(kJsonSchemaTest);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 TEST_F(JsonSchemaTest, TestIsValidSchemaType) { 109 TEST_F(JsonSchemaTest, TestIsValidSchemaType) {
109 TestFunction("testIsValidSchemaType"); 110 TestFunction("testIsValidSchemaType");
110 } 111 }
111 112
112 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) { 113 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) {
113 TestFunction("testCheckSchemaOverlap"); 114 TestFunction("testCheckSchemaOverlap");
114 } 115 }
115 116
116 } // namespace extensions 117 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/resources/extensions/binding.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698