| Index: test/intl/date-format/property-override.js
|
| diff --git a/test/mjsunit/regress/setter.js b/test/intl/date-format/property-override.js
|
| similarity index 54%
|
| copy from test/mjsunit/regress/setter.js
|
| copy to test/intl/date-format/property-override.js
|
| index e3a8000f2bc55c9ee09c483a1cc421305415b85d..a2bc2d9a30030d2e80065ad7d686cb3311eb0eaa 100644
|
| --- a/test/mjsunit/regress/setter.js
|
| +++ b/test/intl/date-format/property-override.js
|
| @@ -25,42 +25,46 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -function s(v) {
|
| - v.x = 1;
|
| -}
|
| +// Checks for security holes introduced by Object.property overrides.
|
| +// For example:
|
| +// Object.defineProperty(Array.prototype, 'locale', {
|
| +// set: function(value) {
|
| +// throw new Error('blah');
|
| +// },
|
| +// configurable: true,
|
| +// enumerable: false
|
| +// });
|
| +//
|
| +// would throw in case of (JS) x.locale = 'us' or (C++) x->Set('locale', 'us').
|
| +//
|
| +// Update both date-format.js and date-format.cc so they have the same list of
|
| +// properties.
|
|
|
| -function c(p) {
|
| - return {__proto__: p};
|
| +// First get supported properties.
|
| +// Some of the properties are optional, so we request them.
|
| +var properties = [];
|
| +var options = Intl.DateTimeFormat(
|
| + 'en-US', {weekday: 'short', era: 'short', year: 'numeric', month: 'short',
|
| + day: 'numeric', hour: 'numeric', minute: 'numeric',
|
| + second: 'numeric', timeZoneName: 'short'}).resolvedOptions();
|
| +for (var prop in options) {
|
| + if (options.hasOwnProperty(prop)) {
|
| + properties.push(prop);
|
| + }
|
| }
|
|
|
| -var p = {};
|
| +var expectedProperties = [
|
| + 'calendar', 'day', 'era', 'hour12', 'hour', 'locale',
|
| + 'minute', 'month', 'numberingSystem',
|
| + 'second', 'timeZone', 'timeZoneName', 'weekday', 'year'
|
| +];
|
|
|
| -var o1 = c(p);
|
| -var o2 = c(p);
|
| -var o3 = c(p);
|
| -var o4 = c(p);
|
| -var o5 = c(p);
|
| +assertEquals(expectedProperties.length, properties.length);
|
|
|
| -// Initialize the store IC.
|
| -s(o1);
|
| -s(o2);
|
| -
|
| -// Install a setter on p.x
|
| -var count = 0;
|
| -Object.defineProperty(p, "x", {
|
| - set: function(x) {
|
| - count += 1;
|
| - }
|
| +properties.forEach(function(prop) {
|
| + assertFalse(expectedProperties.indexOf(prop) === -1);
|
| });
|
|
|
| -// Verify that the setter was called directly.
|
| -o3.x = 20;
|
| -assertEquals(1, count);
|
| -
|
| -// Verify that monomorphic prototype failure is triggered in the IC.
|
| -s(o4);
|
| -assertEquals(2, count);
|
| +taintProperties(properties);
|
|
|
| -// Verify that the newly installed IC is correct.
|
| -s(o5);
|
| -assertEquals(3, count);
|
| +var locale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
|