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

Side by Side Diff: chrome/browser/extensions/extension_action_runner_browsertest.cc

Issue 1804123003: [Extensions] Refactor extension action execution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // script has *not* already executed. 254 // script has *not* already executed.
255 if (inject_success_listener_->was_satisfied()) { 255 if (inject_success_listener_->was_satisfied()) {
256 return testing::AssertionFailure() << name_ 256 return testing::AssertionFailure() << name_
257 << "'s script ran without permission."; 257 << "'s script ran without permission.";
258 } 258 }
259 259
260 // If we reach this point, we should always want to run. 260 // If we reach this point, we should always want to run.
261 DCHECK(wants_to_run); 261 DCHECK(wants_to_run);
262 262
263 // Grant permission by clicking on the extension action. 263 // Grant permission by clicking on the extension action.
264 runner->OnClicked(extension_); 264 runner->RunAction(extension_, true);
265 265
266 // Now, the extension should be able to inject the script. 266 // Now, the extension should be able to inject the script.
267 inject_success_listener_->WaitUntilSatisfied(); 267 inject_success_listener_->WaitUntilSatisfied();
268 268
269 // The extension should no longer want to run. 269 // The extension should no longer want to run.
270 wants_to_run = WantsToRun(); 270 wants_to_run = WantsToRun();
271 if (wants_to_run) { 271 if (wants_to_run) {
272 return testing::AssertionFailure() 272 return testing::AssertionFailure()
273 << "Extension " << name_ << " still wants to run after injecting."; 273 << "Extension " << name_ << " still wants to run after injecting.";
274 } 274 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // We should have pending requests for extension1, but not the removed 364 // We should have pending requests for extension1, but not the removed
365 // extension2. 365 // extension2.
366 EXPECT_TRUE(action_runner->WantsToRun(extension1)); 366 EXPECT_TRUE(action_runner->WantsToRun(extension1));
367 EXPECT_FALSE(action_runner->WantsToRun(extension2)); 367 EXPECT_FALSE(action_runner->WantsToRun(extension2));
368 368
369 // We should still be able to run the request for extension1. 369 // We should still be able to run the request for extension1.
370 ExtensionTestMessageListener inject_success_listener( 370 ExtensionTestMessageListener inject_success_listener(
371 new ExtensionTestMessageListener(kInjectSucceeded, 371 new ExtensionTestMessageListener(kInjectSucceeded,
372 false /* won't reply */)); 372 false /* won't reply */));
373 inject_success_listener.set_extension_id(extension1->id()); 373 inject_success_listener.set_extension_id(extension1->id());
374 action_runner->OnClicked(extension1); 374 action_runner->RunAction(extension1, true);
375 inject_success_listener.WaitUntilSatisfied(); 375 inject_success_listener.WaitUntilSatisfied();
376 } 376 }
377 377
378 // Test that granting the extension all urls permission allows it to run on 378 // Test that granting the extension all urls permission allows it to run on
379 // pages, and that the permission update is sent to existing renderers. 379 // pages, and that the permission update is sent to existing renderers.
380 IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerBrowserTest, 380 IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerBrowserTest,
381 GrantExtensionAllUrlsPermission) { 381 GrantExtensionAllUrlsPermission) {
382 // Loadup an extension and navigate. 382 // Loadup an extension and navigate.
383 const Extension* extension = CreateExtension(ALL_HOSTS, CONTENT_SCRIPT); 383 const Extension* extension = CreateExtension(ALL_HOSTS, CONTENT_SCRIPT);
384 ASSERT_TRUE(extension); 384 ASSERT_TRUE(extension);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 454
455 ASSERT_TRUE(embedded_test_server()->Start()); 455 ASSERT_TRUE(embedded_test_server()->Start());
456 ui_test_utils::NavigateToURL( 456 ui_test_utils::NavigateToURL(
457 browser(), embedded_test_server()->GetURL("/extensions/test_file.html")); 457 browser(), embedded_test_server()->GetURL("/extensions/test_file.html"));
458 458
459 for (size_t i = 0u; i < arraysize(testers); ++i) 459 for (size_t i = 0u; i < arraysize(testers); ++i)
460 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i]; 460 EXPECT_TRUE(testers[i].Verify()) << kExtensionNames[i];
461 } 461 }
462 462
463 } // namespace extensions 463 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698