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

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

Issue 114803007: Register bindings for blessed web contexts (aka hosted app contexts) by hand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_messages_apitest.cc
diff --git a/chrome/browser/extensions/extension_messages_apitest.cc b/chrome/browser/extensions/extension_messages_apitest.cc
index dc4bd163f1fe4f57a1afb0fb3babf0cb5cf691d9..0f8ffda5f2f9c7b45ed2352600d83ed69d57cd9c 100644
--- a/chrome/browser/extensions/extension_messages_apitest.cc
+++ b/chrome/browser/extensions/extension_messages_apitest.cc
@@ -226,7 +226,8 @@ class ExternallyConnectableMessagingTest : public ExtensionApiTest {
"onMessage",
"onMessageExternal",
"onRestartRequired",
- "id",
+ // Note: no "id" here because this test method is used for hosted apps,
+ // which do have access to runtime.id.
};
// Turn the array into a JS array, which effectively gets eval()ed.
@@ -313,6 +314,25 @@ class ExternallyConnectableMessagingTest : public ExtensionApiTest {
connectable_with_tls_channel_id_manifest());
}
+ const Extension* LoadChromiumHostedApp() {
+ const Extension* hosted_app =
+ LoadExtensionIntoDir(&hosted_app_dir_, base::StringPrintf(
+ "{"
+ " \"name\": \"chromium_hosted_app\","
+ " \"version\": \"1.0\","
+ " \"manifest_version\": 2,"
+ " \"app\": {"
+ " \"urls\": [\"%s\"],"
+ " \"launch\": {"
+ " \"web_url\": \"%s\""
+ " }\n"
+ " }\n"
+ "}", chromium_org_url().spec().c_str(),
+ chromium_org_url().spec().c_str()));
+ CHECK(hosted_app);
+ return hosted_app;
+ }
+
void InitializeTestServer() {
base::FilePath test_data;
EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data));
@@ -392,6 +412,7 @@ class ExternallyConnectableMessagingTest : public ExtensionApiTest {
TestExtensionDir web_connectable_dir_;
TestExtensionDir not_connectable_dir_;
TestExtensionDir tls_channel_id_connectable_dir_;
+ TestExtensionDir hosted_app_dir_;
};
IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, NotInstalled) {
@@ -896,5 +917,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingUserGesture) {
"});", receiver->id().c_str())));
}
+// Tests that a hosted app on a connectable site doesn't interfere with the
+// connectability of that site.
+IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, HostedAppOnWebsite) {
+ InitializeTestServer();
+
+ LoadChromiumHostedApp();
+
+ // The presence of the hosted app shouldn't give the ability to send messages.
+ ui_test_utils::NavigateToURL(browser(), chromium_org_url());
+ EXPECT_EQ(NAMESPACE_NOT_DEFINED, CanConnectAndSendMessages(""));
+ EXPECT_FALSE(AreAnyNonWebApisDefined());
+
+ // Once a connectable extension is installed, it should.
+ const Extension* extension = LoadChromiumConnectableExtension();
+ EXPECT_EQ(OK, CanConnectAndSendMessages(extension->id()));
+ EXPECT_FALSE(AreAnyNonWebApisDefined());
+}
+
} // namespace
}; // namespace extensions
« no previous file with comments | « no previous file | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698