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

Unified Diff: chrome/browser/extensions/activity_log/activity_log_unittest.cc

Issue 160753002: Enables Activity Log to extract URLs from URL assignment API calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 | « chrome/browser/extensions/activity_log/activity_log.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/activity_log/activity_log_unittest.cc
diff --git a/chrome/browser/extensions/activity_log/activity_log_unittest.cc b/chrome/browser/extensions/activity_log/activity_log_unittest.cc
index 1c0df01c87b6c3895129d02d0fdfb43c1a4fda76..34dc650aaa6486658b47c3b81a6d1b72efdf5841 100644
--- a/chrome/browser/extensions/activity_log/activity_log_unittest.cc
+++ b/chrome/browser/extensions/activity_log/activity_log_unittest.cc
@@ -34,6 +34,19 @@ namespace {
const char kExtensionId[] = "abc";
+const char* kUrlApiCalls[] = {
+ "HTMLButtonElement.formAction", "HTMLEmbedElement.src",
+ "HTMLFormElement.action", "HTMLFrameElement.src",
+ "HTMLHtmlElement.manifest", "HTMLIFrameElement.src",
+ "HTMLImageElement.longDesc", "HTMLImageElement.src",
+ "HTMLImageElement.lowsrc", "HTMLInputElement.formAction",
+ "HTMLInputElement.src", "HTMLLinkElement.href",
+ "HTMLMediaElement.src", "HTMLMediaElement.currentSrc",
+ "HTMLModElement.cite", "HTMLObjectElement.data",
+ "HTMLQuoteElement.cite", "HTMLScriptElement.src",
+ "HTMLSourceElement.src", "HTMLTrackElement.src",
+ "HTMLVideoElement.poster"};
+
} // namespace
namespace extensions {
@@ -148,6 +161,30 @@ class ActivityLogTest : public ChromeRenderViewHostTestHarness {
ASSERT_EQ("http://www.google.co.uk/", action->arg_url().spec());
}
+ static void RetrieveActions_ArgUrlApiCalls(
+ scoped_ptr<std::vector<scoped_refptr<Action> > > actions) {
+ size_t api_calls_size = arraysize(kUrlApiCalls);
+ const base::DictionaryValue* other = NULL;
+ int dom_verb = -1;
+
+ ASSERT_EQ(api_calls_size, actions->size());
+
+ for (size_t i = 0; i < actions->size(); i++) {
+ scoped_refptr<Action> action = actions->at(i);
+ ASSERT_EQ(kExtensionId, action->extension_id());
+ ASSERT_EQ(Action::ACTION_DOM_ACCESS, action->action_type());
+ ASSERT_EQ(kUrlApiCalls[i], action->api_name());
+ ASSERT_EQ("[\"\\u003Carg_url>\"]",
+ ActivityLogPolicy::Util::Serialize(action->args()));
+ ASSERT_EQ("http://www.google.co.uk/", action->arg_url().spec());
+ other = action->other();
+ ASSERT_TRUE(other);
+ ASSERT_TRUE(
+ other->GetInteger(activity_log_constants::kActionDomVerb, &dom_verb));
+ ASSERT_EQ(DomActionType::SETTER, dom_verb);
+ }
+ }
+
ExtensionService* extension_service_;
#if defined OS_CHROMEOS
@@ -340,4 +377,32 @@ TEST_F(ActivityLogTest, UninstalledExtension) {
base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions0));
}
+TEST_F(ActivityLogTest, ArgUrlApiCalls) {
+ ActivityLog* activity_log = ActivityLog::GetInstance(profile());
+ scoped_ptr<base::ListValue> args(new base::ListValue());
+ base::Time now = base::Time::Now();
+ int api_calls_size = arraysize(kUrlApiCalls);
+ scoped_refptr<Action> action;
+
+ for (int i = 0; i < api_calls_size; i++) {
+ action = new Action(kExtensionId,
+ now - base::TimeDelta::FromSeconds(i),
+ Action::ACTION_DOM_ACCESS,
+ kUrlApiCalls[i]);
+ action->mutable_args()->AppendString("http://www.google.co.uk");
+ action->mutable_other()->SetInteger(activity_log_constants::kActionDomVerb,
+ DomActionType::SETTER);
+ activity_log->LogAction(action);
+ }
+
+ activity_log->GetFilteredActions(
+ kExtensionId,
+ Action::ACTION_ANY,
+ "",
+ "",
+ "",
+ -1,
+ base::Bind(ActivityLogTest::RetrieveActions_ArgUrlApiCalls));
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/activity_log/activity_log.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698