Skip to content

Commit

Permalink
deps: update to latest CDT packages (GoogleChrome#14293)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored and alexnj committed Aug 24, 2022
1 parent 2189bcc commit ccacd91
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 53 deletions.
140 changes: 113 additions & 27 deletions core/lib/cdt/generated/SourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class SourceMapV3 {
sourceRoot;
names;
sourcesContent;
// eslint-disable-next-line @typescript-eslint/naming-convention
x_google_ignoreList;
constructor() {
}
}
Expand Down Expand Up @@ -153,6 +155,38 @@ class TextSourceMap {
const index = Platform.ArrayUtilities.upperBound(mappings, undefined, (unused, entry) => lineNumber - entry.lineNumber || columnNumber - entry.columnNumber);
return index ? mappings[index - 1] : null;
}
findEntryRanges(lineNumber, columnNumber) {
const mappings = this.mappings();
const index = Platform.ArrayUtilities.upperBound(mappings, undefined, (unused, entry) => lineNumber - entry.lineNumber || columnNumber - entry.columnNumber);
if (!index) {
// If the line and column are preceding all the entries, then there is nothing to map.
return null;
}
const sourceURL = mappings[index].sourceURL;
if (!sourceURL) {
return null;
}
// Let us compute the range that contains the source position in the compiled code.
const endLine = index < mappings.length ? mappings[index].lineNumber : 2 ** 31 - 1;
const endColumn = index < mappings.length ? mappings[index].columnNumber : 2 ** 31 - 1;
const range = new TextUtils.TextRange.TextRange(mappings[index - 1].lineNumber, mappings[index - 1].columnNumber, endLine, endColumn);
// Now try to find the corresponding token in the original code.
const reverseMappings = this.reversedMappings(sourceURL);
const startSourceLine = mappings[index - 1].sourceLineNumber;
const startSourceColumn = mappings[index - 1].sourceColumnNumber;
const endReverseIndex = Platform.ArrayUtilities.upperBound(reverseMappings, undefined, (unused, i) => startSourceLine - mappings[i].sourceLineNumber || startSourceColumn - mappings[i].sourceColumnNumber);
if (!endReverseIndex) {
return null;
}
const endSourceLine = endReverseIndex < reverseMappings.length ?
mappings[reverseMappings[endReverseIndex]].sourceLineNumber :
2 ** 31 - 1;
const endSourceColumn = endReverseIndex < reverseMappings.length ?
mappings[reverseMappings[endReverseIndex]].sourceColumnNumber :
2 ** 31 - 1;
const sourceRange = new TextUtils.TextRange.TextRange(startSourceLine, startSourceColumn, endSourceLine, endSourceColumn);
return { range, sourceRange, sourceURL };
}
sourceLineMapping(sourceURL, lineNumber, columnNumber) {
const mappings = this.mappings();
const reverseMappings = this.reversedMappings(sourceURL);
Expand Down Expand Up @@ -219,37 +253,48 @@ class TextSourceMap {
}
/** @return {Array<{lineNumber: number, columnNumber: number, sourceURL?: string, sourceLineNumber: number, sourceColumnNumber: number, name?: string, lastColumnNumber?: number}>} */
mappings() {
this.#ensureMappingsProcessed();
return this.#mappingsInternal ?? [];
}
reversedMappings(sourceURL) {
this.#ensureMappingsProcessed();
return this.#sourceInfos.get(sourceURL)?.reverseMappings ?? [];
}
#ensureMappingsProcessed() {
if (this.#mappingsInternal === null) {
this.#mappingsInternal = [];
this.eachSection(this.parseMap.bind(this));
this.#computeReverseMappings(this.#mappingsInternal);
this.#json = null;
}
return this.#mappingsInternal;
}
reversedMappings(sourceURL) {
const info = this.#sourceInfos.get(sourceURL);
if (!info) {
return [];
#computeReverseMappings(mappings) {
const reverseMappingsPerUrl = new Map();
for (let i = 0; i < mappings.length; i++) {
const entryUrl = mappings[i].sourceURL;
if (!entryUrl) {
continue;
}
let reverseMap = reverseMappingsPerUrl.get(entryUrl);
if (!reverseMap) {
reverseMap = [];
reverseMappingsPerUrl.set(entryUrl, reverseMap);
}
reverseMap.push(i);
}
const mappings = this.mappings();
if (info.reverseMappings === null) {
const indexes = Array(mappings.length).fill(0).map((_, i) => i);
info.reverseMappings = indexes.filter(i => mappings[i].sourceURL === sourceURL).sort(sourceMappingComparator);
for (const [url, reverseMap] of reverseMappingsPerUrl.entries()) {
const info = this.#sourceInfos.get(url);
if (!info) {
continue;
}
reverseMap.sort(sourceMappingComparator);
info.reverseMappings = reverseMap;
}
return info.reverseMappings;
function sourceMappingComparator(indexA, indexB) {
const a = mappings[indexA];
const b = mappings[indexB];
if (a.sourceLineNumber !== b.sourceLineNumber) {
return a.sourceLineNumber - b.sourceLineNumber;
}
if (a.sourceColumnNumber !== b.sourceColumnNumber) {
return a.sourceColumnNumber - b.sourceColumnNumber;
}
if (a.lineNumber !== b.lineNumber) {
return a.lineNumber - b.lineNumber;
}
return a.columnNumber - b.columnNumber;
return a.sourceLineNumber - b.sourceLineNumber || a.sourceColumnNumber - b.sourceColumnNumber ||
a.lineNumber - b.lineNumber || a.columnNumber - b.columnNumber;
}
}
eachSection(callback) {
Expand All @@ -267,6 +312,7 @@ class TextSourceMap {
parseSources(sourceMap) {
const sourcesList = [];
const sourceRoot = sourceMap.sourceRoot || Platform.DevToolsPath.EmptyUrlString;
const ignoreList = new Set(sourceMap.x_google_ignoreList);
for (let i = 0; i < sourceMap.sources.length; ++i) {
let href = sourceMap.sources[i];
// The source map v3 proposal says to prepend the sourceRoot to the source URL
Expand All @@ -286,11 +332,12 @@ class TextSourceMap {
const source = sourceMap.sourcesContent && sourceMap.sourcesContent[i];
if (url === this.#compiledURLInternal && source) {
}
if (this.#sourceInfos.has(url)) {
continue;
}
this.#sourceInfos.set(url, new TextSourceMap.SourceInfo(source || null, null));
sourcesList.push(url);
if (!this.#sourceInfos.has(url)) {
const content = source ?? null;
const ignoreListHint = ignoreList.has(i);
this.#sourceInfos.set(url, new TextSourceMap.SourceInfo(content, ignoreListHint));
}
}
sourceMapToSourceList.set(sourceMap, sourcesList);
}
Expand Down Expand Up @@ -394,6 +441,44 @@ class TextSourceMap {
}
return false;
}
hasIgnoreListHint(sourceURL) {
return this.#sourceInfos.get(sourceURL)?.ignoreListHint ?? false;
}
/**
* Returns a list of ranges in the generated script for original sources that
* match a predicate. Each range is a [begin, end) pair, meaning that code at
* the beginning location, up to but not including the end location, matches
* the predicate.
*/
findRanges(predicate, options) {
const mappings = this.mappings();
const ranges = [];
if (!mappings.length) {
return [];
}
let current = null;
// If the first mapping isn't at the beginning of the original source, it's
// up to the caller to decide if it should be considered matching the
// predicate or not. By default, it's not.
if ((mappings[0].lineNumber !== 0 || mappings[0].columnNumber !== 0) && options?.isStartMatching) {
current = TextUtils.TextRange.TextRange.createUnboundedFromLocation(0, 0);
ranges.push(current);
}
for (const { sourceURL, lineNumber, columnNumber } of mappings) {
const ignoreListHint = sourceURL && predicate(sourceURL);
if (!current && ignoreListHint) {
current = TextUtils.TextRange.TextRange.createUnboundedFromLocation(lineNumber, columnNumber);
ranges.push(current);
continue;
}
if (current && !ignoreListHint) {
current.endLine = lineNumber;
current.endColumn = columnNumber;
current = null;
}
}
return ranges;
}
}
exports.TextSourceMap = TextSourceMap;
(function (TextSourceMap) {
Expand Down Expand Up @@ -426,10 +511,11 @@ exports.TextSourceMap = TextSourceMap;
TextSourceMap.StringCharIterator = StringCharIterator;
class SourceInfo {
content;
reverseMappings;
constructor(content, reverseMappings) {
ignoreListHint;
reverseMappings = null;
constructor(content, ignoreListHint) {
this.content = content;
this.reverseMappings = reverseMappings;
this.ignoreListHint = ignoreListHint;
}
}
TextSourceMap.SourceInfo = SourceInfo;
Expand Down
84 changes: 74 additions & 10 deletions core/lib/deprecations-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ const UIStrings = {
*/
title: 'Deprecated Feature Used',

// Store alphabetized messages per DeprecationIssueType in this block.
/**
* @description TODO(crbug.com/1318846): Description needed for translation
* @description We show this warning when 1) an "authorization" header is
* attached to the request by scripts, 2) there is no "authorization" in
* the "access-control-allow-headers" header in the response, and 3) there
* is a wildcard symbol ("*") in the "access-control-allow-header" header
* in the response. This is allowed now, but we're planning to reject such
* responses and require responses to have an "access-control-allow-headers"
* containing "authorization".
*/
authorizationCoveredByWildcard:
'Authorization will not be covered by the wildcard symbol (*) in CORS `Access-Control-Allow-Headers` handling.',
Expand Down Expand Up @@ -69,7 +74,9 @@ const UIStrings = {
*/
crossOriginWindowApi: 'Triggering {PH1} from cross origin iframes has been deprecated and will be removed in the future.',
/**
* @description TODO(crbug.com/1320339): Description needed for translation
* @description Warning displayed to developers when they hide the Cast button
* on a video element using the deprecated CSS selector instead of using the
* disableRemotePlayback attribute on the element.
*/
cssSelectorInternalMediaControlsOverlayCastButton:
'The `disableRemotePlayback` attribute should be used in order to disable the default Cast integration instead of using `-internal-media-controls-overlay-cast-button` selector.',
Expand All @@ -89,6 +96,10 @@ const UIStrings = {
* @description Warning displayed to developers when the non-standard `Event.path` API is used to notify them that this API is deprecated.
*/
eventPath: '`Event.path` is deprecated and will be removed. Please use `Event.composedPath()` instead.',
/**
* @description This message is shown when the deprecated Expect-CT header is present.
*/
expectCTHeader: 'The `Expect-CT` header is deprecated and will be removed. Chrome requires Certificate Transparency for all publicly trusted certificates issued after April 30, 2018.',
/**
* @description Warning displayed to developers when the Geolocation API is used from an insecure origin (one that isn't localhost or doesn't use HTTPS) to notify them that this use is no longer supported.
*/
Expand All @@ -109,6 +120,12 @@ const UIStrings = {
*/
hostCandidateAttributeGetter:
'`RTCPeerConnectionIceErrorEvent.hostCandidate` is deprecated. Please use `RTCPeerConnectionIceErrorEvent.address` or `RTCPeerConnectionIceErrorEvent.port` instead.',
/**
* @description A deprecation warning shown in the DevTools Issues tab,
* when a service worker reads one of the fields from an event named
* "canmakepayment".
*/
identityInCanMakePaymentEvent: 'The merchant origin and arbitrary data from the `canmakepayment` service worker event are deprecated and will be removed: `topOrigin`, `paymentRequestOrigin`, `methodData`, `modifiers`.',
/**
* @description TODO(crbug.com/1320343): Description needed for translation
*/
Expand Down Expand Up @@ -156,6 +173,16 @@ const UIStrings = {
*/
obsoleteWebRtcCipherSuite:
'Your partner is negotiating an obsolete (D)TLS version. Please check with your partner to have this fixed.',
/**
* @description Warning displayed to developers when `window.openDatabase` is used in non-secure contexts to notify that the API is deprecated and will be removed.
*/
openWebDatabaseInsecureContext:
'WebSQL in non-secure contexts is deprecated and will be removed in M107. Please use Web Storage or Indexed Database.',
/**
* @description Warning displayed to developers when persistent storage type is used to notify that storage type is deprecated.
*/
persistentQuotaType:
'`StorageType.persistent` is deprecated. Please use standardized `navigator.storage` instead.',
/**
* @description This issue indicates that a `<source>` element with a `<picture>` parent was using an `src` attribute, which is not valid and is ignored by the browser. The `srcset` attribute should be used instead.
*/
Expand All @@ -172,7 +199,7 @@ const UIStrings = {
* @description Warning displayed to developers when `window.webkitStorageInfo` is used to notify that the API is deprecated.
*/
prefixedStorageInfo:
'`window.webkitStorageInfo` is deprecated. Please use `navigator.webkitTemporaryStorage` or `navigator.webkitPersistentStorage` instead.',
'`window.webkitStorageInfo` is deprecated. Please use standardized `navigator.storage` instead.',
/**
* @description Standard message when one web API is deprecated in favor of another. Both
* placeholders are always web API functions.
Expand Down Expand Up @@ -232,7 +259,8 @@ const UIStrings = {
*/
rtcpMuxPolicyNegotiate: 'The `rtcpMuxPolicy` option is deprecated and will be removed.',
/**
* @description TODO(crbug.com/1318878): Description needed for translation
* @description A deprecation warning shown in the DevTools Issues tab. The placeholder is always the noun
* "SharedArrayBuffer" which refers to a JavaScript construct.
*/
sharedArrayBufferConstructedWithoutIsolation:
'`SharedArrayBuffer` will require cross-origin isolation. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details.',
Expand All @@ -244,16 +272,24 @@ const UIStrings = {
textToSpeech_DisallowedByAutoplay:
'`speechSynthesis.speak()` without user activation is deprecated and will be removed.',
/**
* @description TODO(crbug.com/1318879): Description needed for translation
* @description A deprecation warning shown in the DevTools Issues tab. The placeholder is always the noun
* "SharedArrayBuffer" which refers to a JavaScript construct. "Extensions" refers to Chrome extensions. The warning is shown
* when Chrome Extensions attempt to use "SharedArrayBuffer"s under insecure circumstances.
*/
v8SharedArrayBufferConstructedInExtensionWithoutIsolation:
'Extensions should opt into cross-origin isolation to continue using `SharedArrayBuffer`. See https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/.',
/**
* @description TODO(crbug.com/1318881): Description needed for translation
* @description Warning displayed to developers that they are using
* `XMLHttpRequest` API in a way that they expect an unsupported character
* encoding `UTF-16` could be used in the server reply.
*/
xhrJSONEncodingDetection: 'UTF-16 is not supported by response json in `XMLHttpRequest`',
/**
* @description TODO(crbug.com/1318882): Description needed for translation
* @description Warning displayed to developers. It is shown when
* the `XMLHttpRequest` API is used in a way that it slows down the page load
* of the next page. The `main thread` refers to an operating systems thread
* used to run most of the processing of HTML documents, so please use a
* consistent wording.
*/
xmlHttpRequestSynchronousInNonWorkerOutsideBeforeUnload:
'Synchronous `XMLHttpRequest` on the main thread is deprecated because of its detrimental effects to the end user\u2019s experience. For more help, check https://xhr.spec.whatwg.org/.',
Expand Down Expand Up @@ -306,7 +342,7 @@ function getDescription(issueDetails) {
break;
case 'CrossOriginAccessBasedOnDocumentDomain':
message = str_(UIStrings.crossOriginAccessBasedOnDocumentDomain);
milestone = 106;
milestone = 109;
break;
case 'CrossOriginWindowAlert':
message = str_(UIStrings.crossOriginWindowApi, {PH1: 'window.alert'});
Expand All @@ -325,13 +361,18 @@ function getDescription(issueDetails) {
break;
case 'DocumentDomainSettingWithoutOriginAgentClusterHeader':
message = str_(UIStrings.documentDomainSettingWithoutOriginAgentClusterHeader);
milestone = 106;
milestone = 109;
break;
case 'EventPath':
message = str_(UIStrings.eventPath);
feature = 5726124632965120;
milestone = 109;
break;
case 'ExpectCTHeader':
message = str_(UIStrings.expectCTHeader);
feature = 6244547273687040;
milestone = 107;
break;
case 'GeolocationInsecureOrigin':
message = str_(UIStrings.geolocationInsecureOrigin);
break;
Expand All @@ -344,6 +385,10 @@ function getDescription(issueDetails) {
case 'HostCandidateAttributeGetter':
message = str_(UIStrings.hostCandidateAttributeGetter);
break;
case 'IdentityInCanMakePaymentEvent':
message = str_(UIStrings.identityInCanMakePaymentEvent);
feature = 5190978431352832;
break;
case 'InsecurePrivateNetworkSubresourceRequest':
message = str_(UIStrings.insecurePrivateNetworkSubresourceRequest);
feature = 5436853517811712;
Expand All @@ -365,6 +410,15 @@ function getDescription(issueDetails) {
message = str_(UIStrings.mediaSourceDurationTruncatingBuffered);
feature = 6107495151960064;
break;
case 'NavigateEventRestoreScroll':
message = str_(
UIStrings.deprecatedWithReplacement, {PH1: 'navigateEvent.restoreScroll()', PH2: 'navigateEvent.scroll()'});
break;
case 'NavigateEventTransitionWhile':
message = str_(
UIStrings.deprecatedWithReplacement,
{PH1: 'navigateEvent.transitionWhile()', PH2: 'navigateEvent.intercept()'});
break;
case 'NoSysexWebMIDIWithoutPermission':
message = str_(UIStrings.noSysexWebMIDIWithoutPermission);
feature = 5138066234671104;
Expand All @@ -381,6 +435,16 @@ function getDescription(issueDetails) {
message = str_(UIStrings.obsoleteWebRtcCipherSuite);
milestone = 81;
break;
case 'OpenWebDatabaseInsecureContext':
message = str_(UIStrings.openWebDatabaseInsecureContext);
feature = 5175124599767040;
milestone = 105;
break;
case 'PersistentQuotaType':
message = str_(UIStrings.persistentQuotaType);
feature = 5176235376246784;
milestone = 106;
break;
case 'PictureSourceSrc':
message = str_(UIStrings.pictureSourceSrc);
break;
Expand Down
1 change: 1 addition & 0 deletions core/lib/network-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const RESOURCE_TYPES = {
Ping: 'Ping',
Preflight: 'Preflight',
CSPViolationReport: 'CSPViolationReport',
Prefetch: 'Prefetch',
};

class NetworkRequest {
Expand Down
Loading

0 comments on commit ccacd91

Please sign in to comment.