Update Closure compiler to v20190729
The new compiler caught a lot of pre-existing issues in the codebase.
Sadly, the old compiler version was not smart enough to understand the
new changes. Therefore, the changes have be included in the same CL as
the compiler update.
Most of the changes are related to better handling of prototype and
class inheritance, as well as handling of null/undefined tracking.
Change-Id: I3941a3a240a4d09c4945e1e20d2521090ef837c9
Bug: 991710
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1762081
Reviewed-by: Yang Guo <[email protected]>
Commit-Queue: Tim van der Lippe <[email protected]>
Auto-Submit: Tim van der Lippe <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#696761}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ca93474213278e32e36d6ace1474c56884030757
diff --git a/front_end/audits/AuditsProtocolService.js b/front_end/audits/AuditsProtocolService.js
index 67f7f9e..f2e677f 100644
--- a/front_end/audits/AuditsProtocolService.js
+++ b/front_end/audits/AuditsProtocolService.js
@@ -54,7 +54,7 @@
}
/**
- * @param {!Object} message
+ * @param {(!Object|string)} message
*/
_dispatchProtocolMessage(message) {
this._send('dispatchProtocolMessage', {message: JSON.stringify(message)});
diff --git a/front_end/bindings/CompilerScriptMapping.js b/front_end/bindings/CompilerScriptMapping.js
index 44c4d83..d74e9e1 100644
--- a/front_end/bindings/CompilerScriptMapping.js
+++ b/front_end/bindings/CompilerScriptMapping.js
@@ -274,7 +274,6 @@
}
/**
- * @override
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @return {boolean}
diff --git a/front_end/bindings/FileUtils.js b/front_end/bindings/FileUtils.js
index 2128eca..d3023d8 100644
--- a/front_end/bindings/FileUtils.js
+++ b/front_end/bindings/FileUtils.js
@@ -215,7 +215,7 @@
/**
* @override
*/
- close() {
+ async close() {
this._closed = true;
if (this._writeCallbacks.length)
return;
diff --git a/front_end/bindings/ResourceMapping.js b/front_end/bindings/ResourceMapping.js
index c26e274..e3c7e75 100644
--- a/front_end/bindings/ResourceMapping.js
+++ b/front_end/bindings/ResourceMapping.js
@@ -389,7 +389,7 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {
return this._resources.firstValue().requestContent();
diff --git a/front_end/bindings/StylesSourceMapping.js b/front_end/bindings/StylesSourceMapping.js
index 1b8877a..a6cca5b 100644
--- a/front_end/bindings/StylesSourceMapping.js
+++ b/front_end/bindings/StylesSourceMapping.js
@@ -325,7 +325,7 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {
return this._headers.firstValue().originalContentProvider().requestContent();
diff --git a/front_end/bindings/TempFile.js b/front_end/bindings/TempFile.js
index 9d74521..f6cba35 100644
--- a/front_end/bindings/TempFile.js
+++ b/front_end/bindings/TempFile.js
@@ -82,7 +82,7 @@
Common.console.error('Failed to read from temp file: ' + error.message);
}
- return reader.result;
+ return /** @type {?string} */ (reader.result);
}
/**
diff --git a/front_end/common/ContentProvider.js b/front_end/common/ContentProvider.js
index b5fdf23..349adfe 100644
--- a/front_end/common/ContentProvider.js
+++ b/front_end/common/ContentProvider.js
@@ -49,7 +49,7 @@
contentEncoded() {},
/**
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {},
diff --git a/front_end/common/ModuleExtensionInterfaces.js b/front_end/common/ModuleExtensionInterfaces.js
index ce14692..5120202 100644
--- a/front_end/common/ModuleExtensionInterfaces.js
+++ b/front_end/common/ModuleExtensionInterfaces.js
@@ -91,6 +91,9 @@
Common.Runnable = function() {};
Common.Runnable.prototype = {
+ /**
+ * @return {!Promise}
+ */
run() {}
};
diff --git a/front_end/common/Object.js b/front_end/common/Object.js
index 2156cf6..9f5e522 100644
--- a/front_end/common/Object.js
+++ b/front_end/common/Object.js
@@ -29,13 +29,13 @@
*/
Common.Object = class {
constructor() {
- /** @type {(!Map<symbol, !Array<!Common.Object._listenerCallbackTuple>>|undefined)} */
+ /** @type {(!Map<string|symbol, !Array<!Common.Object._listenerCallbackTuple>>|undefined)} */
this._listeners;
}
/**
* @override
- * @param {symbol} eventType
+ * @param {string|symbol} eventType
* @param {function(!Common.Event)} listener
* @param {!Object=} thisObject
* @return {!Common.EventTarget.EventDescriptor}
@@ -69,7 +69,7 @@
/**
* @override
- * @param {symbol} eventType
+ * @param {string|symbol} eventType
* @param {function(!Common.Event)} listener
* @param {!Object=} thisObject
*/
@@ -92,7 +92,7 @@
/**
* @override
- * @param {symbol} eventType
+ * @param {string|symbol} eventType
* @return {boolean}
*/
hasEventListeners(eventType) {
@@ -101,7 +101,7 @@
/**
* @override
- * @param {symbol} eventType
+ * @param {string|symbol} eventType
* @param {*=} eventData
*/
dispatchEventToListeners(eventType, eventData) {
@@ -133,7 +133,7 @@
Common.EventTarget = function() {};
/**
- * @typedef {!{eventTarget: !Common.EventTarget, eventType: symbol, thisObject: (!Object|undefined), listener: function(!Common.Event)}}
+ * @typedef {!{eventTarget: !Common.EventTarget, eventType: (string|symbol), thisObject: (!Object|undefined), listener: function(!Common.Event)}}
*/
Common.EventTarget.EventDescriptor;
@@ -163,7 +163,7 @@
once(eventType) {},
/**
- * @param {symbol} eventType
+ * @param {string|symbol} eventType
* @param {function(!Common.Event)} listener
* @param {!Object=} thisObject
*/
diff --git a/front_end/common/OutputStream.js b/front_end/common/OutputStream.js
index a4fa83b..1e72025 100644
--- a/front_end/common/OutputStream.js
+++ b/front_end/common/OutputStream.js
@@ -14,6 +14,9 @@
*/
write(data) {},
+ /**
+ * @return {!Promise}
+ */
close() {}
};
diff --git a/front_end/common/ParsedURL.js b/front_end/common/ParsedURL.js
index eea78c5..9bdc469 100644
--- a/front_end/common/ParsedURL.js
+++ b/front_end/common/ParsedURL.js
@@ -329,7 +329,7 @@
return this._dataURLDisplayName;
if (!this.isDataURL())
return '';
- this._dataURLDisplayName = this.url.trimEnd(20);
+ this._dataURLDisplayName = this.url.trimEndWithMaxLength(20);
return this._dataURLDisplayName;
}
diff --git a/front_end/common/StaticContentProvider.js b/front_end/common/StaticContentProvider.js
index f871b5b..96fd157 100644
--- a/front_end/common/StaticContentProvider.js
+++ b/front_end/common/StaticContentProvider.js
@@ -9,7 +9,7 @@
/**
* @param {string} contentURL
* @param {!Common.ResourceType} contentType
- * @param {function():!Promise<?string>} lazyContent
+ * @param {function():!Promise<string>} lazyContent
*/
constructor(contentURL, contentType, lazyContent) {
this._contentURL = contentURL;
@@ -54,7 +54,7 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {
return this._lazyContent();
diff --git a/front_end/console/ConsoleContextSelector.js b/front_end/console/ConsoleContextSelector.js
index 8252942..d21cf5a 100644
--- a/front_end/console/ConsoleContextSelector.js
+++ b/front_end/console/ConsoleContextSelector.js
@@ -248,7 +248,7 @@
const element = createElementWithClass('div');
const shadowRoot = UI.createShadowRootWithCoreStyles(element, 'console/consoleContextSelector.css');
const title = shadowRoot.createChild('div', 'title');
- title.createTextChild(this.titleFor(item).trimEnd(100));
+ title.createTextChild(this.titleFor(item).trimEndWithMaxLength(100));
const subTitle = shadowRoot.createChild('div', 'subtitle');
const badgeElement = this._badgeFor(item);
if (badgeElement) {
diff --git a/front_end/console/ConsolePinPane.js b/front_end/console/ConsolePinPane.js
index 7367b02..0db3def 100644
--- a/front_end/console/ConsolePinPane.js
+++ b/front_end/console/ConsolePinPane.js
@@ -259,7 +259,7 @@
this._lastNode = node || null;
const isError = result && result.exceptionDetails && !SDK.RuntimeModel.isSideEffectFailure(result);
- this._pinElement.classList.toggle('error-level', isError);
+ this._pinElement.classList.toggle('error-level', !!isError);
}
};
diff --git a/front_end/console/ConsoleViewMessage.js b/front_end/console/ConsoleViewMessage.js
index bc60825..a6e2c49 100644
--- a/front_end/console/ConsoleViewMessage.js
+++ b/front_end/console/ConsoleViewMessage.js
@@ -798,7 +798,7 @@
if (type === 'string' || subtype === 'regexp')
description = object.description.trimMiddle(maxLength);
else
- description = object.description.trimEnd(maxLength);
+ description = object.description.trimEndWithMaxLength(maxLength);
}
rootElement.appendChild(this._previewFormatter.renderPropertyPreview(type, subtype, description));
}
diff --git a/front_end/cookie_table/CookiesTable.js b/front_end/cookie_table/CookiesTable.js
index 298d756..35ac3d9 100644
--- a/front_end/cookie_table/CookiesTable.js
+++ b/front_end/cookie_table/CookiesTable.js
@@ -546,7 +546,7 @@
if (this._blockedReasons) {
for (const blockedReason of this._blockedReasons) {
const attributeMatches = blockedReason.attribute === /** @type {!SDK.Cookie.Attributes} */ (columnId);
- const useNameColumn = !blockedReason.attribute && columnId === SDK.Cookie.Attribute.Name;
+ const useNameColumn = !blockedReason.attribute && columnId === SDK.Cookie.Attributes.Name;
if (attributeMatches || useNameColumn) {
if (blockedReasonString)
blockedReasonString += '\n';
diff --git a/front_end/coverage/CoverageModel.js b/front_end/coverage/CoverageModel.js
index 5f02ea2..b0cb4c0 100644
--- a/front_end/coverage/CoverageModel.js
+++ b/front_end/coverage/CoverageModel.js
@@ -151,8 +151,9 @@
for (const range of func.ranges)
ranges.push(range);
}
- const subentry =
- this._addCoverage(script, script.contentLength, script.lineOffset, script.columnOffset, ranges, type);
+ const subentry = this._addCoverage(
+ script, script.contentLength, script.lineOffset, script.columnOffset, ranges,
+ /** @type {!Coverage.CoverageType} */ (type));
if (subentry)
updatedEntries.push(subentry);
}
diff --git a/front_end/data_grid/DataGrid.js b/front_end/data_grid/DataGrid.js
index 33af6eb..f0dbc4b 100644
--- a/front_end/data_grid/DataGrid.js
+++ b/front_end/data_grid/DataGrid.js
@@ -131,7 +131,7 @@
*/
static setElementText(element, newText, longText) {
if (longText && newText.length > 1000) {
- element.textContent = newText.trimEnd(1000);
+ element.textContent = newText.trimEndWithMaxLength(1000);
element.title = newText;
element[DataGrid.DataGrid._longTextSymbol] = newText;
} else {
@@ -1290,7 +1290,7 @@
super();
/** @type {?Element} */
this._element = null;
- /** @type {boolean} */
+ /** @protected @type {boolean} @suppress {accessControls} */
this._expanded = false;
/** @type {boolean} */
this._selected = false;
@@ -2095,4 +2095,4 @@
this.element.removeChild(dataGrid.element);
this._dataGrids = [];
}
-};
+};
\ No newline at end of file
diff --git a/front_end/data_grid/ViewportDataGrid.js b/front_end/data_grid/ViewportDataGrid.js
index 90a0ed1..d60f61f 100644
--- a/front_end/data_grid/ViewportDataGrid.js
+++ b/front_end/data_grid/ViewportDataGrid.js
@@ -17,10 +17,13 @@
super(columnsArray, editCallback, deleteCallback, refreshCallback);
this._onScrollBound = this._onScroll.bind(this);
- this._scrollContainer.addEventListener('scroll', this._onScrollBound, true);
+ this.scrollContainer.addEventListener('scroll', this._onScrollBound, true);
/** @type {!Array.<!DataGrid.ViewportDataGridNode>} */
this._visibleNodes = [];
+ /**
+ * @type {boolean}
+ */
this._inline = false;
this._stickToBottom = false;
@@ -58,9 +61,12 @@
* @param {!Element} scrollContainer
*/
setScrollContainer(scrollContainer) {
- this._scrollContainer.removeEventListener('scroll', this._onScrollBound, true);
+ this.scrollContainer.removeEventListener('scroll', this._onScrollBound, true);
+ /**
+ * @suppress {accessControls}
+ */
this._scrollContainer = scrollContainer;
- this._scrollContainer.addEventListener('scroll', this._onScrollBound, true);
+ this.scrollContainer.addEventListener('scroll', this._onScrollBound, true);
}
/**
@@ -68,7 +74,7 @@
*/
onResize() {
if (this._stickToBottom)
- this._scrollContainer.scrollTop = this._scrollContainer.scrollHeight - this._scrollContainer.clientHeight;
+ this.scrollContainer.scrollTop = this.scrollContainer.scrollHeight - this.scrollContainer.clientHeight;
this.scheduleUpdate();
super.onResize();
}
@@ -84,8 +90,8 @@
* @param {?Event} event
*/
_onScroll(event) {
- this._stickToBottom = this._scrollContainer.isScrolledToBottom();
- if (this._lastScrollTop !== this._scrollContainer.scrollTop)
+ this._stickToBottom = this.scrollContainer.isScrolledToBottom();
+ if (this._lastScrollTop !== this.scrollContainer.scrollTop)
this.scheduleUpdate(true);
}
@@ -101,7 +107,7 @@
*/
scheduleUpdate(isFromUser) {
if (this._stickToBottom && isFromUser)
- this._stickToBottom = this._scrollContainer.isScrolledToBottom();
+ this._stickToBottom = this.scrollContainer.isScrolledToBottom();
this._updateIsFromUser = this._updateIsFromUser || isFromUser;
if (this._updateAnimationFrameId)
return;
@@ -177,8 +183,8 @@
delete this._updateAnimationFrameId;
}
- const clientHeight = this._scrollContainer.clientHeight;
- let scrollTop = this._scrollContainer.scrollTop;
+ const clientHeight = this.scrollContainer.clientHeight;
+ let scrollTop = this.scrollContainer.scrollTop;
const currentScrollTop = scrollTop;
const maxScrollTop = Math.max(0, this._contentHeight() - clientHeight);
if (!this._updateIsFromUser && this._stickToBottom)
@@ -225,7 +231,7 @@
this.setVerticalPadding(viewportState.topPadding, viewportState.bottomPadding);
this._lastScrollTop = scrollTop;
if (scrollTop !== currentScrollTop)
- this._scrollContainer.scrollTop = scrollTop;
+ this.scrollContainer.scrollTop = scrollTop;
const contentFits =
viewportState.contentHeight <= clientHeight && viewportState.topPadding + viewportState.bottomPadding === 0;
if (contentFits !== this.element.classList.contains('data-grid-fits-viewport')) {
@@ -249,17 +255,20 @@
fromY += nodes[i].nodeSelfHeight();
const toY = fromY + node.nodeSelfHeight();
- let scrollTop = this._scrollContainer.scrollTop;
+ let scrollTop = this.scrollContainer.scrollTop;
if (scrollTop > fromY) {
scrollTop = fromY;
this._stickToBottom = false;
- } else if (scrollTop + this._scrollContainer.offsetHeight < toY) {
- scrollTop = toY - this._scrollContainer.offsetHeight;
+ } else if (scrollTop + this.scrollContainer.offsetHeight < toY) {
+ scrollTop = toY - this.scrollContainer.offsetHeight;
}
- this._scrollContainer.scrollTop = scrollTop;
+ this.scrollContainer.scrollTop = scrollTop;
}
};
+/**
+ * @override @suppress {checkPrototypalTypes} @enum {symbol}
+ */
DataGrid.ViewportDataGrid.Events = {
ViewportCalculated: Symbol('ViewportCalculated')
};
@@ -342,7 +351,7 @@
}
const node = children[depth][counters[depth]++];
flatNodes.push(node);
- if (node._expanded && node.children.length) {
+ if (node.expanded && node.children.length) {
depth++;
children[depth] = node.children;
counters[depth] = 0;
@@ -376,7 +385,7 @@
this.setHasChildren(true);
this.children.splice(index, 0, child);
child.recalculateSiblings(index);
- if (this._expanded)
+ if (this.expanded)
this.dataGrid.scheduleUpdateStructure();
}
@@ -400,7 +409,7 @@
if (!this.children.length)
this.setHasChildren(false);
- if (this._expanded)
+ if (this.expanded)
this.dataGrid.scheduleUpdateStructure();
}
@@ -415,7 +424,7 @@
this.children[i]._unlink();
this.children = [];
- if (this._expanded)
+ if (this.expanded)
this.dataGrid.scheduleUpdateStructure();
}
@@ -429,9 +438,12 @@
* @override
*/
collapse() {
- if (!this._expanded)
+ if (!this.expanded)
return;
this.clearFlatNodes();
+ /**
+ * @suppress {accessControls}
+ */
this._expanded = false;
if (this.existingElement())
this.existingElement().classList.remove('expanded');
@@ -442,7 +454,7 @@
* @override
*/
expand() {
- if (this._expanded)
+ if (this.expanded)
return;
this.dataGrid._stickToBottom = false;
this.clearFlatNodes();
diff --git a/front_end/devtools_compatibility.js b/front_end/devtools_compatibility.js
index ff6cc6d..434e860 100644
--- a/front_end/devtools_compatibility.js
+++ b/front_end/devtools_compatibility.js
@@ -1256,14 +1256,6 @@
}
});
- // Document.prototype.createElementWithClass is a DevTools method, so we
- // need to wait for DOMContentLoaded in order to override it.
- if (window.document.head &&
- (window.document.readyState === 'complete' || window.document.readyState === 'interactive'))
- overrideCreateElementWithClass();
- else
- window.addEventListener('DOMContentLoaded', overrideCreateElementWithClass);
-
function overrideCreateElementWithClass() {
window.removeEventListener('DOMContentLoaded', overrideCreateElementWithClass);
@@ -1277,10 +1269,18 @@
return element;
};
}
+
+ // Document.prototype.createElementWithClass is a DevTools method, so we
+ // need to wait for DOMContentLoaded in order to override it.
+ if (window.document.head &&
+ (window.document.readyState === 'complete' || window.document.readyState === 'interactive'))
+ overrideCreateElementWithClass();
+ else
+ window.addEventListener('DOMContentLoaded', overrideCreateElementWithClass);
}
// Custom Elements V0 polyfill
- if (majorVersion <= 73 && !Document.prototype.registerElement) {
+ if (majorVersion <= 73 && !Document.prototype.hasOwnProperty('registerElement')) {
const fakeRegistry = new Map();
Document.prototype.registerElement = function(typeExtension, options) {
const {prototype, extends: localName} = options;
diff --git a/front_end/elements/ComputedStyleWidget.js b/front_end/elements/ComputedStyleWidget.js
index 43d8b22..b0cd17b 100644
--- a/front_end/elements/ComputedStyleWidget.js
+++ b/front_end/elements/ComputedStyleWidget.js
@@ -359,7 +359,7 @@
child.hidden = !matched;
hasMatch |= matched;
}
- this._noMatchesElement.classList.toggle('hidden', hasMatch);
+ this._noMatchesElement.classList.toggle('hidden', !!hasMatch);
}
};
diff --git a/front_end/elements/ElementsTreeElement.js b/front_end/elements/ElementsTreeElement.js
index 7cb3077..2f51fb3 100644
--- a/front_end/elements/ElementsTreeElement.js
+++ b/front_end/elements/ElementsTreeElement.js
@@ -511,7 +511,7 @@
// Place it here so that all "Copy"-ing items stick together.
const copyMenu = contextMenu.clipboardSection().appendSubMenuItem(Common.UIString('Copy'));
- const createShortcut = UI.KeyboardShortcut.shortcutToString;
+ const createShortcut = UI.KeyboardShortcut.shortcutToString.bind(null);
const modifier = UI.KeyboardShortcut.Modifiers.CtrlOrMeta;
const treeOutline = this.treeOutline;
let menuItem;
diff --git a/front_end/elements/ElementsTreeOutline.js b/front_end/elements/ElementsTreeOutline.js
index 9380824..113e957 100644
--- a/front_end/elements/ElementsTreeOutline.js
+++ b/front_end/elements/ElementsTreeOutline.js
@@ -1445,7 +1445,7 @@
/** @typedef {{node: !SDK.DOMNode, isCut: boolean}} */
Elements.ElementsTreeOutline.ClipboardData;
-/** @enum {symbol} */
+/** @override @suppress {checkPrototypalTypes} @enum {symbol} */
Elements.ElementsTreeOutline.Events = {
SelectedNodeChanged: Symbol('SelectedNodeChanged'),
ElementsTreeUpdated: Symbol('ElementsTreeUpdated')
diff --git a/front_end/elements/StylesSidebarPane.js b/front_end/elements/StylesSidebarPane.js
index ff86ecb..7ddc0a9 100644
--- a/front_end/elements/StylesSidebarPane.js
+++ b/front_end/elements/StylesSidebarPane.js
@@ -634,7 +634,7 @@
let hasAnyVisibleBlock = false;
for (const block of this._sectionBlocks)
hasAnyVisibleBlock |= block.updateFilter();
- this._noMatchesElement.classList.toggle('hidden', hasAnyVisibleBlock);
+ this._noMatchesElement.classList.toggle('hidden', !!hasAnyVisibleBlock);
}
/**
@@ -806,7 +806,7 @@
hasAnyVisibleSection |= section._updateFilter();
if (this._titleElement)
this._titleElement.classList.toggle('hidden', !hasAnyVisibleSection);
- return hasAnyVisibleSection;
+ return !!hasAnyVisibleSection;
}
/**
diff --git a/front_end/emulation/DeviceModeWrapper.js b/front_end/emulation/DeviceModeWrapper.js
index 742d0e1..dc0b3e7 100644
--- a/front_end/emulation/DeviceModeWrapper.js
+++ b/front_end/emulation/DeviceModeWrapper.js
@@ -117,7 +117,8 @@
scale: 1
});
});
- const clip = /** @type {!Protocol.Page.Viewport} */ (JSON.parse(result.object.value));
+ const clip =
+ /** @type {!Protocol.Page.Viewport} */ (JSON.parse(/** @type {string} */ (result.object.value)));
const response = await node.domModel().target().pageAgent().invoke_getLayoutMetrics({});
const page_zoom = !response[Protocol.Error] && response.visualViewport.zoom || 1;
clip.x *= page_zoom;
diff --git a/front_end/event_listeners/EventListenersUtils.js b/front_end/event_listeners/EventListenersUtils.js
index b74ba91..1c43ba0 100644
--- a/front_end/event_listeners/EventListenersUtils.js
+++ b/front_end/event_listeners/EventListenersUtils.js
@@ -189,7 +189,7 @@
function convertToInternalHandlers(pageInternalHandlersObject) {
return SDK.RemoteArray.objectAsArray(pageInternalHandlersObject)
.map(toTargetFunction)
- .then(SDK.RemoteArray.createFromRemoteObjects);
+ .then(SDK.RemoteArray.createFromRemoteObjects.bind(null));
}
/**
diff --git a/front_end/extensions/ExtensionAPI.js b/front_end/extensions/ExtensionAPI.js
index 0d3b2ad..367c428 100644
--- a/front_end/extensions/ExtensionAPI.js
+++ b/front_end/extensions/ExtensionAPI.js
@@ -240,7 +240,7 @@
return panels[name];
}
for (const panel in panels)
- this.__defineGetter__(panel, panelGetter.bind(null, panel));
+ Object.defineProperty(this, panel, {get: panelGetter.bind(null, panel), enumerable: true});
this.applyStyleSheet = function(styleSheet) {
extensionServer.sendRequest({command: commands.ApplyStyleSheet, styleSheet: styleSheet});
};
@@ -361,31 +361,27 @@
const EventSink = declareInterfaceClass(EventSinkImpl);
const ExtensionPanel = declareInterfaceClass(ExtensionPanelImpl);
const ExtensionSidebarPane = declareInterfaceClass(ExtensionSidebarPaneImpl);
- const PanelWithSidebar = declareInterfaceClass(PanelWithSidebarImpl);
+ /**
+ * @constructor
+ * @param {string} hostPanelName
+ */
+ const PanelWithSidebarClass = declareInterfaceClass(PanelWithSidebarImpl);
const Request = declareInterfaceClass(RequestImpl);
const Resource = declareInterfaceClass(ResourceImpl);
const TraceSession = declareInterfaceClass(TraceSessionImpl);
- /**
- * @constructor
- * @extends {PanelWithSidebar}
- */
- function ElementsPanel() {
- PanelWithSidebar.call(this, 'elements');
+ class ElementsPanel extends PanelWithSidebarClass {
+ constructor() {
+ super('elements');
+ }
}
- ElementsPanel.prototype = {__proto__: PanelWithSidebar.prototype};
-
- /**
- * @constructor
- * @extends {PanelWithSidebar}
- */
- function SourcesPanel() {
- PanelWithSidebar.call(this, 'sources');
+ class SourcesPanel extends PanelWithSidebarClass {
+ constructor() {
+ super('sources');
+ }
}
- SourcesPanel.prototype = {__proto__: PanelWithSidebar.prototype};
-
/**
* @constructor
* @extends {ExtensionViewImpl}
@@ -779,7 +775,7 @@
// Only expose tabId on chrome.devtools.inspectedWindow, not webInspector.inspectedWindow.
chrome.devtools.inspectedWindow = {};
- chrome.devtools.inspectedWindow.__defineGetter__('tabId', getTabId);
+ Object.defineProperty(chrome.devtools.inspectedWindow, 'tabId', {get: getTabId});
chrome.devtools.inspectedWindow.__proto__ = coreAPI.inspectedWindow;
chrome.devtools.network = coreAPI.network;
chrome.devtools.panels = coreAPI.panels;
diff --git a/front_end/extensions/ExtensionServer.js b/front_end/extensions/ExtensionServer.js
index 290f125..5953633 100644
--- a/front_end/extensions/ExtensionServer.js
+++ b/front_end/extensions/ExtensionServer.js
@@ -737,7 +737,7 @@
/**
* @param {string} eventTopic
* @param {!Object} eventTarget
- * @param {string} frontendEventType
+ * @param {symbol} frontendEventType
* @param {function(!Common.Event)} handler
*/
_registerAutosubscriptionHandler(eventTopic, eventTarget, frontendEventType, handler) {
@@ -749,7 +749,7 @@
/**
* @param {string} eventTopic
* @param {!Function} modelClass
- * @param {string} frontendEventType
+ * @param {symbol} frontendEventType
* @param {function(!Common.Event)} handler
*/
_registerAutosubscriptionTargetManagerHandler(eventTopic, modelClass, frontendEventType, handler) {
diff --git a/front_end/extensions/ExtensionView.js b/front_end/extensions/ExtensionView.js
index f1ec73e..48c5594 100644
--- a/front_end/extensions/ExtensionView.js
+++ b/front_end/extensions/ExtensionView.js
@@ -76,7 +76,7 @@
}
_onLoad() {
- const frames = /** @type {!Array.<!Window>} */ (window.frames);
+ const frames = window.frames;
this._frameIndex = Array.prototype.indexOf.call(frames, this._iframe.contentWindow);
if (this.isShowing())
this._server.notifyViewShown(this._id, this._frameIndex);
diff --git a/front_end/externs.js b/front_end/externs.js
index 3c8daa5..48017b8 100644
--- a/front_end/externs.js
+++ b/front_end/externs.js
@@ -653,56 +653,6 @@
/** @type {boolean} */
window.dispatchStandaloneTestRunnerMessages;
-/**
- * Inserts the given HTML Element into the node at the location.
- * @param {string} where Where to insert the HTML text, one of 'beforeBegin',
- * 'afterBegin', 'beforeEnd', 'afterEnd'.
- * @param {!Element} element DOM Element to insert.
- * @return {?Element} The element that was inserted, or null, if the
- * insertion failed.
- * @see https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
- */
-Node.prototype.insertAdjacentElement = function(where, element) {};
-
-/**
- * @param {Array.<Object>} keyframes
- * @param {number|Object} timing
- * @return {Object}
- */
-Element.prototype.animate = function(keyframes, timing) {};
-
-/**
- * @param {...!Node} nodes
- * @return {undefined}
- * @see https://dom.spec.whatwg.org/#dom-parentnode-append
- */
-Element.prototype.append = function(nodes) {};
-
-/**
- * @param {...!Node} nodes
- * @return {undefined}
- * @see https://dom.spec.whatwg.org/#dom-parentnode-prepend
- */
-Element.prototype.prepend = function(nodes) {};
-
-/**
- * @override
- * @param {string} type
- * @param {(!EventListener|!function (!Event): (boolean|undefined)|null)} listener
- * @param {(boolean|!{capture: (boolean|undefined), once: (boolean|undefined), passive: (boolean|undefined)})=} options
- * @this {EventTarget}
- */
-Element.prototype.addEventListener = function(type, listener, options) {};
-
-/**
- * @override
- * @param {string} type
- * @param {(!EventListener|!function (!Event): (boolean|undefined)|null)} listener
- * @param {(boolean|!{capture: (boolean|undefined), once: (boolean|undefined), passive: (boolean|undefined)})=} options
- * @this {EventTarget}
- */
-Element.prototype.removeEventListener = function(type, listener, options) {};
-
const acorn = {
/**
* @param {string} text
@@ -1141,7 +1091,8 @@
* @typedef {{
* lhr: !ReportRenderer.ReportJSON,
* artifacts: ReportRenderer.RunnerResultArtifacts,
- * report: string
+ * report: string,
+ * stack: string
* }}
*/
ReportRenderer.RunnerResult;
@@ -1197,20 +1148,6 @@
*/
DetailsRenderer.OpportunitySummary;
-
-// Clipboard API
-
-/** @constructor */
-const Clipboard = function() {};
-/**
- * @param {string} data
- * @return {!Promise}
- */
-Clipboard.prototype.writeText = function(data) {};
-
-/** @type {Clipboard} */
-Navigator.prototype.clipboard;
-
const Lighthouse = {};
Lighthouse.ReportGenerator = {};
diff --git a/front_end/help/Help.js b/front_end/help/Help.js
index dedbb7b..0153f10 100644
--- a/front_end/help/Help.js
+++ b/front_end/help/Help.js
@@ -59,7 +59,7 @@
/**
* @override
*/
- run() {
+ async run() {
if (!Host.isUnderTest())
Help._showReleaseNoteIfNeeded();
}
diff --git a/front_end/layer_viewer/Layers3DView.js b/front_end/layer_viewer/Layers3DView.js
index 3a56560..b6747f9 100644
--- a/front_end/layer_viewer/Layers3DView.js
+++ b/front_end/layer_viewer/Layers3DView.js
@@ -1180,7 +1180,7 @@
this._gl = glContext;
this.scale = scale;
const imageURL = await this.snapshot.replay(scale);
- const image = imageURL && await UI.loadImage(imageURL);
- this.texture = image && LayerViewer.LayerTextureManager._createTextureForImage(glContext, image);
+ const image = imageURL ? await UI.loadImage(imageURL) : null;
+ this.texture = image ? LayerViewer.LayerTextureManager._createTextureForImage(glContext, image) : null;
}
};
diff --git a/front_end/network/NetworkLogView.js b/front_end/network/NetworkLogView.js
index 485d8fd..287f391 100644
--- a/front_end/network/NetworkLogView.js
+++ b/front_end/network/NetworkLogView.js
@@ -1224,6 +1224,25 @@
const manager = SDK.multitargetNetworkManager;
let patterns = manager.blockedPatterns();
+ /**
+ * @param {string} url
+ */
+ function addBlockedURL(url) {
+ patterns.push({enabled: true, url: url});
+ manager.setBlockedPatterns(patterns);
+ manager.setBlockingEnabled(true);
+ UI.viewManager.showView('network.blocked-urls');
+ }
+
+ /**
+ * @param {string} url
+ */
+ function removeBlockedURL(url) {
+ patterns = patterns.filter(pattern => pattern.url !== url);
+ manager.setBlockedPatterns(patterns);
+ UI.viewManager.showView('network.blocked-urls');
+ }
+
const urlWithoutScheme = request.parsedURL.urlWithoutScheme();
if (urlWithoutScheme && !patterns.find(pattern => pattern.url === urlWithoutScheme)) {
contextMenu.debugSection().appendItem(
@@ -1248,25 +1267,6 @@
contextMenu.debugSection().appendItem(
Common.UIString('Replay XHR'), SDK.NetworkManager.replayRequest.bind(null, request));
}
-
- /**
- * @param {string} url
- */
- function addBlockedURL(url) {
- patterns.push({enabled: true, url: url});
- manager.setBlockedPatterns(patterns);
- manager.setBlockingEnabled(true);
- UI.viewManager.showView('network.blocked-urls');
- }
-
- /**
- * @param {string} url
- */
- function removeBlockedURL(url) {
- patterns = patterns.filter(pattern => pattern.url !== url);
- manager.setBlockedPatterns(patterns);
- UI.viewManager.showView('network.blocked-urls');
- }
}
}
diff --git a/front_end/network/RequestPreviewView.js b/front_end/network/RequestPreviewView.js
index ae4dd41..d63c7f8 100644
--- a/front_end/network/RequestPreviewView.js
+++ b/front_end/network/RequestPreviewView.js
@@ -63,7 +63,8 @@
if (!whitelist.has(this.request.mimeType))
return null;
- const content = contentData.encoded ? window.atob(contentData.content) : contentData.content;
+ const content = contentData.encoded ? window.atob(/** @type {string} */ (contentData.content)) :
+ /** @type {string} */ (contentData.content);
// http://crbug.com/767393 - DevTools should recognize JSON regardless of the content type
const jsonView = await SourceFrame.JSONView.createView(content);
diff --git a/front_end/network/RequestResponseView.js b/front_end/network/RequestResponseView.js
index 56050b0..7160865 100644
--- a/front_end/network/RequestResponseView.js
+++ b/front_end/network/RequestResponseView.js
@@ -65,7 +65,7 @@
/**
* @protected
* @param {!SDK.NetworkRequest} request
- * @return {!Promise<?UI.SearchableView>}
+ * @return {!Promise<?UI.Widget>}
*/
static async sourceViewForRequest(request) {
let sourceView = request[Network.RequestResponseView._sourceViewSymbol];
diff --git a/front_end/object_ui/JavaScriptAutocomplete.js b/front_end/object_ui/JavaScriptAutocomplete.js
index 4707e5d..b5c644e 100644
--- a/front_end/object_ui/JavaScriptAutocomplete.js
+++ b/front_end/object_ui/JavaScriptAutocomplete.js
@@ -34,7 +34,7 @@
/**
* @param {string} fullText
- * @return {!Promise<?{args: !Array<!Array<string>>, argumentIndex: number}>}
+ * @return {!Promise<?{args: !Array<!Array<string>>, argumentIndex: number}|undefined>}
*/
async argumentsHint(fullText) {
const functionCall = await Formatter.formatterWorkerPool().findLastFunctionCall(fullText);
@@ -73,7 +73,7 @@
timeout: functionCall.possibleSideEffects ? 500 : undefined
},
/* userGesture */ false, /* awaitPromise */ false);
- return (result && !result.exceptionDetails) ? result.object : null;
+ return (result && !result.exceptionDetails && result.object) ? result.object : null;
}, functionCall.functionName);
executionContext.runtimeModel.releaseObjectGroup('argumentsHint');
if (!args.length || (args.length === 1 && !args[0].length))
@@ -157,7 +157,7 @@
result[result.length] = object.constructor.name;
}
return result;
- });
+ }, []);
}
for (const proto of protoNames) {
const instanceSignatures = javaScriptMetadata.signaturesForInstanceMethod(name, proto);
@@ -363,7 +363,7 @@
/* userGesture */ false,
/* awaitPromise */ false);
if (evaluateResult.object && !evaluateResult.exceptionDetails)
- completions = evaluateResult.object.value || [];
+ completions = /** @type {!Iterable} */ (evaluateResult.object.value) || [];
}
executionContext.runtimeModel.releaseObjectGroup('completion');
diff --git a/front_end/object_ui/JavaScriptREPL.js b/front_end/object_ui/JavaScriptREPL.js
index f0b73e6..60adc89 100644
--- a/front_end/object_ui/JavaScriptREPL.js
+++ b/front_end/object_ui/JavaScriptREPL.js
@@ -93,7 +93,7 @@
if (preview && type === 'object' && subtype !== 'node') {
formatter.appendObjectPreview(fragment, preview, false /* isEntry */);
} else {
- const nonObjectPreview = formatter.renderPropertyPreview(type, subtype, description.trimEnd(400));
+ const nonObjectPreview = formatter.renderPropertyPreview(type, subtype, description.trimEndWithMaxLength(400));
fragment.appendChild(nonObjectPreview);
}
return fragment;
diff --git a/front_end/object_ui/ObjectPopoverHelper.js b/front_end/object_ui/ObjectPopoverHelper.js
index 44b1ee9..29c68f1 100644
--- a/front_end/object_ui/ObjectPopoverHelper.js
+++ b/front_end/object_ui/ObjectPopoverHelper.js
@@ -51,7 +51,7 @@
* @return {!Promise<?ObjectUI.ObjectPopoverHelper>}
*/
static async buildObjectPopover(result, popover) {
- const description = result.description.trimEnd(ObjectUI.ObjectPopoverHelper.MaxPopoverTextLength);
+ const description = result.description.trimEndWithMaxLength(ObjectUI.ObjectPopoverHelper.MaxPopoverTextLength);
let popoverContentElement = null;
if (result.type === 'object') {
let linkifier = null;
@@ -115,7 +115,8 @@
let linkifier = null;
if (sourceURL) {
linkifier = new Components.Linkifier();
- linkContainer.appendChild(linkifier.linkifyRawLocation(rawLocation, sourceURL));
+ linkContainer.appendChild(
+ linkifier.linkifyRawLocation(/** @type {!SDK.DebuggerModel.Location} */ (rawLocation), sourceURL));
}
container.appendChild(popoverContentElement);
popover.contentElement.appendChild(container);
diff --git a/front_end/object_ui/ObjectPropertiesSection.js b/front_end/object_ui/ObjectPropertiesSection.js
index 1dbd573..6710b55 100644
--- a/front_end/object_ui/ObjectPropertiesSection.js
+++ b/front_end/object_ui/ObjectPropertiesSection.js
@@ -193,7 +193,7 @@
} else {
addElements('\u0192', text, nameAndArguments(text));
}
- valueElement.title = description.trimEnd(500);
+ valueElement.title = description.trimEndWithMaxLength(500);
return valueElement;
/**
@@ -221,7 +221,7 @@
if (prefix.length)
valueElement.createChild('span', 'object-value-function-prefix').textContent = prefix + ' ';
if (includePreview)
- valueElement.createTextChild(body.trim().trimEnd(maxFunctionBodyLength));
+ valueElement.createTextChild(body.trim().trimEndWithMaxLength(maxFunctionBodyLength));
else
valueElement.createTextChild(abbreviation.replace(/\n/g, ' '));
}
diff --git a/front_end/perf_ui/FilmStripView.js b/front_end/perf_ui/FilmStripView.js
index 3b120e7..182cd3b 100644
--- a/front_end/perf_ui/FilmStripView.js
+++ b/front_end/perf_ui/FilmStripView.js
@@ -161,7 +161,7 @@
}
/**
- * @param {string} eventName
+ * @param {string|symbol} eventName
* @param {number} timestamp
*/
_onMouseEvent(eventName, timestamp) {
diff --git a/front_end/persistence/FileSystemWorkspaceBinding.js b/front_end/persistence/FileSystemWorkspaceBinding.js
index bbf6ce7..a84c3f2 100644
--- a/front_end/persistence/FileSystemWorkspaceBinding.js
+++ b/front_end/persistence/FileSystemWorkspaceBinding.js
@@ -299,7 +299,7 @@
/**
* @override
* @param {!Workspace.UISourceCode} uiSourceCode
- * @param {function(?string, boolean)} callback
+ * @param {function(?string,boolean)} callback
*/
requestFileContent(uiSourceCode, callback) {
const filePath = this._filePathForUISourceCode(uiSourceCode);
diff --git a/front_end/persistence/IsolatedFileSystem.js b/front_end/persistence/IsolatedFileSystem.js
index 5756f74..0bd7181 100644
--- a/front_end/persistence/IsolatedFileSystem.js
+++ b/front_end/persistence/IsolatedFileSystem.js
@@ -357,7 +357,7 @@
}
let result;
try {
- result = reader.result;
+ result = /** @type {string} */ (reader.result);
} catch (e) {
result = null;
console.error('Can\'t read file: ' + path + ': ' + e);
diff --git a/front_end/platform/utilities.js b/front_end/platform/utilities.js
index 1ae145f..c94bb3d 100644
--- a/front_end/platform/utilities.js
+++ b/front_end/platform/utilities.js
@@ -218,7 +218,7 @@
* @param {number} maxLength
* @return {string}
*/
-String.prototype.trimEnd = function(maxLength) {
+String.prototype.trimEndWithMaxLength = function(maxLength) {
if (this.length <= maxLength)
return String(this);
return this.substr(0, maxLength - 1) + '\u2026';
diff --git a/front_end/profiler/CPUProfileView.js b/front_end/profiler/CPUProfileView.js
index 7c98db1..2df9fb9 100644
--- a/front_end/profiler/CPUProfileView.js
+++ b/front_end/profiler/CPUProfileView.js
@@ -113,6 +113,9 @@
return '.cpuprofile';
}
+ /**
+ * @override
+ */
get buttonTooltip() {
return this._recording ? Common.UIString('Stop CPU profiling') : Common.UIString('Start CPU profiling');
}
@@ -131,10 +134,16 @@
}
}
+ /**
+ * @override
+ */
get treeItemTitle() {
return Common.UIString('CPU PROFILES');
}
+ /**
+ * @override
+ */
get description() {
return Common.UIString('CPU profiles show where the execution time is spent in your page\'s JavaScript functions.');
}
diff --git a/front_end/profiler/HeapProfileView.js b/front_end/profiler/HeapProfileView.js
index 4d61477..3ea629a 100644
--- a/front_end/profiler/HeapProfileView.js
+++ b/front_end/profiler/HeapProfileView.js
@@ -248,6 +248,9 @@
return '.heapprofile';
}
+ /**
+ * @override
+ */
get buttonTooltip() {
return this._recording ? ls`Stop heap profiling` : ls`Start heap profiling`;
}
@@ -338,10 +341,16 @@
this._updateIntervalMs = 200;
}
+ /**
+ * @override
+ */
get treeItemTitle() {
return ls`SAMPLING PROFILES`;
}
+ /**
+ * @override
+ */
get description() {
return ls`Record memory allocations using sampling method.
This profile type has minimal performance overhead and can be used for long running operations.
@@ -387,7 +396,7 @@
Profiler.SamplingHeapProfileType.TypeId = 'SamplingHeap';
-/** @enum {symbol} */
+/** @override @suppress {checkPrototypalTypes} @enum {symbol} */
Profiler.SamplingHeapProfileType.Events = {
RecordingStopped: Symbol('RecordingStopped'),
StatsUpdate: Symbol('StatsUpdate')
@@ -402,10 +411,16 @@
Profiler.SamplingNativeHeapProfileType.instance = this;
}
+ /**
+ * @override
+ */
get treeItemTitle() {
return ls`NATIVE SAMPLING PROFILES`;
}
+ /**
+ * @override
+ */
get description() {
return ls`Allocation profiles show sampled native memory allocations from the renderer process.`;
}
@@ -447,10 +462,16 @@
return true;
}
+ /**
+ * @override
+ */
get treeItemTitle() {
return ls`NATIVE SNAPSHOTS`;
}
+ /**
+ * @override
+ */
get description() {
return ls`Native memory snapshots show sampled native allocations in the renderer process since start up.
Chrome has to be started with --memlog=all flag. Check flags at chrome://flags`;
@@ -485,7 +506,7 @@
const recordedProfile = this.profileBeingRecorded();
if (recordedProfile) {
console.assert(protocolProfile);
- recordedProfile.setProtocolProfile(protocolProfile);
+ recordedProfile.setProtocolProfile(/** @type {!Protocol.Profiler.Profile} */ (protocolProfile));
recordedProfile.updateStatus('');
this.setProfileBeingRecorded(null);
}
diff --git a/front_end/profiler/HeapSnapshotDataGrids.js b/front_end/profiler/HeapSnapshotDataGrids.js
index 51e47f2..fef1ec3 100644
--- a/front_end/profiler/HeapSnapshotDataGrids.js
+++ b/front_end/profiler/HeapSnapshotDataGrids.js
@@ -287,7 +287,7 @@
}
};
-/** @enum {symbol} */
+/** @override @suppress {checkPrototypalTypes} @enum {symbol} */
Profiler.HeapSnapshotSortableDataGrid.Events = {
ContentShown: Symbol('ContentShown'),
SortingComplete: Symbol('SortingComplete')
@@ -666,7 +666,7 @@
}
};
-/** @enum {symbol} */
+/** @override @suppress {checkPrototypalTypes} @enum {symbol} */
Profiler.HeapSnapshotRetainmentDataGrid.Events = {
ExpandRetainersComplete: Symbol('ExpandRetainersComplete')
};
diff --git a/front_end/profiler/HeapSnapshotView.js b/front_end/profiler/HeapSnapshotView.js
index 0945c50..5ca2aea 100644
--- a/front_end/profiler/HeapSnapshotView.js
+++ b/front_end/profiler/HeapSnapshotView.js
@@ -1043,6 +1043,9 @@
return '.heapsnapshot';
}
+ /**
+ * @override
+ */
get buttonTooltip() {
return Common.UIString('Take heap snapshot');
}
@@ -1065,10 +1068,16 @@
return false;
}
+ /**
+ * @override
+ */
get treeItemTitle() {
return Common.UIString('HEAP SNAPSHOTS');
}
+ /**
+ * @override
+ */
get description() {
return Common.UIString(
'Heap snapshot profiles show memory distribution among your page\'s JavaScript objects and related DOM nodes.');
@@ -1225,6 +1234,9 @@
return true;
}
+ /**
+ * @override
+ */
get buttonTooltip() {
return this._recording ? ls`Stop recording heap profile` : ls`Start recording heap profile`;
}
@@ -1322,10 +1334,16 @@
return '.heaptimeline';
}
+ /**
+ * @override
+ */
get treeItemTitle() {
return ls`ALLOCATION TIMELINES`;
}
+ /**
+ * @override
+ */
get description() {
return ls`
Allocation timelines show instrumented JavaScript memory allocations over time.
@@ -1357,6 +1375,9 @@
}
};
+/**
+ * @override
+ */
Profiler.TrackingHeapSnapshotProfileType.TypeId = 'HEAP-RECORD';
Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate = 'HeapStatsUpdate';
@@ -1590,7 +1611,7 @@
/**
* @override
* @param {!File} file
- * @return {!Promise<?Error>}
+ * @return {!Promise<?FileError>}
*/
async loadFromFile(file) {
this.updateStatus(Common.UIString('Loading\u2026'), true);
diff --git a/front_end/profiler/ProfileHeader.js b/front_end/profiler/ProfileHeader.js
index 8498fbe..a63cc2d 100644
--- a/front_end/profiler/ProfileHeader.js
+++ b/front_end/profiler/ProfileHeader.js
@@ -80,7 +80,7 @@
/**
* @param {!File} file
- * @return {!Promise<?Error>}
+ * @return {!Promise<?Error|?FileError>}
*/
loadFromFile(file) {
throw new Error('Not implemented');
diff --git a/front_end/profiler/ProfileType.js b/front_end/profiler/ProfileType.js
index 9bba187..6960d35 100644
--- a/front_end/profiler/ProfileType.js
+++ b/front_end/profiler/ProfileType.js
@@ -143,7 +143,7 @@
/**
* @param {!File} file
- * @return {!Promise<?Error>}
+ * @return {!Promise<?Error|?FileError>}
*/
loadFromFile(file) {
let name = file.name;
diff --git a/front_end/profiler/ProfilesPanel.js b/front_end/profiler/ProfilesPanel.js
index 17c999b..62ed453 100644
--- a/front_end/profiler/ProfilesPanel.js
+++ b/front_end/profiler/ProfilesPanel.js
@@ -597,10 +597,10 @@
this._iconElement = createElementWithClass('div', 'icon');
this._titlesElement = createElementWithClass('div', 'titles no-subtitle');
this._titleContainer = this._titlesElement.createChild('span', 'title-container');
- this._titleElement = this._titleContainer.createChild('span', 'title');
+ this.titleElement = this._titleContainer.createChild('span', 'title');
this._subtitleElement = this._titlesElement.createChild('span', 'subtitle');
- this._titleElement.textContent = profile.title;
+ this.titleElement.textContent = profile.title;
this._className = className;
this._small = false;
this._dataDisplayDelegate = dataDisplayDelegate;
@@ -738,7 +738,7 @@
* @param {string} title
*/
setMainTitle(title) {
- this._titleElement.textContent = title;
+ this.titleElement.textContent = title;
}
};
diff --git a/front_end/protocol_monitor/ProtocolMonitor.js b/front_end/protocol_monitor/ProtocolMonitor.js
index cb0f436..2e32fc1 100644
--- a/front_end/protocol_monitor/ProtocolMonitor.js
+++ b/front_end/protocol_monitor/ProtocolMonitor.js
@@ -243,7 +243,7 @@
case 'request': {
const cell = this.createTD(columnId);
const obj = SDK.RemoteObject.fromLocalObject(this.data[columnId]);
- cell.textContent = obj.description.trimEnd(50);
+ cell.textContent = obj.description.trimEndWithMaxLength(50);
cell.classList.add('source-code');
return cell;
}
diff --git a/front_end/resources/AppManifestView.js b/front_end/resources/AppManifestView.js
index ac75991..44d1269 100644
--- a/front_end/resources/AppManifestView.js
+++ b/front_end/resources/AppManifestView.js
@@ -184,7 +184,7 @@
/**
* @param {?string} url
- * @return {!Promise<?Image>}
+ * @return {!Promise<?Element>}
*/
async _loadImage(url) {
const image = createElement('img');
diff --git a/front_end/resources/ServiceWorkersView.js b/front_end/resources/ServiceWorkersView.js
index 036398d..3f29507 100644
--- a/front_end/resources/ServiceWorkersView.js
+++ b/front_end/resources/ServiceWorkersView.js
@@ -175,7 +175,7 @@
else
section._section.hideWidget();
}
- this.contentElement.classList.toggle('service-worker-has-current', hasThis);
+ this.contentElement.classList.toggle('service-worker-has-current', !!hasThis);
this._otherWorkers.classList.toggle('hidden', !hasOthers);
this._updateListVisibility();
}
diff --git a/front_end/sdk/CSSModel.js b/front_end/sdk/CSSModel.js
index 755da8e..f600a65 100644
--- a/front_end/sdk/CSSModel.js
+++ b/front_end/sdk/CSSModel.js
@@ -648,7 +648,7 @@
/** @typedef {!{range: !Protocol.CSS.SourceRange, styleSheetId: !Protocol.CSS.StyleSheetId, wasUsed: boolean}} */
SDK.CSSModel.RuleUsage;
-/** @typedef {{backgroundColors: ?Array<string>, computedFontSize: string, computedFontWeights: string}} */
+/** @typedef {{backgroundColors: ?Array<string>, computedFontSize: string, computedFontWeight: string}} */
SDK.CSSModel.ContrastInfo;
/** @enum {symbol} */
diff --git a/front_end/sdk/CSSStyleSheetHeader.js b/front_end/sdk/CSSStyleSheetHeader.js
index 7219fc6..12c950a 100644
--- a/front_end/sdk/CSSStyleSheetHeader.js
+++ b/front_end/sdk/CSSStyleSheetHeader.js
@@ -35,7 +35,7 @@
if (!this._originalContentProvider) {
const lazyContent = this._cssModel.originalStyleSheetText.bind(this._cssModel, this);
this._originalContentProvider = new Common.StaticContentProvider(
- this.contentURL(), this.contentType(), /** @type {function():!Promise<?string>} */ (lazyContent));
+ this.contentURL(), this.contentType(), /** @type {function():!Promise<string>} */ (lazyContent));
}
return this._originalContentProvider;
}
@@ -125,10 +125,10 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {
- return this._cssModel.getStyleSheetText(this.id);
+ return /** @type {!Promise<string>} */ (this._cssModel.getStyleSheetText(this.id));
}
/**
diff --git a/front_end/sdk/ChildTargetManager.js b/front_end/sdk/ChildTargetManager.js
index 15bb50c..a89ac32 100644
--- a/front_end/sdk/ChildTargetManager.js
+++ b/front_end/sdk/ChildTargetManager.js
@@ -185,7 +185,7 @@
}
/**
- * @param {function(!Object)} onMessage
+ * @param {function((!Object|string))} onMessage
* @return {!Promise<!Protocol.Connection>}
*/
async createParallelConnection(onMessage) {
@@ -207,7 +207,7 @@
async _createParallelConnectionAndSessionForTarget(target, targetId) {
const targetAgent = target.targetAgent();
const targetRouter = target.router();
- const sessionId = await targetAgent.attachToTarget(targetId, true /* flatten */);
+ const sessionId = /** @type {string} */ (await targetAgent.attachToTarget(targetId, true /* flatten */));
const connection = new SDK.ParallelConnection(targetRouter.connection(), sessionId);
targetRouter.registerSession(target, sessionId, connection);
connection.setOnDisconnect(async () => {
diff --git a/front_end/sdk/ContentProviders.js b/front_end/sdk/ContentProviders.js
index 5cd03c9..45bbc89 100644
--- a/front_end/sdk/ContentProviders.js
+++ b/front_end/sdk/ContentProviders.js
@@ -67,7 +67,7 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {
let callback;
diff --git a/front_end/sdk/DOMModel.js b/front_end/sdk/DOMModel.js
index ef298de..c2e44d1 100644
--- a/front_end/sdk/DOMModel.js
+++ b/front_end/sdk/DOMModel.js
@@ -1190,7 +1190,7 @@
}
/**
- * @return {!Promise<!SDK.DOMDocument>}
+ * @return {!Promise<?SDK.DOMDocument>}
*/
async _requestDocument() {
const documentPayload = await this._agent.getDocument();
diff --git a/front_end/sdk/DebuggerModel.js b/front_end/sdk/DebuggerModel.js
index 79cef91..7f17318 100644
--- a/front_end/sdk/DebuggerModel.js
+++ b/front_end/sdk/DebuggerModel.js
@@ -286,7 +286,7 @@
});
if (response[Protocol.Error])
return {locations: [], breakpointId: null};
- let locations;
+ let locations = [];
if (response.locations)
locations = response.locations.map(payload => SDK.DebuggerModel.Location.fromPayload(this, payload));
return {locations: locations, breakpointId: response.breakpointId};
@@ -310,7 +310,7 @@
return {locations: [], breakpointId: null};
return this._setBreakpointBySourceId(scriptId, lineNumber, columnNumber, condition);
}
- let locations;
+ let locations = [];
if (response.locations)
locations = response.locations.map(payload => SDK.DebuggerModel.Location.fromPayload(this, payload));
return {locations: locations, breakpointId: response.breakpointId};
@@ -1170,6 +1170,7 @@
}
/**
+ * @override
* @param {!SDK.DebuggerModel} debuggerModel
* @param {!Protocol.Debugger.BreakLocation} payload
* @return {!SDK.DebuggerModel.BreakLocation}
diff --git a/front_end/sdk/HARLog.js b/front_end/sdk/HARLog.js
index 21fa0e7..e0b139a 100644
--- a/front_end/sdk/HARLog.js
+++ b/front_end/sdk/HARLog.js
@@ -329,7 +329,7 @@
}
/**
- * @return {!Promise<!Object>}
+ * @return {!Promise<?Object>}
*/
async _buildPostData() {
const postData = await this._request.requestFormData();
diff --git a/front_end/sdk/HeapProfilerModel.js b/front_end/sdk/HeapProfilerModel.js
index 6919fa7..d37fd39 100644
--- a/front_end/sdk/HeapProfilerModel.js
+++ b/front_end/sdk/HeapProfilerModel.js
@@ -74,7 +74,7 @@
* @return {!Promise<!SDK.HeapProfilerModel.NativeHeapProfile>}
*/
async stopNativeSampling() {
- const rawProfile = await this._memoryAgent.getSamplingProfile();
+ const rawProfile = /** @type {!Protocol.Memory.SamplingProfile} */ (await this._memoryAgent.getSamplingProfile());
this._memoryAgent.stopSampling();
return this._convertNativeProfile(rawProfile);
}
@@ -83,7 +83,8 @@
* @return {!Promise<!SDK.HeapProfilerModel.NativeHeapProfile>}
*/
async takeNativeSnapshot() {
- const rawProfile = await this._memoryAgent.getAllTimeSamplingProfile();
+ const rawProfile =
+ /** @type {!Protocol.Memory.SamplingProfile} */ (await this._memoryAgent.getAllTimeSamplingProfile());
return this._convertNativeProfile(rawProfile);
}
@@ -91,7 +92,8 @@
* @return {!Promise<!SDK.HeapProfilerModel.NativeHeapProfile>}
*/
async takeNativeBrowserSnapshot() {
- const rawProfile = await this._memoryAgent.getBrowserSamplingProfile();
+ const rawProfile =
+ /** @type {!Protocol.Memory.SamplingProfile} */ (await this._memoryAgent.getBrowserSamplingProfile());
return this._convertNativeProfile(rawProfile);
}
@@ -235,6 +237,7 @@
};
/**
+ * @implements {Protocol.Profiler.Profile}
* @extends {Protocol.HeapProfiler.SamplingHeapProfile}
*/
SDK.HeapProfilerModel.NativeHeapProfile = class {
diff --git a/front_end/sdk/NetworkRequest.js b/front_end/sdk/NetworkRequest.js
index 6c4cb1d..bde14a3 100644
--- a/front_end/sdk/NetworkRequest.js
+++ b/front_end/sdk/NetworkRequest.js
@@ -1093,10 +1093,10 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
async requestContent() {
- return (await this.contentData()).content;
+ return /** @type {string} */ ((await this.contentData()).content);
}
/**
diff --git a/front_end/sdk/PaintProfiler.js b/front_end/sdk/PaintProfiler.js
index c4371d5..61e3208 100644
--- a/front_end/sdk/PaintProfiler.js
+++ b/front_end/sdk/PaintProfiler.js
@@ -117,7 +117,9 @@
*/
async commandLog() {
const log = await this._paintProfilerModel._layerTreeAgent.snapshotCommandLog(this._id);
- return log && log.map((entry, index) => new SDK.PaintProfilerLogItem(entry, index));
+ return log &&
+ log.map(
+ (entry, index) => new SDK.PaintProfilerLogItem(/** @type {!SDK.RawPaintProfilerLogItem} */ (entry), index));
}
};
diff --git a/front_end/sdk/Resource.js b/front_end/sdk/Resource.js
index 10a2657..50fd5a4 100644
--- a/front_end/sdk/Resource.js
+++ b/front_end/sdk/Resource.js
@@ -188,11 +188,11 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {
if (typeof this._content !== 'undefined')
- return Promise.resolve(this._content);
+ return Promise.resolve(/** @type {string} */ (this._content));
let callback;
const promise = new Promise(fulfill => callback = fulfill);
diff --git a/front_end/sdk/ResourceTreeModel.js b/front_end/sdk/ResourceTreeModel.js
index f465d82..915594c 100644
--- a/front_end/sdk/ResourceTreeModel.js
+++ b/front_end/sdk/ResourceTreeModel.js
@@ -386,7 +386,7 @@
}
/**
- * @return {!Promise<?{currentIndex: number, entries: !Protocol.Page.NavigationEntry}>}
+ * @return {!Promise<?{currentIndex: number, entries: !Array<!Protocol.Page.NavigationEntry>}>}
*/
async navigationHistory() {
const response = await this._agent.invoke_getNavigationHistory({});
diff --git a/front_end/sdk/RuntimeModel.js b/front_end/sdk/RuntimeModel.js
index b377993..f26799a 100644
--- a/front_end/sdk/RuntimeModel.js
+++ b/front_end/sdk/RuntimeModel.js
@@ -55,6 +55,7 @@
/**
* @param {!SDK.RuntimeModel.EvaluationResult} response
+ * @return {boolean}
*/
static isSideEffectFailure(response) {
const exceptionDetails = !response[Protocol.Error] && response.exceptionDetails;
@@ -239,7 +240,7 @@
* @param {string} sourceURL
* @param {boolean} persistScript
* @param {number} executionContextId
- * @return {?Promise<!SDK.RuntimeModel.CompileScriptResult>}
+ * @return {!Promise<?SDK.RuntimeModel.CompileScriptResult>}
*/
async compileScript(expression, sourceURL, persistScript, executionContextId) {
const response = await this._agent.invoke_compileScript({
diff --git a/front_end/sdk/Script.js b/front_end/sdk/Script.js
index 14c5d7d..7800098 100644
--- a/front_end/sdk/Script.js
+++ b/front_end/sdk/Script.js
@@ -135,7 +135,7 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
async requestContent() {
if (this._source)
diff --git a/front_end/sdk/TracingModel.js b/front_end/sdk/TracingModel.js
index 7ec290a..276dd21 100644
--- a/front_end/sdk/TracingModel.js
+++ b/front_end/sdk/TracingModel.js
@@ -534,6 +534,7 @@
}
/**
+ * @this {null}
* @param {!SDK.TracingManager.EventPayload} payload
* @param {!SDK.TracingModel.Thread} thread
* @return {!SDK.TracingModel.Event}
@@ -643,6 +644,8 @@
}
/**
+ * @override
+ * @this {null}
* @param {!SDK.TracingManager.EventPayload} payload
* @param {!SDK.TracingModel.Thread} thread
* @return {!SDK.TracingModel.ObjectSnapshot}
diff --git a/front_end/security/SecurityPanel.js b/front_end/security/SecurityPanel.js
index fdcc33c..865d130 100644
--- a/front_end/security/SecurityPanel.js
+++ b/front_end/security/SecurityPanel.js
@@ -510,7 +510,7 @@
}
};
-/** @enum */
+/** @enum {symbol} */
Security.SecurityPanelSidebarTree.OriginGroup = {
MainOrigin: Symbol('MainOrigin'),
NonSecure: Symbol('NonSecure'),
diff --git a/front_end/source_frame/BinaryResourceViewFactory.js b/front_end/source_frame/BinaryResourceViewFactory.js
index 855bc2a..343ab16 100644
--- a/front_end/source_frame/BinaryResourceViewFactory.js
+++ b/front_end/source_frame/BinaryResourceViewFactory.js
@@ -92,7 +92,7 @@
* @return {!SourceFrame.ResourceSourceFrame}
*/
createUtf8View() {
- const utf8fn = /** @type {function():!Promise<?string>} */ (this.utf8.bind(this));
+ const utf8fn = this.utf8.bind(this);
const utf8ContentProvider = new Common.StaticContentProvider(this._contentUrl, this._resourceType, utf8fn);
return new SourceFrame.ResourceSourceFrame(
utf8ContentProvider,
diff --git a/front_end/source_frame/SourceFrame.js b/front_end/source_frame/SourceFrame.js
index 7b7e662..7010818 100644
--- a/front_end/source_frame/SourceFrame.js
+++ b/front_end/source_frame/SourceFrame.js
@@ -35,7 +35,7 @@
*/
SourceFrame.SourceFrame = class extends UI.SimpleView {
/**
- * @param {function(): !Promise<?string>} lazyContent
+ * @param {function(): !Promise<string>} lazyContent
* @param {!UI.TextEditor.Options=} codeMirrorOptions
*/
constructor(lazyContent, codeMirrorOptions) {
diff --git a/front_end/sources/GutterDiffPlugin.js b/front_end/sources/GutterDiffPlugin.js
index 4ce4277..064be73 100644
--- a/front_end/sources/GutterDiffPlugin.js
+++ b/front_end/sources/GutterDiffPlugin.js
@@ -21,6 +21,7 @@
}
/**
+ * @override
* @param {!Workspace.UISourceCode} uiSourceCode
* @return {boolean}
*/
diff --git a/front_end/sources/JavaScriptBreakpointsSidebarPane.js b/front_end/sources/JavaScriptBreakpointsSidebarPane.js
index 6eff15b..44f19e1 100644
--- a/front_end/sources/JavaScriptBreakpointsSidebarPane.js
+++ b/front_end/sources/JavaScriptBreakpointsSidebarPane.js
@@ -134,7 +134,7 @@
const lineText = text.lineAt(lineNumber);
const maxSnippetLength = 200;
snippetElement.textContent =
- lineText.substring(showColumn ? uiLocation.columnNumber : 0).trimEnd(maxSnippetLength);
+ lineText.substring(showColumn ? uiLocation.columnNumber : 0).trimEndWithMaxLength(maxSnippetLength);
}
}
diff --git a/front_end/sources/SourcesSearchScope.js b/front_end/sources/SourcesSearchScope.js
index 3d19de6..7dadf6c 100644
--- a/front_end/sources/SourcesSearchScope.js
+++ b/front_end/sources/SourcesSearchScope.js
@@ -344,7 +344,7 @@
*/
matchRevealable(index) {
const match = this._searchMatches[index];
- return this._uiSourceCode.uiLocation(match.lineNumber, match.columnNumber);
+ return this._uiSourceCode.uiLocation(match.lineNumber, undefined);
}
/**
diff --git a/front_end/sources/UISourceCodeFrame.js b/front_end/sources/UISourceCodeFrame.js
index 727fe80..e4702d4 100644
--- a/front_end/sources/UISourceCodeFrame.js
+++ b/front_end/sources/UISourceCodeFrame.js
@@ -74,11 +74,11 @@
this._initializeUISourceCode();
/**
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
function workingCopy() {
if (uiSourceCode.isDirty())
- return /** @type {!Promise<?string>} */ (Promise.resolve(uiSourceCode.workingCopy()));
+ return Promise.resolve(uiSourceCode.workingCopy());
return uiSourceCode.requestContent();
}
}
diff --git a/front_end/test_runner/TestRunner.js b/front_end/test_runner/TestRunner.js
index abb4457..99a452c 100644
--- a/front_end/test_runner/TestRunner.js
+++ b/front_end/test_runner/TestRunner.js
@@ -407,7 +407,7 @@
/**
* @param {string} code
- * @return {!Promise<{response: !SDK.RemoteObject,
+ * @return {!Promise<undefined|{response: (!SDK.RemoteObject|undefined),
* exceptionDetails: (!Protocol.Runtime.ExceptionDetails|undefined)}>}
*/
TestRunner._evaluateInPage = async function(code) {
@@ -877,17 +877,17 @@
};
/**
- * @param {symbol} event
+ * @param {symbol} eventName
* @param {!Common.Object} obj
* @param {function(?):boolean=} condition
* @return {!Promise}
*/
-TestRunner.waitForEvent = function(event, obj, condition) {
+TestRunner.waitForEvent = function(eventName, obj, condition) {
condition = condition || function() {
return true;
};
return new Promise(resolve => {
- obj.addEventListener(event, onEventFired);
+ obj.addEventListener(eventName, onEventFired);
/**
* @param {!Common.Event} event
@@ -895,7 +895,7 @@
function onEventFired(event) {
if (!condition(event.data))
return;
- obj.removeEventListener(event, onEventFired);
+ obj.removeEventListener(eventName, onEventFired);
resolve(event.data);
}
});
diff --git a/front_end/text_editor/TextEditorAutocompleteController.js b/front_end/text_editor/TextEditorAutocompleteController.js
index 531c5fb..e9df519 100644
--- a/front_end/text_editor/TextEditorAutocompleteController.js
+++ b/front_end/text_editor/TextEditorAutocompleteController.js
@@ -291,7 +291,7 @@
return;
}
const suffix = hint.substring(query.length).split('\n')[0];
- this._hintElement.textContent = suffix.trimEnd(10000);
+ this._hintElement.textContent = suffix.trimEndWithMaxLength(10000);
const cursor = this._codeMirror.getCursor('to');
if (this._hintMarker) {
const position = this._hintMarker.position();
diff --git a/front_end/timeline/TimelineController.js b/front_end/timeline/TimelineController.js
index f3b0863..002dabe 100644
--- a/front_end/timeline/TimelineController.js
+++ b/front_end/timeline/TimelineController.js
@@ -181,7 +181,7 @@
/**
* @param {string} categories
* @param {boolean=} enableJSSampling
- * @return {!Promise<!Object>}
+ * @return {!Promise<!Object|undefined>}
*/
async _startRecordingWithCategories(categories, enableJSSampling) {
// There might be a significant delay in the beginning of timeline recording
diff --git a/front_end/timeline/TimelineLoader.js b/front_end/timeline/TimelineLoader.js
index 65bf6f9..c102719 100644
--- a/front_end/timeline/TimelineLoader.js
+++ b/front_end/timeline/TimelineLoader.js
@@ -40,7 +40,7 @@
loader._totalSize = file.size;
fileReader.read(loader).then(success => {
if (!success)
- this._reportErrorAndCancelLoading(fileReader.error().message);
+ loader._reportErrorAndCancelLoading(fileReader.error().message);
});
return loader;
}
@@ -198,7 +198,7 @@
/**
* @override
*/
- close() {
+ async close() {
if (!this._client)
return;
this._client.processingStarted();
diff --git a/front_end/timeline/TimelinePanel.js b/front_end/timeline/TimelinePanel.js
index 2448593..1182538 100644
--- a/front_end/timeline/TimelinePanel.js
+++ b/front_end/timeline/TimelinePanel.js
@@ -337,6 +337,9 @@
contextMenu.show();
}
+ /**
+ * @suppress {deprecated}
+ */
async _saveToFile() {
if (this._state !== Timeline.TimelinePanel.State.Idle)
return;
diff --git a/front_end/timeline/TimelineTreeView.js b/front_end/timeline/TimelineTreeView.js
index 376ada7..7f93e22 100644
--- a/front_end/timeline/TimelineTreeView.js
+++ b/front_end/timeline/TimelineTreeView.js
@@ -701,15 +701,17 @@
categories['other'].color;
const unattributed = Common.UIString('[unattributed]');
+ const id = typeof node.id === 'symbol' ? undefined : node.id;
+
switch (this._groupBySetting.get()) {
case Timeline.AggregatedTimelineTreeView.GroupBy.Category: {
- const category = categories[node.id] || categories['other'];
+ const category = id ? categories[id] || categories['other'] : unattributed;
return {name: category.title, color: category.color};
}
case Timeline.AggregatedTimelineTreeView.GroupBy.Domain:
case Timeline.AggregatedTimelineTreeView.GroupBy.Subdomain: {
- let domainName = this._beautifyDomainName(node.id);
+ let domainName = id ? this._beautifyDomainName(id) : undefined;
if (domainName) {
const productName = this._productByEvent(/** @type {!SDK.TracingModel.Event} */ (node.event));
if (productName)
@@ -742,7 +744,7 @@
break;
case Timeline.AggregatedTimelineTreeView.GroupBy.Frame: {
- const frame = this._model.timelineModel().pageFrameById(node.id);
+ const frame = id ? this._model.timelineModel().pageFrameById(id) : undefined;
const frameName = frame ? Timeline.TimelineUIUtils.displayNameForFrame(frame, 80) : Common.UIString('Page');
return {name: frameName, color: color};
}
@@ -750,7 +752,7 @@
default:
console.assert(false, 'Unexpected grouping type');
}
- return {name: node.id || unattributed, color: color};
+ return {name: id || unattributed, color: color};
}
/**
@@ -919,7 +921,7 @@
return;
if (!node.isGroupNode())
return;
- const frame = this._model.timelineModel().pageFrameById(node.id);
+ const frame = this._model.timelineModel().pageFrameById(/** @type {string} */ (node.id));
if (!frame || !frame.ownerNode)
return;
contextMenu.appendApplicableItems(frame.ownerNode);
diff --git a/front_end/timeline_model/TimelineModel.js b/front_end/timeline_model/TimelineModel.js
index 0bd19b5..c2303ec 100644
--- a/front_end/timeline_model/TimelineModel.js
+++ b/front_end/timeline_model/TimelineModel.js
@@ -1932,7 +1932,7 @@
/**
* @param {!Array.<string>=} types
- * @return {!Iterator.<!TimelineModel.InvalidationTrackingEvent>}
+ * @return {!Generator<!TimelineModel.InvalidationTrackingEvent>}
*/
_invalidationsOfTypes(types) {
const invalidations = this._invalidations;
diff --git a/front_end/timeline_model/TimelineProfileTree.js b/front_end/timeline_model/TimelineProfileTree.js
index 22e1c88..d16b466 100644
--- a/front_end/timeline_model/TimelineProfileTree.js
+++ b/front_end/timeline_model/TimelineProfileTree.js
@@ -5,11 +5,16 @@
TimelineModel.TimelineProfileTree = {};
/**
+ * @typedef {Map<string|symbol, !TimelineModel.TimelineProfileTree.Node>}
+ */
+TimelineModel.TimelineProfileTree.ChildrenCache;
+
+/**
* @unrestricted
*/
TimelineModel.TimelineProfileTree.Node = class {
/**
- * @param {string} id
+ * @param {string|symbol} id
* @param {?SDK.TracingModel.Event} event
*/
constructor(id, event) {
@@ -17,7 +22,7 @@
this.totalTime = 0;
/** @type {number} */
this.selfTime = 0;
- /** @type {string} */
+ /** @type {string|symbol} */
this.id = id;
/** @type {?SDK.TracingModel.Event} */
this.event = event;
@@ -44,7 +49,7 @@
}
/**
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
children() {
throw 'Not implemented';
@@ -67,7 +72,7 @@
TimelineModel.TimelineProfileTree.TopDownNode = class extends TimelineModel.TimelineProfileTree.Node {
/**
- * @param {string} id
+ * @param {string|symbol} id
* @param {?SDK.TracingModel.Event} event
* @param {?TimelineModel.TimelineProfileTree.TopDownNode} parent
*/
@@ -90,14 +95,14 @@
/**
* @override
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
children() {
return this._children || this._buildChildren();
}
/**
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
_buildChildren() {
/** @type {!Array<!TimelineModel.TimelineProfileTree.TopDownNode>} */
@@ -105,7 +110,7 @@
for (let node = this; node.parent && !node._isGroupNode; node = node.parent)
path.push(/** @type {!TimelineModel.TimelineProfileTree.TopDownNode} */ (node));
path.reverse();
- /** @type {!Map<string, !TimelineModel.TimelineProfileTree.Node>} */
+ /** @type {!TimelineModel.TimelineProfileTree.ChildrenCache} */
const children = new Map();
const self = this;
const root = this._root;
@@ -239,14 +244,14 @@
/**
* @override
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
children() {
return this._children || this._grouppedTopNodes();
}
/**
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
_grouppedTopNodes() {
const flatNodes = super.children();
@@ -281,7 +286,7 @@
*/
constructor(events, textFilter, filters, startTime, endTime, eventGroupIdCallback) {
super('', null);
- /** @type {?Map<string, !TimelineModel.TimelineProfileTree.Node>} */
+ /** @type {?TimelineModel.TimelineProfileTree.ChildrenCache} */
this._children = null;
this._events = events;
this._textFilter = textFilter;
@@ -301,20 +306,20 @@
}
/**
- * @param {!Map<string, !TimelineModel.TimelineProfileTree.Node>} children
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @param {!TimelineModel.TimelineProfileTree.ChildrenCache} children
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
_filterChildren(children) {
for (const [id, child] of children) {
if (child.event && !this._textFilter.accept(child.event))
- children.delete(/** @type {string} */ (id));
+ children.delete(/** @type {string|symbol} */ (id));
}
return children;
}
/**
* @override
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
children() {
if (!this._children)
@@ -323,13 +328,13 @@
}
/**
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
_ungrouppedTopNodes() {
const root = this;
const startTime = this._startTime;
const endTime = this._endTime;
- /** @type {!Map<string, !TimelineModel.TimelineProfileTree.Node>} */
+ /** @type {!TimelineModel.TimelineProfileTree.ChildrenCache} */
const nodeById = new Map();
/** @type {!Array<number>} */
const selfTimeStack = [endTime - startTime];
@@ -382,7 +387,7 @@
}
/**
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
_grouppedTopNodes() {
const flatNodes = this._ungrouppedTopNodes();
@@ -438,7 +443,7 @@
/**
* @override
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
children() {
return this._children;
@@ -458,7 +463,7 @@
this.parent = parent;
this._root = root;
this._depth = (parent._depth || 0) + 1;
- /** @type {?Map<string, !TimelineModel.TimelineProfileTree.Node>} */
+ /** @type {?TimelineModel.TimelineProfileTree.ChildrenCache} */
this._cachedChildren = null;
this._hasChildren = hasChildren;
}
@@ -477,7 +482,7 @@
/**
* @override
- * @return {!Map<string, !TimelineModel.TimelineProfileTree.Node>}
+ * @return {!TimelineModel.TimelineProfileTree.ChildrenCache}
*/
children() {
if (this._cachedChildren)
@@ -488,7 +493,7 @@
const eventIdStack = [];
/** @type {!Array<!SDK.TracingModel.Event>} */
const eventStack = [];
- /** @type {!Map<string, !TimelineModel.TimelineProfileTree.Node>} */
+ /** @type {!TimelineModel.TimelineProfileTree.ChildrenCache} */
const nodeById = new Map();
const startTime = this._root._startTime;
const endTime = this._root._endTime;
diff --git a/front_end/ui/ARIAUtils.js b/front_end/ui/ARIAUtils.js
index 4eac502..39f467a 100644
--- a/front_end/ui/ARIAUtils.js
+++ b/front_end/ui/ARIAUtils.js
@@ -431,7 +431,7 @@
alertElement.setAttribute('aria-atomic', 'true');
document[UI.ARIAUtils.AlertElementSymbol] = alertElement;
}
- document[UI.ARIAUtils.AlertElementSymbol].textContent = message.trimEnd(10000);
+ document[UI.ARIAUtils.AlertElementSymbol].textContent = message.trimEndWithMaxLength(10000);
};
UI.ARIAUtils.AlertElementSymbol = Symbol('AlertElementSybmol');
diff --git a/front_end/ui/GlassPane.js b/front_end/ui/GlassPane.js
index f6b61de..6c06f67 100644
--- a/front_end/ui/GlassPane.js
+++ b/front_end/ui/GlassPane.js
@@ -119,7 +119,7 @@
}
/**
- * @param {boolean} behavior
+ * @param {!UI.GlassPane.MarginBehavior} behavior
*/
setMarginBehavior(behavior) {
this._marginBehavior = behavior;
diff --git a/front_end/ui/Icon.js b/front_end/ui/Icon.js
index 41046de..a7ef018 100644
--- a/front_end/ui/Icon.js
+++ b/front_end/ui/Icon.js
@@ -90,7 +90,7 @@
UI.Icon._positionRegex = /^[a-z][1-9][0-9]*$/;
-/** @typedef {{position: string, spritesheet: string, isMask: (boolean|undefined)}} */
+/** @typedef {{position: string, spritesheet: string, isMask: (boolean|undefined), coordinates: ({x: number, y: number}|undefined), invert: (boolean|undefined)}} */
UI.Icon.Descriptor;
/** @typedef {{cellWidth: number, cellHeight: number, padding: number}} */
diff --git a/front_end/ui/SuggestBox.js b/front_end/ui/SuggestBox.js
index f460d14..4af9055 100644
--- a/front_end/ui/SuggestBox.js
+++ b/front_end/ui/SuggestBox.js
@@ -199,7 +199,7 @@
element.classList.add('secondary');
element.tabIndex = -1;
const maxTextLength = 50 + query.length;
- const displayText = (item.title || item.text).trim().trimEnd(maxTextLength).replace(/\n/g, '\u21B5');
+ const displayText = (item.title || item.text).trim().trimEndWithMaxLength(maxTextLength).replace(/\n/g, '\u21B5');
const titleElement = element.createChild('span', 'suggestion-title');
const index = displayText.toLowerCase().indexOf(query.toLowerCase());
@@ -215,7 +215,7 @@
element.appendChild(subtitleElement);
} else if (item.subtitle) {
const subtitleElement = element.createChild('span', 'suggestion-subtitle');
- subtitleElement.textContent = item.subtitle.trimEnd(maxTextLength - displayText.length);
+ subtitleElement.textContent = item.subtitle.trimEndWithMaxLength(maxTextLength - displayText.length);
}
return element;
}
diff --git a/front_end/ui/UIUtils.js b/front_end/ui/UIUtils.js
index 6495a8b..4358889 100644
--- a/front_end/ui/UIUtils.js
+++ b/front_end/ui/UIUtils.js
@@ -1618,7 +1618,7 @@
* @return {string}
*/
UI.trimTextEnd = function(context, text, maxWidth) {
- return UI.trimText(context, text, maxWidth, (text, width) => text.trimEnd(width));
+ return UI.trimText(context, text, maxWidth, (text, width) => text.trimEndWithMaxLength(width));
};
/**
@@ -1828,7 +1828,7 @@
output.push(':');
const items = value.replace(Common.Color.Regex, '\0$1\0').split('\0');
for (let i = 0; i < items.length; ++i)
- output.push(this.patchColorText(items[i], colorUsage));
+ output.push(this.patchColorText(items[i], /** @type {!UI.ThemeSupport.ColorUsage} */ (colorUsage)));
if (style.getPropertyPriority(name))
output.push(' !important');
output.push(';');
diff --git a/front_end/ui/View.js b/front_end/ui/View.js
index 4dbf341..691eb91 100644
--- a/front_end/ui/View.js
+++ b/front_end/ui/View.js
@@ -37,6 +37,9 @@
*/
widget() {},
+ /**
+ * @return {!Promise|undefined}
+ */
disposeView() {}
};
diff --git a/front_end/ui/XElement.js b/front_end/ui/XElement.js
index 09d340a..189e9fe 100644
--- a/front_end/ui/XElement.js
+++ b/front_end/ui/XElement.js
@@ -6,6 +6,9 @@
* @extends {HTMLElement}
*/
UI.XElement = class extends HTMLElement {
+ /**
+ * @override
+ */
static get observedAttributes() {
return [
'flex', 'padding', 'padding-top', 'padding-bottom', 'padding-left',
@@ -61,9 +64,11 @@
this.style.setProperty('justify-content', 'flex-start');
}
+ /**
+ * @override
+ */
static get observedAttributes() {
- // TODO(dgozman): should be super.observedAttributes, but does not compile.
- return UI.XElement.observedAttributes.concat(['x-start', 'x-center', 'x-stretch', 'x-baseline', 'justify-content']);
+ return super.observedAttributes.concat(['x-start', 'x-center', 'x-stretch', 'x-baseline', 'justify-content']);
}
/**
diff --git a/front_end/ui/XLink.js b/front_end/ui/XLink.js
index 6f1aa1a..880060c 100644
--- a/front_end/ui/XLink.js
+++ b/front_end/ui/XLink.js
@@ -50,6 +50,7 @@
}
/**
+ * @override
* @return {!Array<string>}
*/
static get observedAttributes() {
diff --git a/front_end/ui/treeoutline.js b/front_end/ui/treeoutline.js
index ea294c5..d95edee 100644
--- a/front_end/ui/treeoutline.js
+++ b/front_end/ui/treeoutline.js
@@ -377,7 +377,8 @@
this._boundOnBlur = this._onBlur.bind(this);
this._listItemNode = createElement('li');
- this._titleElement = this._listItemNode.createChild('span', 'tree-element-title');
+ /** @protected */
+ this.titleElement = this._listItemNode.createChild('span', 'tree-element-title');
this._listItemNode.treeElement = this;
if (title)
this.title = title;
@@ -628,13 +629,6 @@
return this._listItemNode;
}
- /**
- * @return {!Element}
- */
- titleElement() {
- return this._titleElement;
- }
-
get childrenListElement() {
return this._childrenListNode;
}
@@ -655,17 +649,17 @@
this._title = x;
if (typeof x === 'string') {
- this._titleElement.textContent = x;
+ this.titleElement.textContent = x;
this.tooltip = x;
} else {
- this._titleElement = x;
+ this.titleElement = x;
this.tooltip = '';
}
this._listItemNode.removeChildren();
if (this._leadingIconsElement)
this._listItemNode.appendChild(this._leadingIconsElement);
- this._listItemNode.appendChild(this._titleElement);
+ this._listItemNode.appendChild(this.titleElement);
if (this._trailingIconsElement)
this._listItemNode.appendChild(this._trailingIconsElement);
this._ensureSelection();
@@ -686,8 +680,8 @@
* @param {!UI.InplaceEditor.Config} editingConfig
*/
startEditingTitle(editingConfig) {
- UI.InplaceEditor.startEditing(this._titleElement, editingConfig);
- this.treeOutline._shadowRoot.getSelection().selectAllChildren(this._titleElement);
+ UI.InplaceEditor.startEditing(/** @type {!Element} */ (this.titleElement), editingConfig);
+ this.treeOutline._shadowRoot.getSelection().selectAllChildren(this.titleElement);
}
/**
@@ -699,7 +693,7 @@
if (!this._leadingIconsElement) {
this._leadingIconsElement = createElementWithClass('div', 'leading-icons');
this._leadingIconsElement.classList.add('icons-container');
- this._listItemNode.insertBefore(this._leadingIconsElement, this._titleElement);
+ this._listItemNode.insertBefore(this._leadingIconsElement, this.titleElement);
this._ensureSelection();
}
this._leadingIconsElement.removeChildren();
diff --git a/front_end/web_audio/AudioContextSelector.js b/front_end/web_audio/AudioContextSelector.js
index 7fc659d..4ccc3c7 100644
--- a/front_end/web_audio/AudioContextSelector.js
+++ b/front_end/web_audio/AudioContextSelector.js
@@ -78,7 +78,7 @@
const element = createElementWithClass('div');
const shadowRoot = UI.createShadowRootWithCoreStyles(element, 'web_audio/audioContextSelector.css');
const title = shadowRoot.createChild('div', 'title');
- title.createTextChild(this.titleFor(item).trimEnd(100));
+ title.createTextChild(this.titleFor(item).trimEndWithMaxLength(100));
return element;
}
diff --git a/front_end/workspace/UISourceCode.js b/front_end/workspace/UISourceCode.js
index d4724e7..50e5b31 100644
--- a/front_end/workspace/UISourceCode.js
+++ b/front_end/workspace/UISourceCode.js
@@ -56,7 +56,7 @@
}
this._contentType = contentType;
- /** @type {?Promise<?string>} */
+ /** @type {?Promise<string>} */
this._requestContentPromise = null;
/** @type {?Multimap<string, !Workspace.UISourceCode.LineMarker>} */
this._decorations = null;
@@ -142,7 +142,7 @@
name = decodeURI(name);
} catch (e) {
}
- return skipTrim ? name : name.trimEnd(100);
+ return skipTrim ? name : name.trimEndWithMaxLength(100);
}
/**
@@ -235,14 +235,14 @@
/**
* @override
- * @return {!Promise<?string>}
+ * @return {!Promise<string>}
*/
requestContent() {
if (this._requestContentPromise)
return this._requestContentPromise;
if (this._contentLoaded) {
- this._requestContentPromise = Promise.resolve(this._content);
+ this._requestContentPromise = Promise.resolve(this._content || '');
} else {
let fulfill;
this._requestContentPromise = new Promise(x => fulfill = x);