| 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 "extensions/grit/extensions_renderer_resources.h" | 5 #include "extensions/grit/extensions_renderer_resources.h" |
| 6 #include "extensions/renderer/module_system_test.h" | 6 #include "extensions/renderer/module_system_test.h" |
| 7 #include "extensions/renderer/v8_schema_registry.h" | 7 #include "extensions/renderer/v8_schema_registry.h" |
| 8 #include "gin/dictionary.h" | 8 #include "gin/dictionary.h" |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| 11 | 11 |
| 12 class JsonSchemaTest : public ModuleSystemTest { | 12 class JsonSchemaTest : public ModuleSystemTest { |
| 13 public: | 13 public: |
| 14 void SetUp() override { | 14 void SetUp() override { |
| 15 ModuleSystemTest::SetUp(); | 15 ModuleSystemTest::SetUp(); |
| 16 | 16 |
| 17 env()->RegisterModule("json_schema", IDR_JSON_SCHEMA_JS); | 17 env()->RegisterModule("json_schema", IDR_JSON_SCHEMA_JS); |
| 18 env()->RegisterModule("utils", IDR_UTILS_JS); | 18 env()->RegisterModule("utils", IDR_UTILS_JS); |
| 19 | 19 |
| 20 env()->module_system()->RegisterNativeHandler( | 20 env()->module_system()->RegisterNativeHandler( |
| 21 "schema_registry", schema_registry_.AsNativeHandler()); | 21 "schema_registry", schema_registry_.AsNativeHandler()); |
| 22 | 22 |
| 23 env()->RegisterTestFile("json_schema_test", "json_schema_test.js"); | 23 env()->RegisterTestFile("json_schema_test", "json_schema_test.js"); |
| 24 } | 24 } |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 void TestFunction(const std::string& test_name) { | 27 void TestFunction(const std::string& test_name) { |
| 28 { |
| 29 ModuleSystem::NativesEnabledScope natives_enabled_scope( |
| 30 env()->module_system()); |
| 31 ASSERT_FALSE(env() |
| 32 ->module_system() |
| 33 ->Require("json_schema_test") |
| 34 .ToLocalChecked() |
| 35 .IsEmpty()); |
| 36 } |
| 28 env()->module_system()->CallModuleMethodSafe("json_schema_test", test_name); | 37 env()->module_system()->CallModuleMethodSafe("json_schema_test", test_name); |
| 29 } | 38 } |
| 30 | 39 |
| 31 private: | 40 private: |
| 32 V8SchemaRegistry schema_registry_; | 41 V8SchemaRegistry schema_registry_; |
| 33 }; | 42 }; |
| 34 | 43 |
| 35 TEST_F(JsonSchemaTest, TestFormatError) { | 44 TEST_F(JsonSchemaTest, TestFormatError) { |
| 36 TestFunction("testFormatError"); | 45 TestFunction("testFormatError"); |
| 37 } | 46 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 111 |
| 103 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) { | 112 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) { |
| 104 TestFunction("testCheckSchemaOverlap"); | 113 TestFunction("testCheckSchemaOverlap"); |
| 105 } | 114 } |
| 106 | 115 |
| 107 TEST_F(JsonSchemaTest, TestInstanceOf) { | 116 TEST_F(JsonSchemaTest, TestInstanceOf) { |
| 108 TestFunction("testInstanceOf"); | 117 TestFunction("testInstanceOf"); |
| 109 } | 118 } |
| 110 | 119 |
| 111 } // namespace extensions | 120 } // namespace extensions |
| OLD | NEW |