Commit ccc249fb authored by pmarch@chromium.org's avatar pmarch@chromium.org

Enabling ActivityLogApiTest.TriggerEvent after Activity Log refactoring.

BUG=388289

Review URL: https://codereview.chromium.org/393583002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283802 0039d316-1c4b-4281-b951-d872f2087c98
parent 46a19f62
......@@ -46,11 +46,16 @@ class ActivityLogApiTest : public ExtensionApiTest {
CommandLine saved_cmdline_;
};
#if defined(OS_WIN) && !defined(NDEBUG)
// TODO(pmarch): fix flakiness on win debug - crbug.com/299393
#define MAYBE_TriggerEvent DISABLED_TriggerEvent
#else
#define MAYBE_TriggerEvent TriggerEvent
#endif
// The test extension sends a message to its 'friend'. The test completes
// if it successfully sees the 'friend' receive the message.
// TODO(pmarch): Enable this test once modifications to Blink are done,
// crbug.com/388287.
IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, DISABLED_TriggerEvent) {
IN_PROC_BROWSER_TEST_F(ActivityLogApiTest, MAYBE_TriggerEvent) {
ActivityLog::GetInstance(profile())->SetWatchdogAppActiveForTesting(true);
host_resolver()->AddRule("*", "127.0.0.1");
......
......@@ -84,8 +84,7 @@ testCases.push({
'background_xhr', function response() { });
},
expected_activity: [
'XMLHttpRequest.open',
'XMLHttpRequest.setRequestHeader'
'blinkRequestResource XMLHttpRequest',
]
});
testCases.push({
......@@ -176,7 +175,6 @@ testCases.push({
'tabs.sendMessage',
'tabs.executeScript',
'tabs.executeScript',
'HTMLDocument.write',
'tabs.remove'
]
});
......@@ -195,7 +193,6 @@ testCases.push({
'tabs.sendMessage',
'tabs.executeScript',
'tabs.executeScript',
'HTMLDocument.write',
'tabs.remove'
]
});
......@@ -217,21 +214,11 @@ var domExpectedActivity = [
'tabs.onUpdated',
'tabs.executeScript',
// Location access
'Window.location',
'Document.location',
'Window.location',
'Location.assign',
'Location.replace',
// Dom mutations
'Document.createElement',
'Document.createElement',
'Node.appendChild',
'Node.insertBefore',
'Node.replaceChild',
//'Document.location',
'HTMLDocument.write',
'HTMLDocument.writeln',
'Element.innerHTML',
'blinkSetAttribute LocalDOMWindow url',
'blinkSetAttribute LocalDOMWindow url',
'blinkSetAttribute LocalDOMWindow url',
'blinkSetAttribute LocalDOMWindow url',
// Dom mutations
// Navigator access
'Window.navigator',
'Geolocation.getCurrentPosition',
......@@ -253,25 +240,22 @@ var domExpectedActivity = [
// Web database access
'Window.openDatabase',
// Canvas access
'Document.createElement',
'HTMLCanvasElement.getContext',
// XHR from content script.
'XMLHttpRequest.open',
'XMLHttpRequest.setRequestHeader',
'HTMLDocument.write'
'blinkRequestResource XMLHttpRequest',
];
// add the hook activity
hookNames = ['onclick', 'ondblclick', 'ondrag', 'ondragend', 'ondragenter',
'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'oninput',
'onkeydown', 'onkeypress', 'onkeyup', 'onmousedown',
'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout',
'onmouseover', 'onmouseup', 'onmousewheel'];
hookNames = ['click', 'dblclick', 'drag', 'dragend', 'dragenter',
'dragleave', 'dragover', 'dragstart', 'drop', 'input',
'keydown', 'keypress', 'keyup', 'mousedown',
'mouseenter', 'mouseleave', 'mousemove', 'mouseout',
'mouseover', 'mouseup', 'mousewheel'];
for (var i = 0; i < hookNames.length; i++) {
domExpectedActivity.push('HTMLElement.' + hookNames[i]);
domExpectedActivity.push('Document.' + hookNames[i]);
domExpectedActivity.push('Window.' + hookNames[i]);
domExpectedActivity.push('blinkAddEventListener BODY ' + hookNames[i]);
domExpectedActivity.push('blinkAddEventListener #document ' + hookNames[i]);
domExpectedActivity.push('blinkAddEventListener LocalDOMWindow ' +
hookNames[i]);
}
// Close the tab.
......@@ -334,15 +318,15 @@ testCases.push({
var filter = new Object();
filter.extensionId = FRIEND_EXTENSION_ID;
filter.activityType = 'dom_access';
filter.apiCall = 'Document.location';
filter.apiCall = 'blinkSetAttribute';
chrome.activityLogPrivate.getExtensionActivities(
filter,
function(result) {
chrome.test.assertEq(FRIEND_EXTENSION_ID,
result['activities'][0]['extensionId']);
chrome.test.assertEq('Document.location',
chrome.test.assertEq('blinkSetAttribute',
result['activities'][0]['apiCall']);
chrome.test.assertEq('setter',
chrome.test.assertEq('method',
result['activities'][0]['other']['domVerb']);
chrome.test.succeed();
});
......@@ -466,6 +450,10 @@ function checkIncognito(url, incognitoExpected) {
var testCaseIndx = 0;
var callIndx = -1;
var enabledTestCases = [];
var blinkArgs = {
'blinkRequestResource': 2,
'blinkSetAttribute': 3
};
chrome.activityLogPrivate.onExtensionActivity.addListener(
function(activity) {
......@@ -474,6 +462,12 @@ chrome.activityLogPrivate.onExtensionActivity.addListener(
// Check the api call is the one we expected next.
var apiCall = activity['apiCall'];
if (apiCall.indexOf('blink') == 0) {
var args = JSON.parse(activity['args']);
if (blinkArgs[apiCall])
args = args.splice(0, blinkArgs[apiCall] - 1);
apiCall += ' ' + args.join(' ');
}
expectedCall = 'runtime.onMessageExternal';
var testCase = enabledTestCases[testCaseIndx];
if (callIndx > -1) {
......
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