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

Unified Diff: chrome/browser/extensions/webstore_inline_installer_browsertest.cc

Issue 1403293008: Don't allow inline install if frame is deleted before user accepts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: codereview feedback Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/webstore_inline_installer_browsertest.cc
diff --git a/chrome/browser/extensions/webstore_inline_installer_browsertest.cc b/chrome/browser/extensions/webstore_inline_installer_browsertest.cc
index 90144793c8df955ef89101eade1e194f1fe69eae..f17b9a8f05ec15f6956951a6118eb1921380fcbc 100644
--- a/chrome/browser/extensions/webstore_inline_installer_browsertest.cc
+++ b/chrome/browser/extensions/webstore_inline_installer_browsertest.cc
@@ -18,6 +18,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "url/gurl.h"
@@ -87,22 +88,27 @@ ExtensionInstallPrompt::Delegate* ProgrammableInstallPrompt::delegate_;
class WebstoreInlineInstallerForTest : public WebstoreInlineInstaller {
public:
WebstoreInlineInstallerForTest(WebContents* contents,
+ content::RenderFrameHost* host,
const std::string& extension_id,
const GURL& requestor_url,
const Callback& callback)
- : WebstoreInlineInstaller(
- contents,
- kTestExtensionId,
- requestor_url,
- base::Bind(DummyCallback)),
- programmable_prompt_(NULL) {
- }
+ : WebstoreInlineInstaller(contents,
+ host,
+ kTestExtensionId,
+ requestor_url,
+ base::Bind(DummyCallback)),
+ programmable_prompt_(NULL) {}
scoped_ptr<ExtensionInstallPrompt> CreateInstallUI() override {
programmable_prompt_ = new ProgrammableInstallPrompt(web_contents());
return make_scoped_ptr(programmable_prompt_);
}
+ // Added here to make it public so that test cases can call it below.
+ bool CheckRequestorAlive() const override {
+ return WebstoreInlineInstaller::CheckRequestorAlive();
+ }
+
private:
~WebstoreInlineInstallerForTest() override {}
@@ -118,15 +124,26 @@ class WebstoreInlineInstallerForTest : public WebstoreInlineInstaller {
class WebstoreInlineInstallerForTestFactory :
public WebstoreInlineInstallerFactory {
+ public:
+ WebstoreInlineInstallerForTestFactory() : last_installer_(nullptr) {}
~WebstoreInlineInstallerForTestFactory() override {}
+
+ // Returns a pointer to the last installer that was created.
Devlin 2015/11/18 21:48:26 nitty nit: I think it's more common to put the des
asargent_no_longer_on_chrome 2015/11/20 01:11:47 Done.
+ WebstoreInlineInstallerForTest* last_installer() { return last_installer_; }
+
WebstoreInlineInstaller* CreateInstaller(
WebContents* contents,
+ content::RenderFrameHost* host,
const std::string& webstore_item_id,
const GURL& requestor_url,
const WebstoreStandaloneInstaller::Callback& callback) override {
- return new WebstoreInlineInstallerForTest(
- contents, webstore_item_id, requestor_url, callback);
+ last_installer_ = new WebstoreInlineInstallerForTest(
+ contents, host, webstore_item_id, requestor_url, callback);
+ return last_installer_;
}
+
+ protected:
Devlin 2015/11/18 21:48:26 nit: Let's do private (unless there's a reason for
asargent_no_longer_on_chrome 2015/11/20 01:11:47 Done.
+ WebstoreInlineInstallerForTest* last_installer_;
};
IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest,
@@ -145,6 +162,28 @@ IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest,
ProgrammableInstallPrompt::Accept();
}
+IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest,
+ NavigateBeforeInstallConfirmation) {
+ GURL install_url = GenerateTestServerUrl(kAppDomain, "install.html");
+ ui_test_utils::NavigateToURL(browser(), install_url);
+ WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ TabHelper* tab_helper = TabHelper::FromWebContents(web_contents);
+ WebstoreInlineInstallerForTestFactory* factory =
+ new WebstoreInlineInstallerForTestFactory();
+ tab_helper->SetWebstoreInlineInstallerFactoryForTests(factory);
+ RunTestAsync("runTest");
+ while (!ProgrammableInstallPrompt::Ready())
+ base::RunLoop().RunUntilIdle();
+ GURL new_url = GenerateTestServerUrl(kNonAppDomain, "empty.html");
+ web_contents->GetController().LoadURL(
+ new_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ EXPECT_TRUE(content::WaitForLoadStop(web_contents));
+ ASSERT_NE(factory->last_installer(), nullptr);
+ EXPECT_NE(factory->last_installer()->web_contents(), nullptr);
+ EXPECT_FALSE(factory->last_installer()->CheckRequestorAlive());
Devlin 2015/11/18 21:48:26 Since we don't cancel the installation here, can w
asargent_no_longer_on_chrome 2015/11/20 01:11:47 Good suggestion - I ended up having to add a bit o
+}
+
// Flaky: https://crbug.com/537526.
IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest,
DISABLED_ShouldBlockInlineInstallFromPopupWindow) {
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer.cc ('k') | chrome/browser/extensions/webstore_inline_installer_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698