1 This directory contains tests for chrome extension activity logging.
3 The tests use two chrome extensions:
4 -test : sends messages to the friend extension and listens for activity
5 logged by the friend extension. Checks the activity has been logged
7 -friend: receives messages from the extension and runs a function based on
8 the contents of the message.
14 (1) Add a function to call the chrome api calls you want to test. If you
15 need to use window.open please consider adding your code to
16 executeApiCallsOnTabUpdated or executeDOMChangesOnTabUpdated. Every
17 extra window.open call will slow down the tests by 3s and may cause
19 (2) Add the name of the new function to the function map (fnMap).
21 IMPORTANT NOTES for adding tests:
22 - The function should clean up any changes it made (e.g. listeners
23 it added) before finishing. If they are not cleaned up then unexpected
24 behavior can happen in test cases that run after this function.
25 - Every window.open call can add 3 secs to the test run for debug builds.
26 Making lots of window.open calls will therefore cause the tests to
27 timeout. If your test needs to use window.open please consider adding
28 it to one of the following existing functions:
29 - executeApiCallsOnTabUpdated
30 - executeDOMChangesOnTabUpdated
32 In friend/options.html:
33 (1) Add a button to allow the new function to be called in manual mode.
35 You may need also to modify the manifest.json and other files in the
36 friend extension directory.
39 (1) Add the test to the testcase array.
41 You will need to define the function that sends a message to the
42 friend extension and define the expected activity logging. Example:
45 func: function triggerMyFunctionCall() {
46 chrome.runtime.sendMessage(FRIEND_EXTENSION_ID,
47 'my_function_call_id',
48 function response() { });
50 expected_activity: ['api.call1', 'api.call2', 'api.call3']
53 where 'my_function_call_id' is the key you added to the fn_map in
57 Running a testcase in Incognito mode:
59 To check logging when run in incognito mode, add the following to the
64 This will automatically cause all new tabs to be opened in incognito mode and
65 check the url information has been correctly cleaned.
68 Configuring a testcase for a particular OS:
70 If you need to disable a test for a particular OS then you can do this by
71 adding the disabled field to the test case. For example:
73 disabled: {win: true, mac: true}
75 If you need to configure different expected activity for a particular OS, you
76 can override the logging. E.g.:
78 expected_activity_win: ['api.call1', 'api.call2', 'api.call3']
79 expected_activity_mac: ['api.call1', 'api.call2', 'api.call3']
81 See the chrome.runtime.getPlatformInfo documentation for details of which OS
87 > out/Debug/browser_tests --gtest_filter=ActivityLogApiTest.TriggerEvent
90 Running in manual mode:
92 (1) Start chrome with out/Debug/chrome
93 (2) Navigate to chrome://extensions
94 (3) Install the friend and test extensions from your chrome src folder
95 (4) Click on the "options" link under the friend extension
96 (5) You should see the options page the buttons to run the functions manually