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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 10 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 520 |
521 // The extension shouldn't have currently received any webRequest events, | 521 // The extension shouldn't have currently received any webRequest events, |
522 // since it doesn't have permission (and shouldn't receive any from an XHR). | 522 // since it doesn't have permission (and shouldn't receive any from an XHR). |
523 EXPECT_EQ(0, GetWebRequestCountFromBackgroundPage(extension, profile())); | 523 EXPECT_EQ(0, GetWebRequestCountFromBackgroundPage(extension, profile())); |
524 PerformXhrInPage(web_contents, kHost, port, kXhrPath); | 524 PerformXhrInPage(web_contents, kHost, port, kXhrPath); |
525 EXPECT_EQ(0, GetWebRequestCountFromBackgroundPage(extension, profile())); | 525 EXPECT_EQ(0, GetWebRequestCountFromBackgroundPage(extension, profile())); |
526 | 526 |
527 // Grant activeTab permission, and perform another XHR. The extension should | 527 // Grant activeTab permission, and perform another XHR. The extension should |
528 // receive the event. | 528 // receive the event. |
529 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); | 529 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); |
530 runner->OnClicked(extension); | 530 runner->RunAction(extension, true); |
531 EXPECT_EQ(BLOCKED_ACTION_NONE, runner->GetBlockedActions(extension)); | 531 EXPECT_EQ(BLOCKED_ACTION_NONE, runner->GetBlockedActions(extension)); |
532 PerformXhrInPage(web_contents, kHost, port, kXhrPath); | 532 PerformXhrInPage(web_contents, kHost, port, kXhrPath); |
533 EXPECT_EQ(1, GetWebRequestCountFromBackgroundPage(extension, profile())); | 533 EXPECT_EQ(1, GetWebRequestCountFromBackgroundPage(extension, profile())); |
534 | 534 |
535 // If we revoke the extension's tab permissions, it should no longer receive | 535 // If we revoke the extension's tab permissions, it should no longer receive |
536 // webRequest events. | 536 // webRequest events. |
537 ActiveTabPermissionGranter* granter = | 537 ActiveTabPermissionGranter* granter = |
538 TabHelper::FromWebContents(web_contents)->active_tab_permission_granter(); | 538 TabHelper::FromWebContents(web_contents)->active_tab_permission_granter(); |
539 ASSERT_TRUE(granter); | 539 ASSERT_TRUE(granter); |
540 granter->RevokeForTesting(); | 540 granter->RevokeForTesting(); |
541 base::RunLoop().RunUntilIdle(); | 541 base::RunLoop().RunUntilIdle(); |
542 PerformXhrInPage(web_contents, kHost, port, kXhrPath); | 542 PerformXhrInPage(web_contents, kHost, port, kXhrPath); |
543 EXPECT_EQ(1, GetWebRequestCountFromBackgroundPage(extension, profile())); | 543 EXPECT_EQ(1, GetWebRequestCountFromBackgroundPage(extension, profile())); |
544 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); | 544 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); |
545 } | 545 } |
546 | 546 |
547 } // namespace extensions | 547 } // namespace extensions |
OLD | NEW |