diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /js/src/tests/non262 | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262')
-rw-r--r-- | js/src/tests/non262/Date/parse-day-of-week.js | 2 | ||||
-rw-r--r-- | js/src/tests/non262/Iterator/proto.js | 9 | ||||
-rw-r--r-- | js/src/tests/non262/JSON/parse-with-source.js | 112 | ||||
-rw-r--r-- | js/src/tests/non262/PrivateName/nested-class-in-computed-property-key.js | 17 | ||||
-rw-r--r-- | js/src/tests/non262/module/bug1689499.js | 2 |
5 files changed, 103 insertions, 39 deletions
diff --git a/js/src/tests/non262/Date/parse-day-of-week.js b/js/src/tests/non262/Date/parse-day-of-week.js index 08bcd3ee05..52a8c6339a 100644 --- a/js/src/tests/non262/Date/parse-day-of-week.js +++ b/js/src/tests/non262/Date/parse-day-of-week.js @@ -63,6 +63,8 @@ const rejected = [ "Sep 26 1995 foo", "1995 foo Sep 26", "foo2 Sep 26 1995", + "Tuesday_Sep 26 1995", + "foo_12", ]; for (const format of formats) { diff --git a/js/src/tests/non262/Iterator/proto.js b/js/src/tests/non262/Iterator/proto.js index 642e48d171..5b32f5d34b 100644 --- a/js/src/tests/non262/Iterator/proto.js +++ b/js/src/tests/non262/Iterator/proto.js @@ -10,14 +10,5 @@ assertEq(propDesc.writable, false); assertEq(propDesc.enumerable, false); assertEq(propDesc.configurable, false); -// Make sure @@toStringTag has been set. -const toStringTagDesc = Reflect.getOwnPropertyDescriptor(Iterator.prototype, Symbol.toStringTag); -assertDeepEq(toStringTagDesc, { - value: "Iterator", - writable: true, - enumerable: false, - configurable: true, -}); - if (typeof reportCompare === 'function') reportCompare(0, 0); diff --git a/js/src/tests/non262/JSON/parse-with-source.js b/js/src/tests/non262/JSON/parse-with-source.js index 96e9550706..5e144bd6a4 100644 --- a/js/src/tests/non262/JSON/parse-with-source.js +++ b/js/src/tests/non262/JSON/parse-with-source.js @@ -1,49 +1,103 @@ -// |reftest| skip-if(!(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('json-parse-with-source'))) shell-option(--enable-json-parse-with-source) +// |reftest| shell-option(--enable-json-parse-with-source) skip-if(!JSON.hasOwnProperty('isRawJSON')||!xulRuntime.shell) var actual; function reviver(key, value, context) { assertEq(arguments.length, 3); - assertEq("source" in context, true); - actual = context["source"]; + if ("source" in context) { + actual.push(context["source"]); + } else { // objects and arrays have no "source" + actual.push(null); + } } let tests = [ // STRINGS - {input: '""', expected: '""'}, - {input: '"str"', expected: '"str"'}, - {input: '"str" ', expected: '"str"'}, - {input: ' "str" ', expected: '"str"'}, - {input: ' " str"', expected: '" str"'}, - {input: '"\uD83D\uDE0A\u2764\u2FC1"', expected: '"\uD83D\uDE0A\u2764\u2FC1"'}, + {input: '""', expected: ['""']}, + {input: '"str"', expected: ['"str"']}, + {input: '"str" ', expected: ['"str"']}, + {input: ' "str" ', expected: ['"str"']}, + {input: ' " str"', expected: ['" str"']}, + {input: '"\uD83D\uDE0A\u2764\u2FC1"', expected: ['"\uD83D\uDE0A\u2764\u2FC1"']}, // NUMBERS - {input: '1', expected: '1'}, - {input: ' 1', expected: '1'}, - {input: '4.2', expected: '4.2'}, - {input: '4.2 ', expected: '4.2'}, - {input: '4.2000 ', expected: '4.2000'}, - {input: '4e2000 ', expected: '4e2000'}, - {input: '4.4e2000 ', expected: '4.4e2000'}, - {input: '9007199254740999', expected: '9007199254740999'}, - {input: '-31', expected: '-31'}, - {input: '-3.1', expected: '-3.1'}, - {input: ' -31 ', expected: '-31'}, + {input: '1', expected: ['1']}, + {input: ' 1', expected: ['1']}, + {input: '4.2', expected: ['4.2']}, + {input: '4.2 ', expected: ['4.2']}, + {input: '4.2000 ', expected: ['4.2000']}, + {input: '4e2000 ', expected: ['4e2000']}, + {input: '4.4e2000 ', expected: ['4.4e2000']}, + {input: '9007199254740999', expected: ['9007199254740999']}, + {input: '-31', expected: ['-31']}, + {input: '-3.1', expected: ['-3.1']}, + {input: ' -31 ', expected: ['-31']}, // BOOLEANS - {input: 'true', expected: 'true'}, - {input: 'true ', expected: 'true'}, - {input: 'false', expected: 'false'}, - {input: ' false', expected: 'false'}, + {input: 'true', expected: ['true']}, + {input: 'true ', expected: ['true']}, + {input: 'false', expected: ['false']}, + {input: ' false', expected: ['false']}, // NULL - {input: 'null', expected: 'null'}, - {input: ' null', expected: 'null'}, - {input: '\tnull ', expected: 'null'}, - {input: 'null\t', expected: 'null'}, + {input: 'null', expected: ['null']}, + {input: ' null', expected: ['null']}, + {input: '\tnull ', expected: ['null']}, + {input: 'null\t', expected: ['null']}, + // OBJECTS + {input: '{ }', expected: [null]}, + {input: '{ "4": 1 }', expected: ['1', null]}, + {input: '{ "a": 1 }', expected: ['1', null]}, + {input: '{ "b": 2, "a": 1 }', expected: ['2', '1', null]}, + {input: '{ "b": 2, "1": 1 }', expected: ['1', '2', null]}, + {input: '{ "b": 2, "c": null }', expected: ['2', 'null', null]}, + {input: '{ "b": 2, "b": 1, "b": 4 }', expected: ['4', null]}, + {input: '{ "b": 2, "a": "1" }', expected: ['2', '"1"', null]}, + {input: '{ "b": { "c": 3 }, "a": 1 }', expected: ['3', null, '1', null]}, + // ARRAYS + {input: '[]', expected: [null]}, + {input: '[1, 5, 2]', expected: ['1', '5', '2', null]}, + {input: '[1, null, 2]', expected: ['1', 'null', '2', null]}, + {input: '[1, {"a":2}, "7"]', expected: ['1', '2', null, '"7"', null]}, + {input: '[1, [2, [3, [4, 5], [6, 7], 8], 9], 10]', expected: ['1', '2', '3', '4', '5', null, '6', '7', null, '8', null, '9', null, '10', null]}, + {input: '[1, [2, [3, [4, 5, 6, 7, 8, 9, 10], []]]]', expected: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', null, null, null, null, null]}, + {input: '{"a": [1, {"b":2}, "7"], "c": 8}', expected: ['1', '2', null, '"7"', null, '8', null]}, ]; for (const test of tests) { print("Testing " + JSON.stringify(test)); + actual = []; JSON.parse(test.input, reviver); - assertEq(actual, test.expected); + assertDeepEq(actual, test.expected); } +// If the constructed object is modified but the result of the modification is +// the same as the original, we should still provide the source +function replace_c_with_same_val(key, value, context) { + if (key === "a") { + this["c"] = "ABCDEABCDE"; + } + if (key) { + assertEq("source" in context, true); + } + return value; +} +JSON.parse('{ "a": "b", "c": "ABCDEABCDE" }', replace_c_with_same_val); + +// rawJSON +function assertIsRawJson(rawJson, expectedRawJsonValue) { + assertEq(null, Object.getPrototypeOf(rawJson)); + assertEq(true, Object.hasOwn(rawJson, 'rawJSON')); + assertDeepEq(['rawJSON'], Object.getOwnPropertyNames(rawJson)); + assertDeepEq([], Object.getOwnPropertySymbols(rawJson)); + assertEq(expectedRawJsonValue, rawJson.rawJSON); +} + +assertEq(true, Object.isFrozen(JSON.rawJSON('"shouldBeFrozen"'))); +assertThrowsInstanceOf(() => JSON.rawJSON(), SyntaxError); +assertIsRawJson(JSON.rawJSON(1, 2), '1'); + +// isRawJSON +assertEq(false, JSON.isRawJSON()); +assertEq(false, JSON.isRawJSON({}, {})); +assertEq(false, JSON.isRawJSON({}, JSON.rawJSON(2))); +assertEq(true, JSON.isRawJSON(JSON.rawJSON(1), JSON.rawJSON(2))); + if (typeof reportCompare == 'function') reportCompare(0, 0);
\ No newline at end of file diff --git a/js/src/tests/non262/PrivateName/nested-class-in-computed-property-key.js b/js/src/tests/non262/PrivateName/nested-class-in-computed-property-key.js new file mode 100644 index 0000000000..7596dfe542 --- /dev/null +++ b/js/src/tests/non262/PrivateName/nested-class-in-computed-property-key.js @@ -0,0 +1,17 @@ +let capturedPrivateAccess; +class A { + // Declare private name in outer class. + static #x = 42; + + static [( + // Inner class in computed property key. + class {}, + + // Access to private name from outer class. + capturedPrivateAccess = () => A.#x + )]; +} +assertEq(capturedPrivateAccess(), 42); + +if (typeof reportCompare === 'function') + reportCompare(0, 0); diff --git a/js/src/tests/non262/module/bug1689499.js b/js/src/tests/non262/module/bug1689499.js index 859cd6f64f..2547c88d16 100644 --- a/js/src/tests/non262/module/bug1689499.js +++ b/js/src/tests/non262/module/bug1689499.js @@ -1,4 +1,4 @@ -// |reftest| skip-if(!xulRuntime.shell) module async -- needs drainJobQueue +// |reftest| skip-if(!xulRuntime.shell) async -- needs drainJobQueue async function test() { try { |