summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authorvitalyp <vitalyp@chromium.org>2014-09-30 17:44:58 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-01 00:45:10 +0000
commit5d8e6e26496546a78df69aee799bbe3f60a8ee7f (patch)
tree98f10429f40255ecc0c1a40885c01ca7e8fedfa9 /third_party
parentd102d04d237761cb414e253504e8bee4a0decd36 (diff)
downloadchromium_src-5d8e6e26496546a78df69aee799bbe3f60a8ee7f.zip
chromium_src-5d8e6e26496546a78df69aee799bbe3f60a8ee7f.tar.gz
chromium_src-5d8e6e26496546a78df69aee799bbe3f60a8ee7f.tar.bz2
Typecheck chrome://bookmarks using Closure Compiler
R=dbeam@chromium.org BUG=393873 TEST=GYP_GENERATORS=ninja gyp --depth . chrome/browser/resources/bookmark_manager/js/compiled_resources.gyp && ninja -C out/Default Review URL: https://codereview.chromium.org/543863002 Cr-Commit-Position: refs/heads/master@{#297560}
Diffstat (limited to 'third_party')
-rw-r--r--third_party/closure_compiler/externs/bookmark_manager_private.js199
-rw-r--r--third_party/closure_compiler/externs/metrics_private.js117
-rw-r--r--third_party/closure_compiler/externs/system_private.js69
-rw-r--r--third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java10
-rw-r--r--third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java30
5 files changed, 420 insertions, 5 deletions
diff --git a/third_party/closure_compiler/externs/bookmark_manager_private.js b/third_party/closure_compiler/externs/bookmark_manager_private.js
new file mode 100644
index 0000000..e59da2b
--- /dev/null
+++ b/third_party/closure_compiler/externs/bookmark_manager_private.js
@@ -0,0 +1,199 @@
+// Copyright 2014 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 Externs generated from namespace: bookmarkManagerPrivate */
+
+/**
+ * @typedef {{
+ * id: (string|undefined),
+ * parentId: (string|undefined),
+ * title: string,
+ * url: (string|undefined),
+ * children: Array
+ * }}
+ */
+var BookmarkNodeDataElement;
+
+/**
+ * Information about the drag and drop data for use with drag and drop events.
+ * @typedef {{
+ * sameProfile: boolean,
+ * elements: Array
+ * }}
+ */
+var BookmarkNodeData;
+
+/**
+ * Collection of meta info fields.
+ * @typedef {Object}
+ */
+var MetaInfoFields;
+
+/**
+ * @const
+ */
+chrome.bookmarkManagerPrivate = {};
+
+/**
+ * Copies the given bookmarks into the clipboard
+ * @param {Array} idList An array of string-valued ids
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.copy = function(idList, callback) {};
+
+/**
+ * Cuts the given bookmarks into the clipboard
+ * @param {Array} idList An array of string-valued ids
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.cut = function(idList, callback) {};
+
+/**
+ * Pastes bookmarks from the clipboard into the parent folder after the last
+ * selected node
+ * @param {string} parentId
+ * @param {Array=} selectedIdList An array of string-valued ids for selected
+ * bookmarks
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.paste = function(parentId, selectedIdList, callback) {};
+
+/**
+ * Whether there are any bookmarks that can be pasted
+ * @param {string} parentId The ID of the folder to paste into
+ * @param {Function} callback
+ */
+chrome.bookmarkManagerPrivate.canPaste = function(parentId, callback) {};
+
+/**
+ * Sorts the children of a given folder
+ * @param {string} parentId The ID of the folder to sort the children of
+ */
+chrome.bookmarkManagerPrivate.sortChildren = function(parentId) {};
+
+/**
+ * Gets the i18n strings for the bookmark manager
+ * @param {Function} callback
+ */
+chrome.bookmarkManagerPrivate.getStrings = function(callback) {};
+
+/**
+ * Begins dragging a set of bookmarks
+ * @param {Array} idList An array of string-valued ids
+ * @param {boolean} isFromTouch True if the drag was initiated from touch
+ */
+chrome.bookmarkManagerPrivate.startDrag = function(idList, isFromTouch) {};
+
+/**
+ * Performs the drop action of the drag and drop session
+ * @param {string} parentId The ID of the folder that the drop was made
+ * @param {number=} index The index of the position to drop at. If left out the
+ * dropped items will be placed at the end of the existing children
+ */
+chrome.bookmarkManagerPrivate.drop = function(parentId, index) {};
+
+/**
+ * Retrieves a bookmark hierarchy from the given node. If the node id is
+ * empty, it is the full tree. If foldersOnly is true, it will only return
+ * folders, not actual bookmarks.
+ * @param {string} id ID of the root of the tree to pull. If empty, the entire
+ * tree will be returned.
+ * @param {boolean} foldersOnly Pass true to only return folders.
+ * @param {Function} callback
+ */
+chrome.bookmarkManagerPrivate.getSubtree = function(id, foldersOnly, callback) {};
+
+/**
+ * Whether bookmarks can be modified
+ * @param {Function} callback
+ */
+chrome.bookmarkManagerPrivate.canEdit = function(callback) {};
+
+/**
+ * Whether bookmarks can be opened in new windows
+ * @param {Function} callback
+ */
+chrome.bookmarkManagerPrivate.canOpenNewWindows = function(callback) {};
+
+/**
+ * Recursively removes list of bookmarks nodes.
+ * @param {Array} idList An array of string-valued ids
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.removeTrees = function(idList, callback) {};
+
+/**
+ */
+chrome.bookmarkManagerPrivate.recordLaunch = function() {};
+
+/**
+ * Mimics the functionality of bookmarks.create, but will additionally set the
+ * given meta info fields.
+ * @param {chrome.bookmarks.CreateDetails} bookmark
+ * @param {MetaInfoFields} metaInfo
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.createWithMetaInfo = function(bookmark, metaInfo, callback) {};
+
+/**
+ * Gets meta info from a bookmark node
+ * @param {string=} id The id of the bookmark to retrieve meta info from. If
+ * omitted meta info for all nodes is returned.
+ * @param {string=} key The key for the meta info to retrieve. If omitted, all
+ * fields are returned
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.getMetaInfo = function(id, key, callback) {};
+
+/**
+ * Sets a meta info value for a bookmark node
+ * @param {string} id The id of the bookmark node to set the meta info on
+ * @param {string} key The key of the meta info to set
+ * @param {string} value The meta info to set
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.setMetaInfo = function(id, key, value, callback) {};
+
+/**
+ * Updates a set of meta info values for a bookmark node.
+ * @param {string} id The id of the bookmark node to update the meta info of.
+ * @param {MetaInfoFields} metaInfoChanges A set of meta info key/value pairs
+ * to update.
+ * @param {Function=} callback
+ */
+chrome.bookmarkManagerPrivate.updateMetaInfo = function(id, metaInfoChanges, callback) {};
+
+/**
+ * Performs an undo of the last change to the bookmark model
+ */
+chrome.bookmarkManagerPrivate.undo = function() {};
+
+/**
+ * Performs a redo of last undone change to the bookmark model
+ */
+chrome.bookmarkManagerPrivate.redo = function() {};
+
+/**
+ * Gets the information for the undo if available
+ * @param {Function} callback
+ */
+chrome.bookmarkManagerPrivate.getUndoInfo = function(callback) {};
+
+/**
+ * Gets the information for the redo if available
+ * @param {Function} callback
+ */
+chrome.bookmarkManagerPrivate.getRedoInfo = function(callback) {};
+
+/** @type {!ChromeEvent} */
+chrome.bookmarkManagerPrivate.onDragEnter;
+
+/** @type {!ChromeEvent} */
+chrome.bookmarkManagerPrivate.onDragLeave;
+
+/** @type {!ChromeEvent} */
+chrome.bookmarkManagerPrivate.onDrop;
+
+/** @type {!ChromeEvent} */
+chrome.bookmarkManagerPrivate.onMetaInfoChanged;
diff --git a/third_party/closure_compiler/externs/metrics_private.js b/third_party/closure_compiler/externs/metrics_private.js
new file mode 100644
index 0000000..b2c9ef85
--- /dev/null
+++ b/third_party/closure_compiler/externs/metrics_private.js
@@ -0,0 +1,117 @@
+// Copyright 2014 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 Externs generated from namespace: metricsPrivate */
+
+/**
+ * Describes the type of metric that is to be collected.
+ * @typedef {{
+ * metricName: string,
+ * type: string,
+ * min: number,
+ * max: number,
+ * buckets: number
+ * }}
+ */
+var MetricType;
+
+/**
+ * @const
+ */
+chrome.metricsPrivate = {};
+
+/**
+ * Returns true if the user opted in to sending crash reports.
+ * @param {Function} callback
+ */
+chrome.metricsPrivate.getIsCrashReportingEnabled = function(callback) {};
+
+/**
+ * Returns the group name chosen for the named trial, or the empty string if
+ * the trial does not exist or is not enabled.
+ * @param {string} name
+ * @param {Function} callback
+ */
+chrome.metricsPrivate.getFieldTrial = function(name, callback) {};
+
+/**
+ * Returns variation parameters for the named trial if available, or undefined
+ * otherwise.
+ * @param {string} name
+ * @param {Function} callback
+ */
+chrome.metricsPrivate.getVariationParams = function(name, callback) {};
+
+/**
+ * Records an action performed by the user.
+ * @param {string} name
+ */
+chrome.metricsPrivate.recordUserAction = function(name) {};
+
+/**
+ * Records a percentage value from 1 to 100.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordPercentage = function(metricName, value) {};
+
+/**
+ * Records a value than can range from 1 to 1,000,000.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordCount = function(metricName, value) {};
+
+/**
+ * Records a value than can range from 1 to 100.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordSmallCount = function(metricName, value) {};
+
+/**
+ * Records a value than can range from 1 to 10,000.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordMediumCount = function(metricName, value) {};
+
+/**
+ * Records an elapsed time of no more than 10 seconds. The sample value is
+ * specified in milliseconds.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordTime = function(metricName, value) {};
+
+/**
+ * Records an elapsed time of no more than 3 minutes. The sample value is
+ * specified in milliseconds.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordMediumTime = function(metricName, value) {};
+
+/**
+ * Records an elapsed time of no more than 1 hour. The sample value is
+ * specified in milliseconds.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordLongTime = function(metricName, value) {};
+
+/**
+ * Increments the count associated with |value| in the sparse histogram defined
+ * by the |metricName|.
+ * @param {string} metricName
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordSparseValue = function(metricName, value) {};
+
+/**
+ * Adds a value to the given metric.
+ * @param {MetricType} metric
+ * @param {number} value
+ */
+chrome.metricsPrivate.recordValue = function(metric, value) {};
diff --git a/third_party/closure_compiler/externs/system_private.js b/third_party/closure_compiler/externs/system_private.js
new file mode 100644
index 0000000..0ea2476
--- /dev/null
+++ b/third_party/closure_compiler/externs/system_private.js
@@ -0,0 +1,69 @@
+// Copyright 2014 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 Externs generated from namespace: systemPrivate */
+
+/**
+ * Information about the system update.
+ * @typedef {{
+ * state: string,
+ * downloadProgress: number
+ * }}
+ */
+var UpdateStatus;
+
+/**
+ * Information about the volume.
+ * @typedef {{
+ * volume: number,
+ * isVolumeMuted: boolean
+ * }}
+ */
+var VolumeInfo;
+
+/**
+ * Information about a change to the screen brightness.
+ * @typedef {{
+ * brightness: number,
+ * userInitiated: boolean
+ * }}
+ */
+var BrightnessChangeInfo;
+
+/**
+ * @const
+ */
+chrome.systemPrivate = {};
+
+/**
+ * Returns whether the incognito mode is enabled, disabled or forced
+ * @param {Function} callback Called with the result.
+ */
+chrome.systemPrivate.getIncognitoModeAvailability = function(callback) {};
+
+/**
+ * Gets information about the system update.
+ * @param {Function} callback
+ */
+chrome.systemPrivate.getUpdateStatus = function(callback) {};
+
+/**
+ * Gets Chrome's API key to use for requests to Google services.
+ * @param {Function} callback
+ */
+chrome.systemPrivate.getApiKey = function(callback) {};
+
+/** @type {!ChromeEvent} */
+chrome.systemPrivate.onVolumeChanged;
+
+/** @type {!ChromeEvent} */
+chrome.systemPrivate.onBrightnessChanged;
+
+/** @type {!ChromeEvent} */
+chrome.systemPrivate.onScreenUnlocked;
+
+/** @type {!ChromeEvent} */
+chrome.systemPrivate.onWokeUp;
+
+
diff --git a/third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java b/third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java
index d897823..274f0f8 100644
--- a/third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java
+++ b/third_party/closure_compiler/runner/src/com/google/javascript/jscomp/ChromePass.java
@@ -313,11 +313,11 @@ public class ChromePass extends AbstractPostOrderCallback implements CompilerPas
for (Node keyNode : objectLit.children()) {
String key = keyNode.getString();
- // TODO(vitalyp): Can dict value be other than a simple NAME? What if NAME doesn't
- // refer to a function/constructor?
- String value = keyNode.getFirstChild().getString();
-
- res.put(value, key);
+ Node valueNode = keyNode.getFirstChild();
+ if (valueNode.isName()) {
+ String value = keyNode.getFirstChild().getString();
+ res.put(value, key);
+ }
}
return res;
diff --git a/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java b/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
index d6264c1..830b9ba 100644
--- a/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
+++ b/third_party/closure_compiler/runner/test/com/google/javascript/jscomp/ChromePassTest.java
@@ -192,6 +192,36 @@ public class ChromePassTest extends CompilerTestCase {
"});\n");
}
+ public void testCrDefineDoesNothingWithExportedNotAName() throws Exception {
+ test(
+ "cr.define('namespace', function() {\n" +
+ " return {\n" +
+ " a: 42\n" +
+ " };\n" +
+ "});\n",
+ "var namespace = namespace || {};\n" +
+ "cr.define('namespace', function() {\n" +
+ " return {\n" +
+ " a: 42\n" +
+ " };\n" +
+ "});\n");
+ }
+
+ public void testCrDefineDoesNothingWithExportedNotAName() throws Exception {
+ test(
+ "cr.define('namespace', function() {\n" +
+ " return {\n" +
+ " a: 42\n" +
+ " };\n" +
+ "});\n",
+ "var namespace = namespace || {};\n" +
+ "cr.define('namespace', function() {\n" +
+ " return {\n" +
+ " a: 42\n" +
+ " };\n" +
+ "});\n");
+ }
+
public void testCrDefineChangesReferenceToExportedFunction() throws Exception {
test(
"cr.define('namespace', function() {\n" +