Commit 7662f4b0 authored by Findit's avatar Findit

Revert "[Extensions] Add recent extension activities to the activity log page"

This reverts commit e393ff47.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 607924 as the
culprit for flakes in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/flake/flake-culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyQwsSDEZsYWtlQ3VscHJpdCIxY2hyb21pdW0vZTM5M2ZmNDc1M2JmZTk3ZjkwZTk2MTRmZWRhMTBhMGNhMWQ3M2YwOAw

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.linux/linux-xenial-rel/4885

Sample Failed Step: browser_tests on Ubuntu-16.04

Sample Flaky Test: ExtensionsActivityLogTest.TestActivityLogVisible

Original change's description:
> [Extensions] Add recent extension activities to the activity log page
> 
> Show recent extension activities by making a call to
> chrome.activityLogPrivate.getExtensionActivities whenever the user
> navigates to the activity log page. Currently, the activity type,
> api call, event count and page url (if there is one) are shown
> in descending order of event count.
> 
> Note: the activity log database can sometimes store more than one entry
> that has the same api call/event type. This CL currently does not
> group any duplicate activity entries.
> 
> Bug: 832354
> Change-Id: I0191d77cd7961bdc5d95ec8daea98d39b1a7c638
> Reviewed-on: https://chromium-review.googlesource.com/c/1321166
> Commit-Queue: Kelvin Jiang <kelvinjiang@chromium.org>
> Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#607924}

