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

Unified Diff: test/intl/collator/property-override.js

Issue 18687003: Import intl test suite from v8-i18n project (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
Index: test/intl/collator/property-override.js
diff --git a/src/extensions/i18n/i18n-extension.h b/test/intl/collator/property-override.js
similarity index 61%
copy from src/extensions/i18n/i18n-extension.h
copy to test/intl/collator/property-override.js
index 050c336a67a21fd6cb32892e14215cac11971111..759a1d5ecc64e700cd76873be2e37205d8ed0855 100644
--- a/src/extensions/i18n/i18n-extension.h
+++ b/test/intl/collator/property-override.js
@@ -26,26 +26,41 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// limitations under the License.
-#ifndef V8_EXTENSIONS_I18N_I18N_EXTENSION_H_
-#define V8_EXTENSIONS_I18N_I18N_EXTENSION_H_
-
-#include "v8.h"
-
-namespace v8_i18n {
+// 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.
-class Extension : public v8::Extension {
- public:
- Extension();
+// First get supported properties.
+var properties = [];
+var options = Intl.Collator().resolvedOptions();
+for (var prop in options) {
+ if (options.hasOwnProperty(prop)) {
+ properties.push(prop);
+ }
+}
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
- v8::Handle<v8::String> name);
+var expectedProperties = [
+ 'caseFirst', 'sensitivity', 'ignorePunctuation',
+ 'locale', 'numeric', 'usage', 'collation'
+];
- static void Register();
+assertEquals(expectedProperties.length, properties.length);
- private:
- static Extension* extension_;
-};
+properties.forEach(function(prop) {
+ assertFalse(expectedProperties.indexOf(prop) === -1);
+});
-} // namespace v8_i18n
+taintProperties(properties);
-#endif // V8_EXTENSIONS_I18N_I18N_EXTENSION_H_
+var locale = Intl.Collator().resolvedOptions().locale;

Powered by Google App Engine
This is Rietveld 408576698