diff options
Diffstat (limited to 'src/civetweb/src/third_party/duktape-1.5.2/polyfills/duktape-error-setter-nonwritable.js')
-rw-r--r-- | src/civetweb/src/third_party/duktape-1.5.2/polyfills/duktape-error-setter-nonwritable.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/civetweb/src/third_party/duktape-1.5.2/polyfills/duktape-error-setter-nonwritable.js b/src/civetweb/src/third_party/duktape-1.5.2/polyfills/duktape-error-setter-nonwritable.js new file mode 100644 index 00000000..236c706b --- /dev/null +++ b/src/civetweb/src/third_party/duktape-1.5.2/polyfills/duktape-error-setter-nonwritable.js @@ -0,0 +1,20 @@ +/* + * Ensure Error .fileName, .lineNumber, and .stack are not directly writable, + * but can be written using Object.defineProperty(). This matches Duktape + * 1.3.0 and prior. + * + * See: https://github.com/svaarala/duktape/pull/390. + */ + +(function () { + var err = new Error('test'); + err.fileName = 999; + if (err.fileName !== 999) { return; } // already non-writable + + var fn = new Function(''); // nop + Object.defineProperties(Error.prototype, { + fileName: { set: fn }, + lineNumber: { set: fn }, + stack: { set: fn } + }); +})(); |