summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/sync_internals_browsertest.js
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 20:59:01 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 20:59:01 +0000
commit34da86a6d837a137631c4d9c98d0d8e6709edb01 (patch)
tree24789fd85d009a4712cea24abf936745a066babb /chrome/browser/ui/webui/sync_internals_browsertest.js
parentb4f5dae6842567d21ca5eedca1f1aedcb5387a60 (diff)
downloadchromium_src-34da86a6d837a137631c4d9c98d0d8e6709edb01.zip
chromium_src-34da86a6d837a137631c4d9c98d0d8e6709edb01.tar.gz
chromium_src-34da86a6d837a137631c4d9c98d0d8e6709edb01.tar.bz2
sync: Remove some WebUI debug functions
This CL removes a number of functions from the sync debugging framework in order to prepare for some upcoming changes to sync debugging (due to 328606). This CL removes the following functions: - GetRootNodeDetails - GetNodeSummaries - GetNodeDetails - GetChildNodeIds It also adds the function 'getListOfKnownTypes' to help replace some old functionality required by the 'data' tab and to fix issue 329013. Rather than having that tab fetch a list of children of the root node, it now asks for a list of all known data types. This is a better solution, since it does not require sync to be fully initialized in order to properly populate the set of checkboxes. The most significant user of the removed functionality is the node browser. Its javascript code has been modified in order to transition it to relying on the getAllNodes function. Rather than fetching node data on demand by a series of asynchronous callbacks, the tab now fetches a list of all known sync nodes at once. This has the advantage of providing a more consistent (though more stale) snapshot. This CL adds a refresh button to the node browser tab in order to give users some control over its staleness. This change had some minor side-effects. The node browser now relies on items' string-based IDs rather than their metahandles when determining the nodes' hierarchy. We've also had to add a 'positionIndex' field to the output of getAllNodes to make it easier for the node browser to sort its entries. In part to make it easier to fetch this field, most of the code associated with getAllNodes has been moved into the syncable::Directory. In addition to all these changes, this CL adds some webui tests to help prevent regressions in about:sync functionality. For now, they only cover the node browser. More tests will be added in future CLs. BUG=110517,329013,328606 Review URL: https://codereview.chromium.org/134443004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245313 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/webui/sync_internals_browsertest.js')
-rw-r--r--chrome/browser/ui/webui/sync_internals_browsertest.js166
1 files changed, 165 insertions, 1 deletions
diff --git a/chrome/browser/ui/webui/sync_internals_browsertest.js b/chrome/browser/ui/webui/sync_internals_browsertest.js
index 5a261bf..733bac5 100644
--- a/chrome/browser/ui/webui/sync_internals_browsertest.js
+++ b/chrome/browser/ui/webui/sync_internals_browsertest.js
@@ -20,7 +20,9 @@ SyncInternalsWebUITest.prototype = {
/** @override */
preLoad: function() {
- // TODO(zea): mock out the the sync info to fake an active syncer.
+ this.makeAndRegisterMockHandler([
+ 'getAllNodes',
+ ]);
},
/**
@@ -48,6 +50,114 @@ SyncInternalsWebUITest.prototype = {
}
};
+/** Constant hard-coded value to return from mock getAllNodes */
+var HARD_CODED_ALL_NODES = [
+{
+ "BASE_SERVER_SPECIFICS": {},
+ "BASE_VERSION": "1388699799780000",
+ "CTIME": "Wednesday, December 31, 1969 4:00:00 PM",
+ "ID": "sZ:ADqtAZw5kjSwSkukraMoMX6z0OlFXENzhA+1HZNcO6LbATQrkVenHJS5" +
+ "AgICYfj8/6KcvwlCw3FIvcRFtOEP3zSP5YJ1VH53/Q==",
+ "IS_DEL": false,
+ "IS_DIR": true,
+ "IS_UNAPPLIED_UPDATE": false,
+ "IS_UNSYNCED": false,
+ "LOCAL_EXTERNAL_ID": "0",
+ "META_HANDLE": "376",
+ "MTIME": "Wednesday, December 31, 1969 4:00:00 PM",
+ "NON_UNIQUE_NAME": "Typed URLs",
+ "PARENT_ID": "r",
+ "SERVER_CTIME": "Wednesday, December 31, 1969 4:00:00 PM",
+ "SERVER_IS_DEL": false,
+ "SERVER_IS_DIR": true,
+ "SERVER_MTIME": "Wednesday, December 31, 1969 4:00:00 PM",
+ "SERVER_NON_UNIQUE_NAME": "Typed URLs",
+ "SERVER_PARENT_ID": "r",
+ "SERVER_SPECIFICS": {
+ "typed_url": {
+ "visit_transitions": [],
+ "visits": []
+ }
+ },
+ "SERVER_UNIQUE_POSITION": "INVALID[]",
+ "SERVER_VERSION": "1388699799780000",
+ "SPECIFICS": {
+ "typed_url": {
+ "visit_transitions": [],
+ "visits": []
+ }
+ },
+ "SYNCING": false,
+ "TRANSACTION_VERSION": "1",
+ "UNIQUE_BOOKMARK_TAG": "",
+ "UNIQUE_CLIENT_TAG": "",
+ "UNIQUE_POSITION": "INVALID[]",
+ "UNIQUE_SERVER_TAG": "google_chrome_typed_urls",
+ "isDirty": false,
+ "serverModelType": "Typed URLs"
+},
+{
+ "BASE_SERVER_SPECIFICS": {},
+ "BASE_VERSION": "1372291923970334",
+ "CTIME": "Wednesday, June 26, 2013 5:12:03 PM",
+ "ID": "sZ:ADqtAZyz70DhOIusPT1v2XCd/8YT8Fy43WlqdRyH6UwoBAqMkX5Pnkl/sW9A" +
+ "+AVrmzAPWFTrRBf0AWD57HyN4GcYXwSR9q4lYA==",
+ "IS_DEL": false,
+ "IS_DIR": false,
+ "IS_UNAPPLIED_UPDATE": false,
+ "IS_UNSYNCED": false,
+ "LOCAL_EXTERNAL_ID": "0",
+ "META_HANDLE": "3011",
+ "MTIME": "Wednesday, June 26, 2013 5:12:03 PM",
+ "NON_UNIQUE_NAME": "http://chrome.com/",
+ "PARENT_ID": "sZ:ADqtAZw5kjSwSkukraMoMX6z0OlFXENzhA+1HZNcO6LbATQrkVen" +
+ "HJS5AgICYfj8/6KcvwlCw3FIvcRFtOEP3zSP5YJ1VH53/Q==",
+ "SERVER_CTIME": "Wednesday, June 26, 2013 5:12:03 PM",
+ "SERVER_IS_DEL": false,
+ "SERVER_IS_DIR": false,
+ "SERVER_MTIME": "Wednesday, June 26, 2013 5:12:03 PM",
+ "SERVER_NON_UNIQUE_NAME": "http://chrome.com/",
+ "SERVER_PARENT_ID": "sZ:ADqtAZw5kjSwSkukraMoMX6z0OlFXENzhA+1HZNcO6LbAT" +
+ "QrkVenHJS5AgICYfj8/6KcvwlCw3FIvcRFtOEP3zSP5YJ1VH53/Q==",
+ "SERVER_SPECIFICS": {
+ "typed_url": {
+ "hidden": false,
+ "title": "Chrome",
+ "url": "http://chrome.com/",
+ "visit_transitions": [
+ "268435457"
+ ],
+ "visits": [
+ "13016765523677321"
+ ]
+ }
+ },
+ "SERVER_UNIQUE_POSITION": "INVALID[]",
+ "SERVER_VERSION": "1372291923970334",
+ "SPECIFICS": {
+ "typed_url": {
+ "hidden": false,
+ "title": "Chrome",
+ "url": "http://chrome.com/",
+ "visit_transitions": [
+ "268435457"
+ ],
+ "visits": [
+ "13016765523677321"
+ ]
+ }
+ },
+ "SYNCING": false,
+ "TRANSACTION_VERSION": "1",
+ "UNIQUE_BOOKMARK_TAG": "",
+ "UNIQUE_CLIENT_TAG": "J28uWKpXPuQwR3SJKbuLqzYGOcM=",
+ "UNIQUE_POSITION": "INVALID[]",
+ "UNIQUE_SERVER_TAG": "",
+ "isDirty": false,
+ "serverModelType": "Typed URLs"
+}
+];
+
TEST_F('SyncInternalsWebUITest', 'Uninitialized', function() {
assertNotEquals(null, chrome.sync.aboutInfo);
expectTrue(this.hasInDetails(true, 'Username', ''));
@@ -77,3 +187,57 @@ TEST_F('SyncInternalsWebUITest', 'SearchTabDoesntChangeOnItemSelect',
$('sync-results-list').getListItemByIndex(0).selected = true;
expectTrue($('sync-search-tab').selected);
});
+
+TEST_F('SyncInternalsWebUITest', 'NodeBrowserTest', function() {
+ this.mockHandler.expects(once()).getAllNodes([]).will(
+ callFunction(function() {
+ chrome.sync.getAllNodes.handleReply(HARD_CODED_ALL_NODES);
+ }));
+
+ // Hit the refresh button.
+ $('node-browser-refresh-button').click();
+
+ // Check that the refresh time was updated.
+ expectNotEquals($('node-browser-refresh-time').textContent, 'Never');
+
+ // Verify some hard-coded assumptions. These depend on the vaue of the
+ // hard-coded nodes, specified elsewhere in this file.
+
+ // Start with the tree itself.
+ var tree = $('sync-node-tree');
+ assertEquals(1, tree.items.length);
+
+ // Check the type root and expand it.
+ var typeRoot = tree.items[0];
+ expectFalse(typeRoot.expanded);
+ typeRoot.expanded = true;
+ assertEquals(1, typeRoot.items.length);
+
+ // An actual sync node. The child of the type root.
+ var leaf = typeRoot.items[0];
+
+ // Verify that selecting it affects the details view.
+ expectTrue($('node-details').hasAttribute('hidden'));
+ leaf.selected = true;
+ expectFalse($('node-details').hasAttribute('hidden'));
+});
+
+TEST_F('SyncInternalsWebUITest', 'NodeBrowserRefreshOnTabSelect', function() {
+ this.mockHandler.expects(once()).getAllNodes([]).will(
+ callFunction(function() {
+ chrome.sync.getAllNodes.handleReply(HARD_CODED_ALL_NODES);
+ }));
+
+ // Should start with non-refreshed node browser.
+ expectEquals($('node-browser-refresh-time').textContent, 'Never');
+
+ // Selecting the tab will refresh it.
+ $('sync-browser-tab').selected = true;
+ expectNotEquals($('node-browser-refresh-time').textContent, 'Never');
+
+ // Re-selecting the tab shouldn't re-refresh.
+ $('node-browser-refresh-time').textContent = 'TestCanary';
+ $('sync-browser-tab').selected = false;
+ $('sync-browser-tab').selected = true;
+ expectEquals($('node-browser-refresh-time').textContent, 'TestCanary');
+});