| Index: test/intl/collator/property-override.js
|
| diff --git a/test/mjsunit/regress/setter.js b/test/intl/collator/property-override.js
|
| similarity index 61%
|
| copy from test/mjsunit/regress/setter.js
|
| copy to test/intl/collator/property-override.js
|
| index e3a8000f2bc55c9ee09c483a1cc421305415b85d..bed4d7773db9630869d5abd965b5c24f543e9f51 100644
|
| --- a/test/mjsunit/regress/setter.js
|
| +++ b/test/intl/collator/property-override.js
|
| @@ -25,42 +25,41 @@
|
| // (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 collator.js and collator.cc so they have the same list of
|
| +// properties.
|
|
|
| -function c(p) {
|
| - return {__proto__: p};
|
| +// First get supported properties.
|
| +var properties = [];
|
| +var options = Intl.Collator().resolvedOptions();
|
| +for (var prop in options) {
|
| + if (options.hasOwnProperty(prop)) {
|
| + properties.push(prop);
|
| + }
|
| }
|
|
|
| -var p = {};
|
| +var expectedProperties = [
|
| + 'caseFirst', 'sensitivity', 'ignorePunctuation',
|
| + 'locale', 'numeric', 'usage', 'collation'
|
| +];
|
|
|
| -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.Collator().resolvedOptions().locale;
|
|
|