From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../from/wrap-functions-on-other-global.js | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 js/src/tests/non262/Iterator/from/wrap-functions-on-other-global.js (limited to 'js/src/tests/non262/Iterator/from/wrap-functions-on-other-global.js') diff --git a/js/src/tests/non262/Iterator/from/wrap-functions-on-other-global.js b/js/src/tests/non262/Iterator/from/wrap-functions-on-other-global.js new file mode 100644 index 0000000000..186e4e62d0 --- /dev/null +++ b/js/src/tests/non262/Iterator/from/wrap-functions-on-other-global.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Iterator')) + +class TestError extends Error {} + +function checkIterResult({done, value}, expectedDone, expectedValue) { + assertEq(done, expectedDone); + assertEq(value, expectedValue); +} + +const iter = { + next(value) { + return {done: false, value: arguments.length}; + }, + return() { + throw new TestError(); + }, + throw: (value) => ({done: true, value}), +}; +const thisWrap = Iterator.from(iter); +const otherGlobal = newGlobal({newCompartment: true}); +const otherWrap = otherGlobal.Iterator.from(iter); + +checkIterResult(thisWrap.next.call(otherWrap), false, 0); +checkIterResult(thisWrap.next.call(otherWrap, 'value'), false, 1); + +assertThrowsInstanceOf(thisWrap.return.bind(otherWrap), TestError); + +checkIterResult(thisWrap.throw.call(otherWrap, 'value'), true, 'value'); + +if (typeof reportCompare === 'function') + reportCompare(0, 0); -- cgit v1.2.3