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/README.md b/node_modules/serialize-javascript/README.md
index 1339474..810fb57 100644
--- a/node_modules/serialize-javascript/README.md
+++ b/node_modules/serialize-javascript/README.md
@@ -40,20 +40,19 @@
bool : true,
nil : null,
undef: undefined,
- inf : Infinity,
- date : new Date("Thu, 28 Apr 2016 22:02:17 GMT"),
- map : new Map([['hello', 'world']]),
- set : new Set([123, 456]),
- fn : function echo(arg) { return arg; },
- re : /([^\s]+)/g,
- big : BigInt(10),
+ date: new Date("Thu, 28 Apr 2016 22:02:17 GMT"),
+ map: new Map([['hello', 'world']]),
+ set: new Set([123, 456]),
+
+ fn: function echo(arg) { return arg; },
+ re: /([^\s]+)/g
});
```
The above will produce the following string output:
```js
-'{"str":"string","num":0,"obj":{"foo":"foo"},"arr":[1,2,3],"bool":true,"nil":null,"undef":undefined,"inf":Infinity,"date":new Date("2016-04-28T22:02:17.000Z"),"map":new Map([["hello","world"]]),"set":new Set([123,456]),"fn":function echo(arg) { return arg; },"re":new RegExp("([^\\\\s]+)", "g"),"big":BigInt("10")}'
+'{"str":"string","num":0,"obj":{"foo":"foo"},"arr":[1,2,3],"bool":true,"nil":null,"undef":undefined,"date":new Date("2016-04-28T22:02:17.000Z"),"map":new Map([["hello","world"]]),"set":new Set([123,456]),"fn":function echo(arg) { return arg; },"re":/([^\s]+)/g}'
```
Note: to produced a beautified string, you can pass an optional second argument to `serialize()` to define the number of spaces to be used for the indentation.
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);
diff --git a/node_modules/serialize-javascript/package.json b/node_modules/serialize-javascript/package.json
index 4e002d2..ff9959f 100644
--- a/node_modules/serialize-javascript/package.json
+++ b/node_modules/serialize-javascript/package.json
@@ -3,15 +3,12 @@
"bugs": {
"url": "https://github.com/yahoo/serialize-javascript/issues"
},
- "dependencies": {
- "randombytes": "^2.1.0"
- },
"description": "Serialize JavaScript to a superset of JSON that includes regular expressions and functions.",
"devDependencies": {
"benchmark": "^2.1.4",
"chai": "^4.1.0",
- "mocha": "^7.0.0",
- "nyc": "^15.0.0"
+ "mocha": "^6.2.0",
+ "nyc": "^14.1.1"
},
"homepage": "https://github.com/yahoo/serialize-javascript",
"keywords": [
@@ -32,5 +29,5 @@
"benchmark": "node -v && node test/benchmark/serialize.js",
"test": "nyc --reporter=lcov mocha test/unit"
},
- "version": "4.0.0"
+ "version": "2.1.2"
}