Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: test/intl/date-format/property-override.js

Issue 148883002: Synchronize with r15594. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/intl/date-format/parse-mdyhms.js ('k') | test/intl/date-format/protected-icu-internals.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « test/intl/date-format/parse-mdyhms.js ('k') | test/intl/date-format/protected-icu-internals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698