Index: test/intl/overrides/security.js |
diff --git a/src/extensions/i18n/i18n-extension.h b/test/intl/overrides/security.js |
similarity index 65% |
copy from src/extensions/i18n/i18n-extension.h |
copy to test/intl/overrides/security.js |
index 050c336a67a21fd6cb32892e14215cac11971111..c6bbc3a5bbe0b99e4569062d540efd20aaa9ebad 100644 |
--- a/src/extensions/i18n/i18n-extension.h |
+++ b/test/intl/overrides/security.js |
@@ -26,26 +26,26 @@ |
// 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_ |
+// Test that we always use original Intl.Constructors for toLocaleString calls. |
-#include "v8.h" |
+function throwError() { |
+ throw new Error('Malicious method invoked.'); |
+} |
-namespace v8_i18n { |
+Intl.Collator = Intl.NumberFormat = Intl.DateTimeFormat = throwError; |
-class Extension : public v8::Extension { |
- public: |
- Extension(); |
+Intl.Collator.prototype.compare = throwError; |
+Intl.NumberFormat.prototype.format = throwError; |
+Intl.DateTimeFormat.prototype.format = throwError; |
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
- v8::Handle<v8::String> name); |
+// Make sure constructors actually throw now. |
+assertThrows('new Intl.Collator()'); |
+assertThrows('new Intl.NumberFormat()'); |
+assertThrows('new Intl.DateTimeFormat()'); |
- static void Register(); |
- |
- private: |
- static Extension* extension_; |
-}; |
- |
-} // namespace v8_i18n |
- |
-#endif // V8_EXTENSIONS_I18N_I18N_EXTENSION_H_ |
+// None of these should throw. |
+assertDoesNotThrow('new Date().toLocaleString()'); |
+assertDoesNotThrow('new Date().toLocaleDateString()'); |
+assertDoesNotThrow('new Date().toLocaleTimeString()'); |
+assertDoesNotThrow('new Number(12345.412).toLocaleString()'); |
+assertDoesNotThrow('new String(\'abc\').localeCompare(\'bcd\')'); |