Revert "Update Mocha and rollup-plugin-terser"
This reverts commit ecc4ecb65cd8285f5dc4eb6b02efb10787e440f2.
Reason for revert: This CL is suspected of breaking the roll into
chromium (https://crbug.com/1121242#c2).
Original change's description:
> Update Mocha and rollup-plugin-terser
>
> These two packages had NPM advisories filed against them. Luckily,
> we can upgrade to versions where they are fixed.
>
> The upgrade of rollup-plugin-terser includes the upgrade to Terser 5.
> Looking at its changelog (https://github.com/terser/terser/blob/master/CHANGELOG.md#v500-beta0)
> we seem to not be affected. Our build also works as expected.
>
> DISABLE_THIRD_PARTY_CHECK=Update node modules
> R=​petermarshall@chromium.org
>
> Change-Id: I6974a73d92a1a210b705246053be5c2af268605b
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2372148
> Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
> Commit-Queue: Peter Marshall <petermarshall@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
TBR=petermarshall@chromium.org,tvanderlippe@chromium.org
Change-Id: I969ca281c77d299038332f93ffd477925e191073
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2374207
Reviewed-by: Wolfgang Beyer <wolfi@chromium.org>
Commit-Queue: Wolfgang Beyer <wolfi@chromium.org>
diff --git a/node_modules/serialize-javascript/index.js b/node_modules/serialize-javascript/index.js
index cf14df4..3594167 100644
--- a/node_modules/serialize-javascript/index.js
+++ b/node_modules/serialize-javascript/index.js
@@ -6,12 +6,9 @@
'use strict';
-var randomBytes = require('randombytes');
-
// Generate an internal UID to make the regexp pattern harder to guess.
-var UID_LENGTH = 16;
-var UID = generateUID();
-var PLACE_HOLDER_REGEXP = new RegExp('(\\\\)?"@__(F|R|D|M|S|U|I|B)-' + UID + '-(\\d+)__@"', 'g');
+var UID = Math.floor(Math.random() * 0x10000000000).toString(16);
+var PLACE_HOLDER_REGEXP = new RegExp('"@__(F|R|D|M|S|U)-' + UID + '-(\\d+)__@"', 'g');
var IS_NATIVE_CODE_REGEXP = /\{\s*\[native code\]\s*\}/g;
var IS_PURE_FUNCTION = /function.*?\(/;
@@ -34,15 +31,6 @@
return ESCAPED_CHARS[unsafeChar];
}
-function generateUID() {
- var bytes = randomBytes(UID_LENGTH);
- var result = '';
- for(var i=0; i<UID_LENGTH; ++i) {
- result += bytes[i].toString(16);
- }
- return result;
-}
-
function deleteFunctions(obj){
var functionKeys = [];
for (var key in obj) {
@@ -69,8 +57,6 @@
var maps = [];
var sets = [];
var undefs = [];
- var infinities= [];
- var bigInts = [];
// Returns placeholders for functions and regexps (identified by index)
// which are later replaced by their string representation.
@@ -116,14 +102,6 @@
return '@__U-' + UID + '-' + (undefs.push(origValue) - 1) + '__@';
}
- if (type === 'number' && !isNaN(origValue) && !isFinite(origValue)) {
- return '@__I-' + UID + '-' + (infinities.push(origValue) - 1) + '__@';
- }
-
- if (type === 'bigint') {
- return '@__B-' + UID + '-' + (bigInts.push(origValue) - 1) + '__@';
- }
-
return value;
}
@@ -197,21 +175,14 @@
str = str.replace(UNSAFE_CHARS_REGEXP, escapeUnsafeChars);
}
- if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && undefs.length === 0 && infinities.length === 0 && bigInts.length === 0) {
+ if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && undefs.length === 0) {
return str;
}
// Replaces all occurrences of function, regexp, date, map and set placeholders in the
// JSON string with their string representations. If the original value can
// not be found, then `undefined` is used.
- return str.replace(PLACE_HOLDER_REGEXP, function (match, backSlash, type, valueIndex) {
- // The placeholder may not be preceded by a backslash. This is to prevent
- // replacing things like `"a\"@__R-<UID>-0__@"` and thus outputting
- // invalid JS.
- if (backSlash) {
- return match;
- }
-
+ return str.replace(PLACE_HOLDER_REGEXP, function (match, type, valueIndex) {
if (type === 'D') {
return "new Date(\"" + dates[valueIndex].toISOString() + "\")";
}
@@ -232,14 +203,6 @@
return 'undefined'
}
- if (type === 'I') {
- return infinities[valueIndex];
- }
-
- if (type === 'B') {
- return "BigInt(\"" + bigInts[valueIndex] + "\")";
- }
-
var fn = functions[valueIndex];
return serializeFunc(fn);