Chromium Code Reviews| 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 "chrome/browser/extensions/api/declarative_content/content_action.h" | 5 #include "chrome/browser/extensions/api/declarative_content/content_action.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | |
| 7 #include "base/test/values_test_util.h" | 8 #include "base/test/values_test_util.h" |
| 8 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
| 11 #include "chrome/browser/extensions/extension_service_test_base.h" | |
| 10 #include "chrome/browser/extensions/extension_tab_util.h" | 12 #include "chrome/browser/extensions/extension_tab_util.h" |
| 11 #include "chrome/browser/extensions/test_extension_environment.h" | 13 #include "chrome/browser/extensions/test_extension_environment.h" |
| 14 #include "chrome/browser/extensions/test_extension_system.h" | |
| 15 #include "chrome/test/base/testing_profile.h" | |
|
Devlin
2014/08/28 21:47:09
don't need
| |
| 12 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/extension_system.h" | |
| 19 #include "extensions/common/extension.h" | |
| 14 #include "extensions/common/extension_builder.h" | 20 #include "extensions/common/extension_builder.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 23 |
| 18 namespace extensions { | 24 namespace extensions { |
| 19 namespace { | 25 namespace { |
| 20 | 26 |
| 21 using base::test::ParseJson; | 27 using base::test::ParseJson; |
| 22 using testing::HasSubstr; | 28 using testing::HasSubstr; |
| 23 | 29 |
| 30 | |
| 31 scoped_ptr<base::DictionaryValue> SimpleManifest() { | |
| 32 return DictionaryBuilder() | |
| 33 .Set("name", "extension") | |
| 34 .Set("manifest_version", 2) | |
| 35 .Set("version", "1.0") | |
| 36 .Build(); | |
| 37 } | |
| 38 | |
| 39 class RequestContentScriptTest : public ExtensionServiceTestBase { | |
| 40 public: | |
| 41 RequestContentScriptTest(); | |
| 42 | |
| 43 // TODO(rdevlin.cronin): This should be SetUp(), but an issues with invoking | |
|
Devlin
2014/08/28 21:47:10
nit: not "an issues"
| |
| 44 // InitializeEmptyExtensionService() within SetUp() means that we have to | |
| 45 // call this manually within every test. This can be cleaned up once said | |
| 46 // issue is fixed. | |
| 47 virtual void Init(); | |
| 48 | |
| 49 Profile* profile() { return profile_.get(); } | |
| 50 Extension* extension() { return extension_.get(); } | |
| 51 | |
| 52 private: | |
| 53 scoped_refptr<Extension> extension_; | |
| 54 }; | |
| 55 | |
| 56 RequestContentScriptTest::RequestContentScriptTest() | |
|
Jeffrey Yasskin
2014/08/28 21:38:47
Inside a test, it's generally good to define metho
Devlin
2014/08/28 21:47:10
He probably got this from me. I've heard it a bit
Mark Dittmer
2014/08/28 21:59:47
Done.
| |
| 57 : extension_(ExtensionBuilder().SetManifest(SimpleManifest()).Build()) {} | |
| 58 | |
| 59 void RequestContentScriptTest::Init() { | |
| 60 InitializeEmptyExtensionService(); | |
| 61 static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile()))-> | |
| 62 SetReady(); | |
| 63 base::RunLoop().RunUntilIdle(); | |
| 64 } | |
| 65 | |
| 24 TEST(DeclarativeContentActionTest, InvalidCreation) { | 66 TEST(DeclarativeContentActionTest, InvalidCreation) { |
| 25 TestExtensionEnvironment env; | 67 TestExtensionEnvironment env; |
| 26 std::string error; | 68 std::string error; |
| 27 bool bad_message = false; | 69 bool bad_message = false; |
| 28 scoped_refptr<const ContentAction> result; | 70 scoped_refptr<const ContentAction> result; |
| 29 | 71 |
| 30 // Test wrong data type passed. | 72 // Test wrong data type passed. |
| 31 error.clear(); | 73 error.clear(); |
| 32 result = ContentAction::Create(NULL, *ParseJson("[]"), &error, &bad_message); | 74 result = ContentAction::Create( |
| 75 NULL, NULL, *ParseJson("[]"), &error, &bad_message); | |
| 33 EXPECT_TRUE(bad_message); | 76 EXPECT_TRUE(bad_message); |
| 34 EXPECT_EQ("", error); | 77 EXPECT_EQ("", error); |
| 35 EXPECT_FALSE(result.get()); | 78 EXPECT_FALSE(result.get()); |
| 36 | 79 |
| 37 // Test missing instanceType element. | 80 // Test missing instanceType element. |
| 38 error.clear(); | 81 error.clear(); |
| 39 result = ContentAction::Create(NULL, *ParseJson("{}"), &error, &bad_message); | 82 result = ContentAction::Create( |
| 83 NULL, NULL, *ParseJson("{}"), &error, &bad_message); | |
| 40 EXPECT_TRUE(bad_message); | 84 EXPECT_TRUE(bad_message); |
| 41 EXPECT_EQ("", error); | 85 EXPECT_EQ("", error); |
| 42 EXPECT_FALSE(result.get()); | 86 EXPECT_FALSE(result.get()); |
| 43 | 87 |
| 44 // Test wrong instanceType element. | 88 // Test wrong instanceType element. |
| 45 error.clear(); | 89 error.clear(); |
| 46 result = ContentAction::Create(NULL, *ParseJson( | 90 result = ContentAction::Create(NULL, NULL, *ParseJson( |
| 47 "{\n" | 91 "{\n" |
| 48 " \"instanceType\": \"declarativeContent.UnknownType\",\n" | 92 " \"instanceType\": \"declarativeContent.UnknownType\",\n" |
| 49 "}"), | 93 "}"), |
| 50 &error, &bad_message); | 94 &error, &bad_message); |
| 51 EXPECT_THAT(error, HasSubstr("invalid instanceType")); | 95 EXPECT_THAT(error, HasSubstr("invalid instanceType")); |
| 52 EXPECT_FALSE(result.get()); | 96 EXPECT_FALSE(result.get()); |
| 53 } | 97 } |
| 54 | 98 |
| 55 TEST(DeclarativeContentActionTest, ShowPageActionWithoutPageAction) { | 99 TEST(DeclarativeContentActionTest, ShowPageActionWithoutPageAction) { |
| 56 TestExtensionEnvironment env; | 100 TestExtensionEnvironment env; |
| 57 | 101 |
| 58 const Extension* extension = env.MakeExtension(base::DictionaryValue()); | 102 const Extension* extension = env.MakeExtension(base::DictionaryValue()); |
| 59 std::string error; | 103 std::string error; |
| 60 bool bad_message = false; | 104 bool bad_message = false; |
| 61 scoped_refptr<const ContentAction> result = ContentAction::Create( | 105 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 106 NULL, | |
| 62 extension, | 107 extension, |
| 63 *ParseJson( | 108 *ParseJson( |
| 64 "{\n" | 109 "{\n" |
| 65 " \"instanceType\": \"declarativeContent.ShowPageAction\",\n" | 110 " \"instanceType\": \"declarativeContent.ShowPageAction\",\n" |
| 66 "}"), | 111 "}"), |
| 67 &error, | 112 &error, |
| 68 &bad_message); | 113 &bad_message); |
| 69 EXPECT_THAT(error, testing::HasSubstr("without a page action")); | 114 EXPECT_THAT(error, testing::HasSubstr("without a page action")); |
| 70 EXPECT_FALSE(bad_message); | 115 EXPECT_FALSE(bad_message); |
| 71 ASSERT_FALSE(result.get()); | 116 ASSERT_FALSE(result.get()); |
| 72 } | 117 } |
| 73 | 118 |
| 74 TEST(DeclarativeContentActionTest, ShowPageAction) { | 119 TEST(DeclarativeContentActionTest, ShowPageAction) { |
| 75 TestExtensionEnvironment env; | 120 TestExtensionEnvironment env; |
| 76 | 121 |
| 77 const Extension* extension = env.MakeExtension( | 122 const Extension* extension = env.MakeExtension( |
| 78 *ParseJson("{\"page_action\": { \"default_title\": \"Extension\" } }")); | 123 *ParseJson("{\"page_action\": { \"default_title\": \"Extension\" } }")); |
| 79 std::string error; | 124 std::string error; |
| 80 bool bad_message = false; | 125 bool bad_message = false; |
| 81 scoped_refptr<const ContentAction> result = ContentAction::Create( | 126 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 127 NULL, | |
| 82 extension, | 128 extension, |
| 83 *ParseJson( | 129 *ParseJson( |
| 84 "{\n" | 130 "{\n" |
| 85 " \"instanceType\": \"declarativeContent.ShowPageAction\",\n" | 131 " \"instanceType\": \"declarativeContent.ShowPageAction\",\n" |
| 86 "}"), | 132 "}"), |
| 87 &error, | 133 &error, |
| 88 &bad_message); | 134 &bad_message); |
| 89 EXPECT_EQ("", error); | 135 EXPECT_EQ("", error); |
| 90 EXPECT_FALSE(bad_message); | 136 EXPECT_FALSE(bad_message); |
| 91 ASSERT_TRUE(result.get()); | 137 ASSERT_TRUE(result.get()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 102 result->Apply(extension->id(), base::Time(), &apply_info); | 148 result->Apply(extension->id(), base::Time(), &apply_info); |
| 103 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); | 149 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); |
| 104 result->Apply(extension->id(), base::Time(), &apply_info); | 150 result->Apply(extension->id(), base::Time(), &apply_info); |
| 105 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); | 151 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); |
| 106 result->Revert(extension->id(), base::Time(), &apply_info); | 152 result->Revert(extension->id(), base::Time(), &apply_info); |
| 107 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); | 153 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); |
| 108 result->Revert(extension->id(), base::Time(), &apply_info); | 154 result->Revert(extension->id(), base::Time(), &apply_info); |
| 109 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); | 155 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); |
| 110 } | 156 } |
| 111 | 157 |
| 112 TEST(DeclarativeContentActionTest, RequestContentScriptMissingScripts) { | 158 TEST_F(RequestContentScriptTest, MissingScripts) { |
| 113 TestExtensionEnvironment env; | 159 Init(); |
| 114 | |
| 115 std::string error; | 160 std::string error; |
| 116 bool bad_message = false; | 161 bool bad_message = false; |
| 117 scoped_refptr<const ContentAction> result = ContentAction::Create( | 162 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 118 NULL, | 163 profile(), |
| 164 extension(), | |
| 119 *ParseJson( | 165 *ParseJson( |
| 120 "{\n" | 166 "{\n" |
| 121 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 167 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 122 " \"allFrames\": true,\n" | 168 " \"allFrames\": true,\n" |
| 123 " \"matchAboutBlank\": true\n" | 169 " \"matchAboutBlank\": true\n" |
| 124 "}"), | 170 "}"), |
| 125 &error, | 171 &error, |
| 126 &bad_message); | 172 &bad_message); |
| 127 EXPECT_THAT(error, testing::HasSubstr("Missing parameter is required")); | 173 EXPECT_THAT(error, testing::HasSubstr("Missing parameter is required")); |
| 128 EXPECT_FALSE(bad_message); | 174 EXPECT_FALSE(bad_message); |
| 129 ASSERT_FALSE(result.get()); | 175 ASSERT_FALSE(result.get()); |
| 130 } | 176 } |
| 131 | 177 |
| 132 TEST(DeclarativeContentActionTest, RequestContentScriptCSS) { | 178 TEST_F(RequestContentScriptTest, CSS) { |
| 133 TestExtensionEnvironment env; | 179 Init(); |
| 134 | |
| 135 std::string error; | 180 std::string error; |
| 136 bool bad_message = false; | 181 bool bad_message = false; |
| 137 scoped_refptr<const ContentAction> result = ContentAction::Create( | 182 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 138 NULL, | 183 profile(), |
| 184 extension(), | |
| 139 *ParseJson( | 185 *ParseJson( |
| 140 "{\n" | 186 "{\n" |
| 141 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 187 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 142 " \"css\": [\"style.css\"]\n" | 188 " \"css\": [\"style.css\"]\n" |
| 143 "}"), | 189 "}"), |
| 144 &error, | 190 &error, |
| 145 &bad_message); | 191 &bad_message); |
| 146 EXPECT_EQ("", error); | 192 EXPECT_EQ("", error); |
| 147 EXPECT_FALSE(bad_message); | 193 EXPECT_FALSE(bad_message); |
| 148 ASSERT_TRUE(result.get()); | 194 ASSERT_TRUE(result.get()); |
| 149 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); | 195 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); |
| 150 } | 196 } |
| 151 | 197 |
| 152 TEST(DeclarativeContentActionTest, RequestContentScriptJS) { | 198 TEST_F(RequestContentScriptTest, JS) { |
| 153 TestExtensionEnvironment env; | 199 Init(); |
| 154 | |
| 155 std::string error; | 200 std::string error; |
| 156 bool bad_message = false; | 201 bool bad_message = false; |
| 157 scoped_refptr<const ContentAction> result = ContentAction::Create( | 202 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 158 NULL, | 203 profile(), |
| 204 extension(), | |
| 159 *ParseJson( | 205 *ParseJson( |
| 160 "{\n" | 206 "{\n" |
| 161 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 207 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 162 " \"js\": [\"script.js\"]\n" | 208 " \"js\": [\"script.js\"]\n" |
| 163 "}"), | 209 "}"), |
| 164 &error, | 210 &error, |
| 165 &bad_message); | 211 &bad_message); |
| 166 EXPECT_EQ("", error); | 212 EXPECT_EQ("", error); |
| 167 EXPECT_FALSE(bad_message); | 213 EXPECT_FALSE(bad_message); |
| 168 ASSERT_TRUE(result.get()); | 214 ASSERT_TRUE(result.get()); |
| 169 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); | 215 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); |
| 170 } | 216 } |
| 171 | 217 |
| 172 TEST(DeclarativeContentActionTest, RequestContentScriptCSSBadType) { | 218 TEST_F(RequestContentScriptTest, CSSBadType) { |
| 173 TestExtensionEnvironment env; | 219 Init(); |
| 174 | |
| 175 std::string error; | 220 std::string error; |
| 176 bool bad_message = false; | 221 bool bad_message = false; |
| 177 scoped_refptr<const ContentAction> result = ContentAction::Create( | 222 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 178 NULL, | 223 profile(), |
| 224 extension(), | |
| 179 *ParseJson( | 225 *ParseJson( |
| 180 "{\n" | 226 "{\n" |
| 181 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 227 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 182 " \"css\": \"style.css\"\n" | 228 " \"css\": \"style.css\"\n" |
| 183 "}"), | 229 "}"), |
| 184 &error, | 230 &error, |
| 185 &bad_message); | 231 &bad_message); |
| 186 EXPECT_TRUE(bad_message); | 232 EXPECT_TRUE(bad_message); |
| 187 ASSERT_FALSE(result.get()); | 233 ASSERT_FALSE(result.get()); |
| 188 } | 234 } |
| 189 | 235 |
| 190 TEST(DeclarativeContentActionTest, RequestContentScriptJSBadType) { | 236 TEST_F(RequestContentScriptTest, JSBadType) { |
| 191 TestExtensionEnvironment env; | 237 Init(); |
| 192 | |
| 193 std::string error; | 238 std::string error; |
| 194 bool bad_message = false; | 239 bool bad_message = false; |
| 195 scoped_refptr<const ContentAction> result = ContentAction::Create( | 240 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 196 NULL, | 241 profile(), |
| 242 extension(), | |
| 197 *ParseJson( | 243 *ParseJson( |
| 198 "{\n" | 244 "{\n" |
| 199 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 245 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 200 " \"js\": \"script.js\"\n" | 246 " \"js\": \"script.js\"\n" |
| 201 "}"), | 247 "}"), |
| 202 &error, | 248 &error, |
| 203 &bad_message); | 249 &bad_message); |
| 204 EXPECT_TRUE(bad_message); | 250 EXPECT_TRUE(bad_message); |
| 205 ASSERT_FALSE(result.get()); | 251 ASSERT_FALSE(result.get()); |
| 206 } | 252 } |
| 207 | 253 |
| 208 TEST(DeclarativeContentActionTest, RequestContentScriptAllFrames) { | 254 TEST_F(RequestContentScriptTest, AllFrames) { |
| 209 TestExtensionEnvironment env; | 255 Init(); |
| 210 | |
| 211 std::string error; | 256 std::string error; |
| 212 bool bad_message = false; | 257 bool bad_message = false; |
| 213 scoped_refptr<const ContentAction> result = ContentAction::Create( | 258 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 214 NULL, | 259 profile(), |
| 260 extension(), | |
| 215 *ParseJson( | 261 *ParseJson( |
| 216 "{\n" | 262 "{\n" |
| 217 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 263 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 218 " \"js\": [\"script.js\"],\n" | 264 " \"js\": [\"script.js\"],\n" |
| 219 " \"allFrames\": true\n" | 265 " \"allFrames\": true\n" |
| 220 "}"), | 266 "}"), |
| 221 &error, | 267 &error, |
| 222 &bad_message); | 268 &bad_message); |
| 223 EXPECT_EQ("", error); | 269 EXPECT_EQ("", error); |
| 224 EXPECT_FALSE(bad_message); | 270 EXPECT_FALSE(bad_message); |
| 225 ASSERT_TRUE(result.get()); | 271 ASSERT_TRUE(result.get()); |
| 226 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); | 272 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); |
| 227 } | 273 } |
| 228 | 274 |
| 229 TEST(DeclarativeContentActionTest, RequestContentScriptMatchAboutBlank) { | 275 TEST_F(RequestContentScriptTest, MatchAboutBlank) { |
| 230 TestExtensionEnvironment env; | 276 Init(); |
| 231 | |
| 232 std::string error; | 277 std::string error; |
| 233 bool bad_message = false; | 278 bool bad_message = false; |
| 234 scoped_refptr<const ContentAction> result = ContentAction::Create( | 279 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 235 NULL, | 280 profile(), |
| 281 extension(), | |
| 236 *ParseJson( | 282 *ParseJson( |
| 237 "{\n" | 283 "{\n" |
| 238 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 284 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 239 " \"js\": [\"script.js\"],\n" | 285 " \"js\": [\"script.js\"],\n" |
| 240 " \"matchAboutBlank\": true\n" | 286 " \"matchAboutBlank\": true\n" |
| 241 "}"), | 287 "}"), |
| 242 &error, | 288 &error, |
| 243 &bad_message); | 289 &bad_message); |
| 244 EXPECT_EQ("", error); | 290 EXPECT_EQ("", error); |
| 245 EXPECT_FALSE(bad_message); | 291 EXPECT_FALSE(bad_message); |
| 246 ASSERT_TRUE(result.get()); | 292 ASSERT_TRUE(result.get()); |
| 247 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); | 293 EXPECT_EQ(ContentAction::ACTION_REQUEST_CONTENT_SCRIPT, result->GetType()); |
| 248 } | 294 } |
| 249 | 295 |
| 250 TEST(DeclarativeContentActionTest, RequestContentScriptAllFramesBadType) { | 296 TEST_F(RequestContentScriptTest, AllFramesBadType) { |
| 251 TestExtensionEnvironment env; | 297 Init(); |
| 252 | |
| 253 std::string error; | 298 std::string error; |
| 254 bool bad_message = false; | 299 bool bad_message = false; |
| 255 scoped_refptr<const ContentAction> result = ContentAction::Create( | 300 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 256 NULL, | 301 profile(), |
| 302 extension(), | |
| 257 *ParseJson( | 303 *ParseJson( |
| 258 "{\n" | 304 "{\n" |
| 259 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 305 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 260 " \"js\": [\"script.js\"],\n" | 306 " \"js\": [\"script.js\"],\n" |
| 261 " \"allFrames\": null\n" | 307 " \"allFrames\": null\n" |
| 262 "}"), | 308 "}"), |
| 263 &error, | 309 &error, |
| 264 &bad_message); | 310 &bad_message); |
| 265 EXPECT_TRUE(bad_message); | 311 EXPECT_TRUE(bad_message); |
| 266 ASSERT_FALSE(result.get()); | 312 ASSERT_FALSE(result.get()); |
| 267 } | 313 } |
| 268 | 314 |
| 269 TEST(DeclarativeContentActionTest, RequestContentScriptMatchAboutBlankBadType) { | 315 TEST_F(RequestContentScriptTest, MatchAboutBlankBadType) { |
| 270 TestExtensionEnvironment env; | 316 Init(); |
| 271 | |
| 272 std::string error; | 317 std::string error; |
| 273 bool bad_message = false; | 318 bool bad_message = false; |
| 274 scoped_refptr<const ContentAction> result = ContentAction::Create( | 319 scoped_refptr<const ContentAction> result = ContentAction::Create( |
| 275 NULL, | 320 profile(), |
| 321 extension(), | |
| 276 *ParseJson( | 322 *ParseJson( |
| 277 "{\n" | 323 "{\n" |
| 278 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" | 324 " \"instanceType\": \"declarativeContent.RequestContentScript\",\n" |
| 279 " \"js\": [\"script.js\"],\n" | 325 " \"js\": [\"script.js\"],\n" |
| 280 " \"matchAboutBlank\": null\n" | 326 " \"matchAboutBlank\": null\n" |
| 281 "}"), | 327 "}"), |
| 282 &error, | 328 &error, |
| 283 &bad_message); | 329 &bad_message); |
| 284 EXPECT_TRUE(bad_message); | 330 EXPECT_TRUE(bad_message); |
| 285 ASSERT_FALSE(result.get()); | 331 ASSERT_FALSE(result.get()); |
| 286 } | 332 } |
| 287 | 333 |
| 288 } // namespace | 334 } // namespace |
| 289 } // namespace extensions | 335 } // namespace extensions |
| OLD | NEW |