Change-Id: I0074574f067f532e3398b48254a52bb9f7a7af0f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 832354, 905278
Reviewed-on: https://chromium-review.googlesource.com/c/1335827
Cr-Commit-Position: refs/heads/master@{#607964}
parent eab6e04f
......@@ -7,7 +7,7 @@
<message name="IDS_EXTENSIONS_ALLOW_ON_ALL_URLS" desc="The checkbox for allowing an extension to run scripts on all websites without explicit permission.">
Allow on all websites
</message>
<message name="IDS_EXTENSIONS_VIEW_ACTIVITY_LOG" desc="The label of the button to click to view recent extension activity.">
<message name="IDS_EXTENSIONS_ACTIVITY_LOG" desc="The label of the button to click to view recent extension activity.">
View Activity Log
</message>
<message name="IDS_EXTENSIONS_BACKGROUND_PAGE" desc="Display name for an autogenerated background page.">
......@@ -121,9 +121,6 @@
<message name="IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE" desc="Accessibility message to indicate the lines that an error spans. The lines of code will be read to the user. The place holders will be numbers.">
Error from line <ph name="ERROR_LINE_START">$1</ph> to <ph name="ERROR_LINE_END">$2</ph>
</message>
<message name="IDS_MD_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING" desc="The heading of the page displaying an extension's activity log.">
Activity Log
</message>
<message name="IDS_MD_EXTENSIONS_ITEM_ID" desc="The text for the label next to the extension id.">
&lt;span&gt;ID: &lt;/span&gt;<ph name="EXTENSION_ID">$1<ex>cfhdojbkjhnklbpkdaibdccddilifddb</ex></ph>
</message>
......@@ -226,9 +223,6 @@
<message name="IDS_MD_EXTENSIONS_LOAD_ERROR_RETRY" desc="The text on the button to retry loading an unpacked extension after a failed load.">
Retry
</message>
<message name="IDS_MD_EXTENSIONS_NO_ACTIVITIES" desc="The message shown to the user when an extension has no recent activities.">
No recent activities
</message>
<message name="IDS_MD_EXTENSIONS_NO_INSTALLED_ITEMS" desc="The message shown to the user on the Extensions settings page when there are no extensions or apps installed.">
Find extensions and themes in the <ph name="BEGIN_LINK">&lt;a target="_blank" href="https://chrome.google.com/webstore/category/extensions"&gt;</ph>Chrome Web Store<ph name="END_LINK">&lt;/a&gt;<ex>&lt;/a&gt;</ex></ph>
</message>
......
......@@ -51,7 +51,6 @@ grit("flattened_resources") {
js_type_check("closure_compile") {
deps = [
":activity_log",
":activity_log_item",
":code_section",
":detail_view",
":drag_and_drop_handler",
......@@ -91,22 +90,10 @@ js_library("code_section") {
externs_list = [ "$externs_path/developer_private.js" ]
}
js_library("activity_log_item") {
deps = [
"//ui/webui/resources/js:cr",
]
externs_list = [ "$externs_path/activity_log_private.js" ]
}
js_library("activity_log") {
deps = [
":activity_log_item",
"//ui/webui/resources/js:cr",
]
externs_list = [
"$externs_path/activity_log_private.js",
"$externs_path/developer_private.js",
]
}
js_library("detail_view") {
......@@ -257,7 +244,6 @@ js_library("load_error") {
js_library("manager") {
deps = [
":activity_log",
":activity_log_item",
":detail_view",
":item",
":item_list",
......@@ -341,7 +327,6 @@ js_library("service") {
"//ui/webui/resources/js:load_time_data",
]
externs_list = [
"$externs_path/activity_log_private.js",
"$externs_path/developer_private.js",
"$externs_path/management.js",
"$externs_path/metrics_private.js",
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_container_shadow_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html">
<link rel="import" href="activity_log_item.html">
<link rel="import" href="navigation_helper.html">
<link rel="import" href="shared_style.html">
<dom-module id="extensions-activity-log">
<template>
<style include="iron-flex cr-shared-style shared-style">
.empty-activity-message {
color: #6e6e6e;
font-size: 123%; /* Should be 16px when 100% is 13px. */
font-weight: 500;
margin-top: 80px;
text-align: center;
<style include="iron-flex cr-shared-style">
#container {
height: 100%;
overflow: overlay;
}
#main {
background-color: white;
margin: auto;
min-height: 100%;
padding-bottom: 64px;
width: var(--cr-toolbar-field-width);
}
</style>
<div class="page-container" id="container">
<div class="page-content">
<div class="page-header">
<paper-icon-button-light class="icon-arrow-back no-overlap">
<button id="close-button" aria-label="$i18n{back}"
on-click="onCloseButtonTap_"></button>
</paper-icon-button-light>
<span>$i18n{activityLogPageHeading}</span>
</div>
<div id="no-activities" class="empty-activity-message"
hidden$="[[!shouldShowEmptyActivityLogMessage_(
activityData_)]]">
<span>$i18n{noActivities}</span>
</div>
<div hidden$="[[!activityData_]]">
<template is="dom-repeat" items="[[activityData_.activities]]">
<activity-log-item id="[[item.activityId]]" data="[[item]]">
</activity-log-item>
</template>
</div>
<div id="container">
<div id="main">
Welcome to the new activity log
</div>
</div>
</template>
......
......@@ -5,86 +5,11 @@
cr.define('extensions', function() {
'use strict';
/** @interface */
class ActivityLogDelegate {
/**
* @param {string} extensionId
* @return {!Promise<!chrome.activityLogPrivate.ActivityResultSet>}
*/
getExtensionActivityLog(extensionId) {}
}
const ActivityLog = Polymer({
is: 'extensions-activity-log',
behaviors: [
CrContainerShadowBehavior,
],
properties: {
/** @type {!string} */
extensionId: String,
/** @type {!extensions.ActivityLogDelegate} */
delegate: Object,
/**
* @private
* @type {!chrome.activityLogPrivate.ActivityResultSet|undefined}
*/
activityData_: Object,
},
navigationListener_: null,
/** @override */
attached: function() {
// Fetch the activity log for the extension when this page is attached.
// This is necesary as the listener below is not fired if the user
// navigates directly to the activity log page using url.
this.getActivityLog_();
// Add a listener here so we fetch the activity log whenever a user
// navigates to the activity log from another page.
// This is needed since this component already exists in the background
// if a user navigates away from this page so attached may not be called
// when a user navigates back.
this.navigationListener_ = extensions.navigation.addListener(newPage => {
if (newPage.page === Page.ACTIVITY_LOG)
this.getActivityLog_();
});
},
/** @override */
detached: function() {
assert(extensions.navigation.removeListener(this.navigationListener_));
this.navigationListener_ = null;
},
/**
* @private
* @return {boolean}
*/
shouldShowEmptyActivityLogMessage_: function() {
return !this.activityData_ || this.activityData_.activities.length === 0;
},
/** @private */
onCloseButtonTap_: function() {
extensions.navigation.navigateTo(
{page: Page.DETAILS, extensionId: this.extensionId});
},
/** @private */
getActivityLog_: function() {
this.delegate.getExtensionActivityLog(this.extensionId).then(result => {
this.activityData_ = result;
});
},
properties: {},
});
return {
ActivityLog: ActivityLog,
ActivityLogDelegate: ActivityLogDelegate,
};
return {ActivityLog: ActivityLog};
});
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/html/cr.html">
<dom-module id="activity-log-item">
<template>
<style include="iron-flex cr-shared-style">
#main {
min-height: 0;
padding: 16px 20px;
}
#activity-type {
min-width: 85px;
}
#api-call {
flex-grow: 1;
margin-left: 10px;
}
#page-url-link {
margin-left: 16px;
}
</style>
<div id="main">
<div id="activity-call-and-count" class="layout horizontal">
<span id="activity-type">[[data.activityType]]</span>
<span id="api-call">[[data.apiCall]]</span>
<span id="activity-count">[[data.count]]</span>
</div>
<div id="page-url" hidden$="[[!data.pageUrl]]">
<a id="page-url-link" href="[[data.pageUrl]]">[[data.pageUrl]]</a>
</div>
</div>
</template>
<script src="activity_log_item.js"></script>
</dom-module>
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('extensions', function() {
'use strict';
const ActivityLogItem = Polymer({
is: 'activity-log-item',
properties: {
/**
* The underlying ExtensionActivity that provides data for the
* ActivityLogItem displayed.
* @type {chrome.activityLogPrivate.ExtensionActivity}
*/
data: Object,
},
});
return {ActivityLogItem: ActivityLogItem};
});
......@@ -23,13 +23,12 @@
<link rel="import" href="host_permissions_toggle_list.html">
<link rel="import" href="navigation_helper.html">
<link rel="import" href="runtime_host_permissions.html">
<link rel="import" href="shared_style.html">
<link rel="import" href="strings.html">
<link rel="import" href="toggle_row.html">
<dom-module id="extensions-detail-view">
<template>
<style include="iron-flex cr-shared-style cr-icons action-link paper-button-style shared-style">
<style include="iron-flex cr-shared-style cr-icons action-link paper-button-style">
:host {
--iron-icon-fill-color: var(--google-grey-refresh-700);
display: block;
......@@ -53,6 +52,29 @@
color: var(--google-blue-500);
}
#container {
height: 100%;
overflow: overlay;
}
#main {
@apply --cr-card-elevation;
background-color: white;
box-sizing: border-box;
margin: auto;
min-height: 100%;
padding-bottom: 64px;
width: var(--cr-toolbar-field-width);
}
#top-bar {
align-items: center;
display: flex;
height: 40px;
margin-bottom: 12px;
padding: 8px 12px 0;
}
#icon {
height: 24px;
margin-inline-end: 12px;
......@@ -169,9 +191,9 @@
@apply --cr-icon-height-width;
}
</style>
<div class="page-container" id="container">
<div class="page-content">
<div class="page-header">
<div id="container">
<div id="main">
<div id="top-bar">
<paper-icon-button-light class="icon-arrow-back no-overlap">
<button id="closeButton" aria-label="$i18n{back}"
on-click="onCloseButtonTap_"></button>
......
......@@ -17,16 +17,20 @@
<link rel="import" href="code_section.html">
<link rel="import" href="item_util.html">
<link rel="import" href="navigation_helper.html">
<link rel="import" href="shared_style.html">
<dom-module id="extensions-error-page">
<template>
<style include="paper-button-style cr-icons cr-shared-style shared-style">
<style include="paper-button-style cr-icons cr-shared-style">
:host {
display: block;
height: 100%;
}
#container {
height: 100%;
overflow: overlay;
}
iron-icon {
--iron-icon-fill-color: var(--google-grey-refresh-700);
@apply --cr-icon-height-width;
......@@ -41,6 +45,17 @@
--iron-icon-fill-color: var(--paper-red-700);
}
/* TODO(dpapad): There is a lot of duplicated styling between
* detail_view.html and error_page.html. Refactor such that no duplication
* happens.*/
#main {
@apply --cr-card-elevation;
background-color: white;
margin: auto;
min-height: 100%;
width: 640px;
}
.section {
padding: 0 var(--cr-section-padding);
}
......@@ -154,8 +169,8 @@
outline: none;
}
</style>
<div class="page-container" id="container">
<div class="page-content">
<div id="container">
<div id="main">
<div id="heading">
<paper-icon-button-light class="icon-arrow-back no-overlap">
<button id="closeButton" aria-label="$i18n{back}"
......
......@@ -35,12 +35,6 @@
<structure name="IDR_MD_EXTENSIONS_ACTIVITY_LOG_JS"
file="activity_log.js"
type="chrome_html" />
<structure name="IDR_MD_EXTENSIONS_ACTIVITY_LOG_ITEM_HTML"
file="activity_log_item.html"
type="chrome_html" />
<structure name="IDR_MD_EXTENSIONS_ACTIVITY_LOG_ITEM_JS"
file="activity_log_item.js"
type="chrome_html" />
<structure name="IDR_MD_EXTENSIONS_DETAIL_VIEW_HTML"
file="detail_view.html"
type="chrome_html" />
......@@ -177,9 +171,6 @@
<structure name="IDR_MD_EXTENSIONS_SERVICE_JS"
file="service.js"
type="chrome_html" />
<structure name="IDR_MD_EXTENSIONS_SHARED_STYLE_HTML"
file="shared_style.html"
type="chrome_html" />
<structure name="IDR_MD_EXTENSIONS_SHORTCUT_INPUT_HTML"
file="shortcut_input.html"
type="chrome_html" />
......
......@@ -98,8 +98,7 @@
</cr-lazy-render>
<cr-lazy-render id="activity-log">
<template>
<extensions-activity-log delegate="[[delegate]]" slot="view"
extension-id="[[activityLogItemId_]]">
<extensions-activity-log slot="view">
</extensions-activity-log>
</template>
</cr-lazy-render>
......
......@@ -94,13 +94,6 @@ cr.define('extensions', function() {
*/
detailViewItem_: Object,
/**
* The id of the item for the activity log view subpage.
* See also errorPageItem_.
* @private {!string|undefined}
*/
activityLogItemId_: String,
/** @private {!Array<!chrome.developerPrivate.ExtensionInfo>} */
extensions_: Array,
......@@ -392,8 +385,6 @@ cr.define('extensions', function() {
this.errorPageItem_ && this.errorPageItem_.id == item.id &&
this.currentPage_.page == Page.ERRORS) {
this.errorPageItem_ = item;
} else if (this.currentPage_.page == Page.ACTIVITY_LOG) {
this.activityLogItemId_ = item.id;
}
},
......@@ -476,8 +467,6 @@ cr.define('extensions', function() {
{page: Page.DETAILS, extensionId: newPage.extensionId});
return;
}
this.activityLogItemId_ = assert(data.id);
}
if (fromPage != toPage) {
......
......@@ -6,7 +6,6 @@ cr.define('extensions', function() {
'use strict';
/**
* @implements {extensions.ActivityLogDelegate}
* @implements {extensions.ErrorPageDelegate}
* @implements {extensions.ItemDelegate}
* @implements {extensions.KeyboardShortcutDelegate}
......@@ -339,21 +338,6 @@ cr.define('extensions', function() {
showInFolder(id) {
chrome.developerPrivate.showPath(id);
}
/** @override */
getExtensionActivityLog(extensionId) {
return new Promise(function(resolve, reject) {
chrome.activityLogPrivate.getExtensionActivities(
{
activityType:
chrome.activityLogPrivate.ExtensionActivityFilter.ANY,
extensionId: extensionId
},
function(result) {
resolve(result);
});
});
}
}
cr.addSingletonGetter(Service);
......
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<dom-module id="shared-style">
<template>
<style include="cr-shared-style">
.page-container {
height: 100%;
overflow: overlay;
}
.page-content {
@apply --cr-card-elevation;
background-color: white;
margin: auto;
min-height: 100%;
padding-bottom: 64px;
width: var(--cr-toolbar-field-width);
}
.page-header {
align-items: center;
display: flex;
height: 40px;
margin-bottom: 12px;
padding: 8px 12px 0;
}
</style>
</template>
</dom-module>
......@@ -6,7 +6,6 @@
#include <string>
#include "base/command_line.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
......@@ -18,7 +17,6 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_contents_sizer.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
......@@ -217,51 +215,3 @@ IN_PROC_BROWSER_TEST_F(ExtensionSettingsUIBrowserTest, ListenerRegistration) {
expect_has_listeners(false);
}
}
class ExtensionsActivityLogTest : public ExtensionSettingsUIBrowserTest {
protected:
// Enable command line flags for test.
void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitch(switches::kEnableExtensionActivityLogging);
};
};
IN_PROC_BROWSER_TEST_F(ExtensionsActivityLogTest, TestActivityLogVisible) {
base::FilePath test_data_dir;
ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
test_data_dir = test_data_dir.AppendASCII("extensions");
extensions::ChromeTestExtensionLoader loader(browser()->profile());
const extensions::Extension* extension =
loader
.LoadExtension(test_data_dir.AppendASCII("activity_log/simple_call"))
.get();
ASSERT_TRUE(extension);
GURL activity_log_url("chrome://extensions/?activity=" + extension->id());
ui_test_utils::NavigateToURL(browser(), activity_log_url);
content::WebContents* activity_log_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(activity_log_contents);
EXPECT_EQ(activity_log_url, activity_log_contents->GetLastCommittedURL());
// We are looking for the 'tabs.query' entry in the activity log as that is
// the only API call the simple_call.crx extension does.
// The querySelectors and shadowRoots are used here in order to penetrate
// multiple nested shadow DOMs created by Polymer components
// in the chrome://extensions page.
// See chrome/browser/resources/md_extensions for the Polymer code.
// This test only serves as an end to end test, and most of the functionality
// is covered in the JS unit tests.
bool has_api_call = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
activity_log_contents,
R"(let manager = document.querySelector('extensions-manager');
let activityLog =
manager.shadowRoot.querySelector('extensions-activity-log');
let item = activityLog.shadowRoot.querySelector('activity-log-item');
let apiCall = item.shadowRoot.getElementById('api-call');
window.domAutomationController.send(
apiCall.innerText === 'tabs.query');)",
&has_api_call));
EXPECT_TRUE(has_api_call);
}
......@@ -192,7 +192,6 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"accessibilityErrorLine", IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_LINE},
{"accessibilityErrorMultiLine",
IDS_MD_EXTENSIONS_ACCESSIBILITY_ERROR_MULTI_LINE},
{"activityLogPageHeading", IDS_MD_EXTENSIONS_ACTIVITY_LOG_PAGE_HEADING},
{"appIcon", IDS_MD_EXTENSIONS_APP_ICON},
{"extensionIcon", IDS_MD_EXTENSIONS_EXTENSION_ICON},
{"extensionA11yAssociation", IDS_MD_EXTENSIONS_EXTENSION_A11Y_ASSOCIATION},
......@@ -227,7 +226,6 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"loadErrorFileLabel", IDS_MD_EXTENSIONS_LOAD_ERROR_FILE_LABEL},
{"loadErrorErrorLabel", IDS_MD_EXTENSIONS_LOAD_ERROR_ERROR_LABEL},
{"loadErrorRetry", IDS_MD_EXTENSIONS_LOAD_ERROR_RETRY},
{"noActivities", IDS_MD_EXTENSIONS_NO_ACTIVITIES},
{"noErrorsToShow", IDS_EXTENSIONS_ERROR_NO_ERRORS_CODE_MESSAGE},
{"runtimeHostsDialogInputError",
IDS_MD_EXTENSIONS_RUNTIME_HOSTS_DIALOG_INPUT_ERROR},
......@@ -261,7 +259,7 @@ content::WebUIDataSource* CreateMdExtensionsSource(bool in_dev_mode) {
{"toolbarUpdatingToast", IDS_MD_EXTENSIONS_TOOLBAR_UPDATING_TOAST},
{"updateRequiredByPolicy",
IDS_MD_EXTENSIONS_DISABLED_UPDATE_REQUIRED_BY_POLICY},
{"viewActivityLog", IDS_EXTENSIONS_VIEW_ACTIVITY_LOG},
{"viewActivityLog", IDS_EXTENSIONS_ACTIVITY_LOG},
{"viewBackgroundPage", IDS_EXTENSIONS_BACKGROUND_PAGE},
{"viewIncognito", IDS_EXTENSIONS_VIEW_INCOGNITO},
{"viewInactive", IDS_EXTENSIONS_VIEW_INACTIVE},
......
......@@ -26,7 +26,6 @@ def _CheckExterns(input_api, output_api):
externs_root = join(src_root, 'third_party', 'closure_compiler', 'externs')
api_pair_names = {
'activity_log_private.json': 'activity_log_private.js',
'autofill_private.idl': 'autofill_private.js',
'automation.idl': 'automation.js',
'developer_private.idl': 'developer_private.js',
......
......@@ -61,16 +61,10 @@
"dependencies": ["manifest:action"],
"contexts": ["blessed_extension"]
},
"activityLogPrivate": [{
"activityLogPrivate": {
"dependencies": ["permission:activityLogPrivate"],
"contexts": ["blessed_extension"]
}, {
"channel": "stable",
"contexts": ["webui"],
"matches": [
"chrome://extensions/*"
]
}],
},
"app": {
"blacklist": [
"2FC374607C2DF285634B67C64A2E356C607091C3", // Quickoffice
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This extension makes a single call to the tab API, it is used to test the
// activity log page as it should display a call for this extension.
// This test might be expanded upon in the future.
chrome.tabs.query({}, (tabs) => {
console.log(`queried tabs: ${tabs}`);
});
{
"name": "Activity log call testing extension",
"description": "Extension that makes 1 API call, used to test activity log.",
"manifest_version": 2,
"version": "2.0",
"permissions": [
"tabs"
],
"background": {
"scripts": ["background.js"]
}
}
......@@ -13,7 +13,6 @@
// related and whose tests fail.
var expected = [
'activityLogPrivate',
'csi',
'developerPrivate',
'getVariableValue',
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** @fileoverview Suite of tests for extensions-activity-log. */
suite('ExtensionsActivityLogTest', function() {
/**
* Backing extension id, same id as the one in
* extension_test_util.createExtensionInfo
* @type {string}
*/
const EXTENSION_ID = 'a'.repeat(32);
/**
* Extension activityLog created before each test.
* @type {extensions.ActivityLog}
*/
let activityLog;
let proxyDelegate;
let testVisible;
const testActivities = {
activities: [
{
activityId: '299',
activityType: 'api_call',
apiCall: 'i18n.getUILanguage',
args: 'null',
count: 10,
extensionId: EXTENSION_ID,
time: 1541203132002.664
},
{
activityId: '309',
activityType: 'dom_access',
apiCall: 'Storage.getItem',
args: 'null',
count: 9,
extensionId: EXTENSION_ID,
other: {domVerb: 'method'},
pageTitle: 'Test Extension',
pageUrl: `chrome-extension://${EXTENSION_ID}/index.html`,
time: 1541203131994.837
},
]
};
// Initialize an extension activity log before each test.
setup(function() {
PolymerTest.clearBody();
activityLog = new extensions.ActivityLog();
testVisible = extension_test_util.testVisible.bind(null, activityLog);
activityLog.extensionId = EXTENSION_ID;
proxyDelegate = new extensions.TestService();
activityLog.delegate = proxyDelegate;
proxyDelegate.testActivities = testActivities;
document.body.appendChild(activityLog);
// Wait until we have finished making the call to fetch the activity log.
return proxyDelegate.whenCalled('getExtensionActivityLog');
});
teardown(function() {
activityLog.remove();
});
test('activities are present for extension', function() {
Polymer.dom.flush();
expectEquals(
activityLog.shadowRoot.querySelectorAll('activity-log-item').length, 2);
});
test('message shown when no activities present for extension', function() {
// Spoof an API call and pretend that the extension has no activities.
activityLog.activityData_ = {
activities: [],
};
Polymer.dom.flush();
testVisible('#no-activities', true);
expectEquals(
activityLog.shadowRoot.querySelectorAll('activity-log-item').length, 0);
});
test('clicking on back button navigates to the details page', function() {
Polymer.dom.flush();
let currentPage = null;
extensions.navigation.addListener(newPage => {
currentPage = newPage;
});
activityLog.$$('#close-button').click();
expectDeepEquals(
currentPage, {page: Page.DETAILS, extensionId: EXTENSION_ID});
});
});
......@@ -196,26 +196,6 @@ TEST_F('CrExtensionsItemsTest', 'HtmlInName', function() {
this.runMochaTest(extension_item_tests.TestNames.HtmlInName);
});
////////////////////////////////////////////////////////////////////////////////
// Extension Activity Log Tests
CrExtensionsActivityLogTest = class extends CrExtensionsBrowserTest {
/** @override */
get browsePreload() {
return 'chrome://extensions/activity_log.html';
}
get extraLibraries() {
return super.extraLibraries.concat([
'activity_log_test.js',
]);
}
};
TEST_F('CrExtensionsActivityLogTest', 'All', () => {
mocha.run();
});
////////////////////////////////////////////////////////////////////////////////
// Extension Detail View Tests
......
......@@ -8,7 +8,6 @@ cr.define('extensions', function() {
constructor() {
super([
'addRuntimeHostPermission',
'getExtensionActivityLog',
'getExtensionsInfo',
'getExtensionSize',
'getProfileConfiguration',
......@@ -36,9 +35,6 @@ cr.define('extensions', function() {
/** @type {boolean} */
this.forceReloadItemError_ = false;
/** @type {!chrome.activityLogPrivate.ActivityResultSet|undefined} */
this.testActivities = undefined;
}
/**
......@@ -153,12 +149,6 @@ cr.define('extensions', function() {
this.methodCalled('updateAllExtensions');
return Promise.resolve();
}
/** @override */
getExtensionActivityLog(id) {
this.methodCalled('getExtensionActivityLog', id);
return Promise.resolve(this.testActivities);
}
}
return {
......
......@@ -68,7 +68,6 @@ CrElementsSliderTest.*
CrElementsToastTest.*
CrElementsToggleTest.*
CrElementsToolbarSearchFieldTest.*
CrExtensionsActivityLogTest.*
CrExtensionsA11yTest.*
CrExtensionsA11yTestWithMultipleExensions.*
CrExtensionsCodeSectionTest.*
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file was generated by:
// tools/json_schema_compiler/compiler.py.
// NOTE: The format of types has changed. 'FooType' is now
// 'chrome.activityLogPrivate.FooType'.
// Please run the closure compiler before committing changes.
// See https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md
/** @fileoverview Externs generated from namespace: activityLogPrivate */
/**
* @const
*/
chrome.activityLogPrivate = {};
/**
* @enum {string}
*/
chrome.activityLogPrivate.ExtensionActivityType = {
API_CALL: 'api_call',
API_EVENT: 'api_event',
CONTENT_SCRIPT: 'content_script',
DOM_ACCESS: 'dom_access',
DOM_EVENT: 'dom_event',
WEB_REQUEST: 'web_request',
};
/**
* @enum {string}
*/
chrome.activityLogPrivate.ExtensionActivityFilter = {
API_CALL: 'api_call',
API_EVENT: 'api_event',
CONTENT_SCRIPT: 'content_script',
DOM_ACCESS: 'dom_access',
DOM_EVENT: 'dom_event',
WEB_REQUEST: 'web_request',
ANY: 'any',
};
/**
* @enum {string}
*/
chrome.activityLogPrivate.ExtensionActivityDomVerb = {
GETTER: 'getter',
SETTER: 'setter',
METHOD: 'method',
INSERTED: 'inserted',
XHR: 'xhr',
WEBREQUEST: 'webrequest',
MODIFIED: 'modified',
};
/**
* This corresponds to a row from the ActivityLog database. Fields will be blank if they were specified precisely in a lookup filter.
* @typedef {{
* activityId: (string|undefined),
* extensionId: (string|undefined),
* activityType: !chrome.activityLogPrivate.ExtensionActivityType,
* time: (number|undefined),
* apiCall: (string|undefined),
* args: (string|undefined),
* count: (number|undefined),
* pageUrl: (string|undefined),
* pageTitle: (string|undefined),
* argUrl: (string|undefined),
* other: ({
* prerender: (boolean|undefined),
* domVerb: (!chrome.activityLogPrivate.ExtensionActivityDomVerb|undefined),
* webRequest: (string|undefined),
* extra: (string|undefined)
* }|undefined)
* }}
*/
chrome.activityLogPrivate.ExtensionActivity;
/**
* Used to specify values for a lookup.
* @typedef {{
* extensionId: (string|undefined),
* activityType: !chrome.activityLogPrivate.ExtensionActivityFilter,
* apiCall: (string|undefined),
* pageUrl: (string|undefined),
* argUrl: (string|undefined),
* daysAgo: (number|undefined)
* }}
*/
chrome.activityLogPrivate.Filter;
/**
* This holds the results of a lookup, the filter of the lookup, the time of the lookup, and whether there are more results that match.
* @typedef {{
* activities: !Array<!chrome.activityLogPrivate.ExtensionActivity>
* }}
*/
chrome.activityLogPrivate.ActivityResultSet;
/**
* Retrieves activity from the ActivityLog that matches the specified filter.
* @param {!chrome.activityLogPrivate.Filter} filter Fill out the fields that
* you want to search for in the database.
* @param {function(!chrome.activityLogPrivate.ActivityResultSet):void} callback
*/
chrome.activityLogPrivate.getExtensionActivities = function(filter, callback) {};
/**
* Deletes activities in the ActivityLog database specified in the array of
* activity IDs.
* @param {!Array<string>} activityIds Erases only the activities which IDs are
* listed in the array.
*/
chrome.activityLogPrivate.deleteActivities = function(activityIds) {};
/**
* Deletes the entire ActivityLog database.
*/
chrome.activityLogPrivate.deleteDatabase = function() {};
/**
* Delete URLs in the ActivityLog database.
* @param {!Array<string>=} urls Erases only the URLs listed; if empty, erases
* all URLs.
*/
chrome.activityLogPrivate.deleteUrls = function(urls) {};
/**
* Fired when a given extension performs another activity.
* @type {!ChromeEvent}
*/
chrome.activityLogPrivate.onExtensionActivity;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment