GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add initial pull delay and prototype pollution prevention tests · nodejs/node@17b7ec4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-whatwg-readablestream.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-whatwg-readablestream.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-readablestream.js
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,3 +1701,50 @@ class Source {
17011701
assert.deepStrictEqual(value, new Uint8Array([1, 1, 1]));
17021702
}));
17031703
}
1704+
1705+
// Initial Pull Delay
1706+
{
1707+
const stream = new ReadableStream({
1708+
start(controller) {
1709+
controller.enqueue('data');
1710+
controller.close();
1711+
}
1712+
});
1713+
1714+
const iterator = stream.values();
1715+
1716+
let microtaskCompleted = false;
1717+
Promise.resolve().then(() => { microtaskCompleted = true; });
1718+
1719+
iterator.next().then(common.mustCall(({ done, value }) => {
1720+
assert.strictEqual(done, false);
1721+
assert.strictEqual(value, 'data');
1722+
assert.strictEqual(microtaskCompleted, true);
1723+
}));
1724+
}
1725+
1726+
// Avoiding Prototype Pollution
1727+
{
1728+
const stream = new ReadableStream({
1729+
start(controller) {
1730+
controller.enqueue('data');
1731+
controller.close();
1732+
}
1733+
});
1734+
1735+
const iterator = stream.values();
1736+
1737+
// Modify Promise.prototype.then to simulate prototype pollution
1738+
const originalThen = Promise.prototype.then;
1739+
Promise.prototype.then = function(onFulfilled, onRejected) {
1740+
return originalThen.call(this, onFulfilled, onRejected);
1741+
};
1742+
1743+
iterator.next().then(common.mustCall(({ done, value }) => {
1744+
assert.strictEqual(done, false);
1745+
assert.strictEqual(value, 'data');
1746+
1747+
// Restore original then method
1748+
Promise.prototype.then = originalThen;
1749+
}));
1750+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.