Bug 1782661 - [devtools] Update json5 vendored library to v2.2.1 r=nchevobbe

Compare https://github.com/json5/json5/compare/v2.1.0%E2%80%A6v2.2.1

Differential Revision: https://phabricator.services.mozilla.com/D153602
This commit is contained in:
Julian Descottes 2022-08-03 16:20:53 +00:00
Родитель cb388313e1
Коммит 74ce47ded5
4 изменённых файлов: 33 добавлений и 18 удалений

Просмотреть файл

@ -122,6 +122,7 @@ const testCases = [
[{ name: "ls3", value: "http://foobar.com/baz.php", dontMatch: true }],
true,
],
["ls4", [{ name: "ls4", value: "0x1" }], false],
[["sessionStorage", "https://test1.example.org"]],
["ss1", [{ name: "ss1", value: "This#is#an#array" }]],
[
@ -240,14 +241,21 @@ add_task(async function() {
for (const item of testCases) {
info("clicking for item " + item);
const [path, ruleArray, parsed] = item;
const start = performance.now();
if (Array.isArray(item[0])) {
await selectTreeItem(item[0]);
if (Array.isArray(path)) {
await selectTreeItem(path);
continue;
} else if (item[0]) {
await selectTableItem(item[0]);
} else if (path) {
await selectTableItem(path);
}
await findVariableViewProperties(item[1], item[2]);
// Parsing "0x1" used to be very slow and memory intensive.
// Check that each test case completes in less than 15000ms.
const time = performance.now() - start;
ok(time < 15000, `item ${item} completed in less than 15000ms ${time}`);
await findVariableViewProperties(ruleArray, parsed);
}
});

Просмотреть файл

@ -31,6 +31,7 @@ localStorage.setItem("ls1", JSON.stringify({
}]}));
localStorage.setItem("ls2", "foobar-2");
localStorage.setItem("ls3", "http://foobar.com/baz.php");
localStorage.setItem("ls4", "0x1");
// ... and finally some session storage items too
sessionStorage.setItem("ss1", "This#is#an#array");
sessionStorage.setItem("ss2", "This~is~another~array");

Просмотреть файл

@ -9,7 +9,7 @@
```bash
git clone https://github.com/json5/json5
cd json5
git checkout v2.1.0 # checkout the right version tag
git checkout v2.2.1 # checkout the right version tag
```
## Building
@ -26,11 +26,11 @@ cp dist/index.js <gecko-dev>/devtools/shared/storage/vendor/json5.js
- Add the version number to the top of the file:
```
/**
* json5 v2.1.0
* json5 v2.2.1
*/
```
- Replace instances of `Function('return this')()` with `globalThis`. See Bug 1473549.
## Update the version:
The current version is 2.1.0. Update this version number everywhere in this file.
The current version is 2.2.1. Update this version number everywhere in this file.

26
devtools/shared/storage/vendor/json5.js поставляемый
Просмотреть файл

@ -1,5 +1,5 @@
/**
* json5 v2.1.0
* json5 v2.2.1
*/
(function (global, factory) {
@ -15,7 +15,8 @@
var _global = createCommonjsModule(function (module) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self : globalThis;
? window : typeof self != 'undefined' && self.Math == Math ? self
: globalThis;
if (typeof __g == 'number') { __g = global; } // eslint-disable-line no-undef
});
@ -314,11 +315,11 @@
var util = {
isSpaceSeparator: function isSpaceSeparator (c) {
return unicode.Space_Separator.test(c)
return typeof c === 'string' && unicode.Space_Separator.test(c)
},
isIdStartChar: function isIdStartChar (c) {
return (
return typeof c === 'string' && (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c === '$') || (c === '_') ||
@ -327,7 +328,7 @@
},
isIdContinueChar: function isIdContinueChar (c) {
return (
return typeof c === 'string' && (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
@ -338,11 +339,11 @@
},
isDigit: function isDigit (c) {
return /[0-9]/.test(c)
return typeof c === 'string' && /[0-9]/.test(c)
},
isHexDigit: function isHexDigit (c) {
return /[0-9A-Fa-f]/.test(c)
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
},
};
@ -1560,15 +1561,20 @@
var product = '';
for (var i = 0, list = value; i < list.length; i += 1) {
var c = list[i];
for (var i = 0; i < value.length; i++) {
var c = value[i];
switch (c) {
case "'":
case '"':
quotes[c]++;
product += c;
continue
case '\0':
if (util.isDigit(value[i + 1])) {
product += '\\x00';
continue
}
}
if (replacements[c]) {