Bug 1103181 - Remove String.prototype.quote. r=jorendorff
authorTom Schuster <evilpies@gmail.com>
Fri, 05 Dec 2014 11:07:15 -0800
changeset 218546 7794fca7bda8db1c1b9bc7452e086c3dbe6b25d1
parent 218545 73e43148a51bf1a892fd71b7715eaeb09107d8b0
child 218547 3bdce03e9ec0f61ad050888076704fe7e2462f11
push id27934
push userryanvm@gmail.com
push dateSat, 06 Dec 2014 00:03:14 +0000
treeherdermozilla-central@6aeb84ed920d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1103181
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1103181 - Remove String.prototype.quote. r=jorendorff
js/src/jit-test/tests/latin1/quote.js
js/src/jsstr.cpp
js/src/tests/js1_5/Regress/regress-315974.js
js/src/tests/js1_6/extensions/regress-312385-01.js
js/src/tests/js1_8_5/extensions/shell.js
deleted file mode 100644
--- a/js/src/jit-test/tests/latin1/quote.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var s = 'Abc1234"\'\t987\u00ff';
-assertEq(isLatin1(s), true);
-assertEq(s.toSource(), '(new String("Abc1234\\"\'\\t987\\xFF"))');
-var res = s.quote();
-assertEq(res, '"Abc1234\\"\'\\t987\\xFF"');
-assertEq(isLatin1(res), true);
-
-s = 'Abc1234"\'\t\u1200987\u00ff';
-assertEq(isLatin1(s), false);
-assertEq(s.toSource(), '(new String("Abc1234\\"\'\\t\\u1200987\\xFF"))');
-assertEq(s.quote(), '"Abc1234\\"\'\\t\\u1200987\\xFF"');
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -477,34 +477,16 @@ ThisToStringForStringProto(JSContext *cx
 MOZ_ALWAYS_INLINE bool
 IsString(HandleValue v)
 {
     return v.isString() || (v.isObject() && v.toObject().is<StringObject>());
 }
 
 #if JS_HAS_TOSOURCE
 
-/*
- * String.prototype.quote is generic (as are most string methods), unlike
- * toSource, toString, and valueOf.
- */
-static bool
-str_quote(JSContext *cx, unsigned argc, Value *vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    RootedString str(cx, ThisToStringForStringProto(cx, args));
-    if (!str)
-        return false;
-    str = js_QuoteString(cx, str, '"');
-    if (!str)
-        return false;
-    args.rval().setString(str);
-    return true;
-}
-
 MOZ_ALWAYS_INLINE bool
 str_toSource_impl(JSContext *cx, CallArgs args)
 {
     MOZ_ASSERT(IsString(args.thisv()));
 
     Rooted<JSString*> str(cx, ToString<CanGC>(cx, args.thisv()));
     if (!str)
         return false;
@@ -3971,17 +3953,16 @@ str_concat(JSContext *cx, unsigned argc,
     }
 
     args.rval().setString(str);
     return true;
 }
 
 static const JSFunctionSpec string_methods[] = {
 #if JS_HAS_TOSOURCE
-    JS_FN("quote",             str_quote,             0,JSFUN_GENERIC_NATIVE),
     JS_FN(js_toSource_str,     str_toSource,          0,0),
 #endif
 
     /* Java-like methods. */
     JS_FN(js_toString_str,     js_str_toString,       0,0),
     JS_FN(js_valueOf_str,      js_str_toString,       0,0),
     JS_FN("toLowerCase",       str_toLowerCase,       0,JSFUN_GENERIC_NATIVE),
     JS_FN("toUpperCase",       str_toUpperCase,       0,JSFUN_GENERIC_NATIVE),
deleted file mode 100644
--- a/js/src/tests/js1_5/Regress/regress-315974.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-//-----------------------------------------------------------------------------
-
-/*
-  This test case uses String.quote(), because that method uses the JS printf()
-  functions internally. The printf() functions print to a char* buffer, causing
-  conversion to and from UTF-8 if UTF-8 is enabled. If not, UTF-8 sequences are
-  converted to ASCII \uXXXX sequences. Thus, both return values are acceptable.
-*/
-
-var BUGNUMBER = 315974;
-var summary = 'Test internal printf() for wide characters';
-
-printBugNumber(BUGNUMBER);
-printStatus (summary);
-
-enterFunc (String (BUGNUMBER));
-
-var goodSurrogatePair = '\uD841\uDC42';
-var badSurrogatePair = '\uD841badbad';
-
-var goodSurrogatePairQuotedUtf8 = '"\uD841\uDC42"';
-var badSurrogatePairQuotedUtf8 = 'no error thrown!';
-var goodSurrogatePairQuotedNoUtf8 = '"\\uD841\\uDC42"';
-var badSurrogatePairQuotedNoUtf8 = '"\\uD841badbad"';
-
-var status = summary + ': String.quote() should pay respect to surrogate pairs';
-var actual = goodSurrogatePair.quote();
-/* Result in case UTF-8 is enabled. */
-var expect = goodSurrogatePairQuotedUtf8;
-/* Result in case UTF-8 is disabled. */
-if (actual != expect && actual == goodSurrogatePairQuotedNoUtf8)
-  expect = actual;
-reportCompare(expect, actual, status);
-
-/*
- * A malformed surrogate pair throws an out-of-memory error,
- * but only if UTF-8 is enabled.
- */
-status = summary + ': String.quote() should throw error on bad surrogate pair';
-/* Out of memory is not catchable. */
-actual = badSurrogatePair.quote();
-/* Come here only if UTF-8 is disabled. */
-reportCompare(badSurrogatePairQuotedNoUtf8, actual, status);
-
-exitFunc (String (BUGNUMBER));
--- a/js/src/tests/js1_6/extensions/regress-312385-01.js
+++ b/js/src/tests/js1_6/extensions/regress-312385-01.js
@@ -9,18 +9,17 @@ var summary = 'Generic methods with null
 var actual = '';
 var expect = true;
 var voids = [null, undefined];
 
 
 function noop() { }
 
 var generics = {
-  String: [{ quote: [] },
-{ substring: [] },
+String: [{ substring: [] },
 { toLowerCase: [] },
 { toUpperCase: [] },
 { charAt: [] },
 { charCodeAt: [] },
 { indexOf: [] },
 { lastIndexOf: [] },
 { toLocaleLowerCase: [] },
 { toLocaleUpperCase: [] },
--- a/js/src/tests/js1_8_5/extensions/shell.js
+++ b/js/src/tests/js1_8_5/extensions/shell.js
@@ -108,17 +108,17 @@ var Match =
             if (!(act instanceof RegExp) || exp.source !== act.source)
                 throw new MatchError("expected " + quote(exp) + ", got: " + quote(act));
             return true;
         }
 
         switch (typeof exp) {
         case "string":
             if (act !== exp)
-                throw new MatchError("expected " + exp.quote() + ", got " + quote(act));
+                throw new MatchError("expected " + quote(exp) + ", got " + quote(act));
             return true;
         case "boolean":
         case "number":
             if (exp !== act)
                 throw new MatchError("expected " + exp + ", got " + quote(act));
             return true;
         }
 
@@ -126,17 +126,17 @@ var Match =
     }
 
     function matchObject(act, exp) {
         if (!isObject(act))
             throw new MatchError("expected object, got " + quote(act));
 
         for (var key in exp) {
             if (!(key in act))
-                throw new MatchError("expected property " + key.quote() + " not found in " + quote(act));
+                throw new MatchError("expected property " + quote(key) + " not found in " + quote(act));
             match(act[key], exp[key]);
         }
 
         return true;
     }
 
     function matchFunction(act, exp) {
         if (!isFunction(act))