Bug 793781 - Disable String.prototype.contains until MooTools 1.2 is vanquished. r=luke a=akeybl
authorBenjamin Peterson <benjamin@python.org>
Sat, 06 Oct 2012 11:02:10 -0400
changeset 107087 086db97198a8
parent 107086 921ab431cc37
child 107088 ea1910a8ffe4
push id2222
push userbenjamin@python.org
push date2012-10-06 15:02 +0000
Treeherderresults
reviewersluke, akeybl
bugs793781
milestone17.0a2
Bug 793781 - Disable String.prototype.contains until MooTools 1.2 is vanquished. r=luke a=akeybl
js/src/jit-test/tests/basic/string-contains.js
js/src/jsstr.cpp
toolkit/components/places/nsPlacesAutoComplete.js
--- a/js/src/jit-test/tests/basic/string-contains.js
+++ b/js/src/jit-test/tests/basic/string-contains.js
@@ -1,46 +1,47 @@
-assertEq("abc".contains("a"), true);
-assertEq("abc".contains("b"), true);
-assertEq("abc".contains("abc"), true);
-assertEq("abc".contains("bc"), true);
-assertEq("abc".contains("d"), false);
-assertEq("abc".contains("abcd"), false);
-assertEq("abc".contains("ac"), false);
-assertEq("abc".contains("abc", 0), true);
-assertEq("abc".contains("bc", 0), true);
-assertEq("abc".contains("de", 0), false);
-assertEq("abc".contains("bc", 1), true);
-assertEq("abc".contains("c", 1), true);
-assertEq("abc".contains("a", 1), false);
-assertEq("abc".contains("abc", 1), false);
-assertEq("abc".contains("c", 2), true);
-assertEq("abc".contains("d", 2), false);
-assertEq("abc".contains("dcd", 2), false);
-assertEq("abc".contains("a", 42), false);
-assertEq("abc".contains("a", Infinity), false);
-assertEq("abc".contains("ab", -43), true);
-assertEq("abc".contains("cd", -42), false);
-assertEq("abc".contains("ab", -Infinity), true);
-assertEq("abc".contains("cd", -Infinity), false);
-assertEq("abc".contains("ab", NaN), true);
-assertEq("abc".contains("cd", NaN), false);
-var myobj = {toString : (function () "abc"), contains : String.prototype.contains};
-assertEq(myobj.contains("abc"), true);
-assertEq(myobj.contains("cd"), false);
-var gotStr = false, gotPos = false;
-myobj = {toString : (function () {
-    assertEq(gotPos, false);
-    gotStr = true;
-    return "xyz";
-}),
-contains : String.prototype.contains};
-var idx = {valueOf : (function () {
-    assertEq(gotStr, true);
-    gotPos = true;
-    return 42;
-})};
-myobj.contains("elephant", idx);
-assertEq(gotPos, true);
-assertEq("xyzzy".contains("zy\0", 2), false);
-var dots = Array(10000).join('.');
-assertEq(dots.contains("\x01", 10000), false);
-assertEq(dots.contains("\0", 10000), false);
+// Disabled pending bug 789036
+// assertEq("abc".contains("a"), true);
+// assertEq("abc".contains("b"), true);
+// assertEq("abc".contains("abc"), true);
+// assertEq("abc".contains("bc"), true);
+// assertEq("abc".contains("d"), false);
+// assertEq("abc".contains("abcd"), false);
+// assertEq("abc".contains("ac"), false);
+// assertEq("abc".contains("abc", 0), true);
+// assertEq("abc".contains("bc", 0), true);
+// assertEq("abc".contains("de", 0), false);
+// assertEq("abc".contains("bc", 1), true);
+// assertEq("abc".contains("c", 1), true);
+// assertEq("abc".contains("a", 1), false);
+// assertEq("abc".contains("abc", 1), false);
+// assertEq("abc".contains("c", 2), true);
+// assertEq("abc".contains("d", 2), false);
+// assertEq("abc".contains("dcd", 2), false);
+// assertEq("abc".contains("a", 42), false);
+// assertEq("abc".contains("a", Infinity), false);
+// assertEq("abc".contains("ab", -43), true);
+// assertEq("abc".contains("cd", -42), false);
+// assertEq("abc".contains("ab", -Infinity), true);
+// assertEq("abc".contains("cd", -Infinity), false);
+// assertEq("abc".contains("ab", NaN), true);
+// assertEq("abc".contains("cd", NaN), false);
+// var myobj = {toString : (function () "abc"), contains : String.prototype.contains};
+// assertEq(myobj.contains("abc"), true);
+// assertEq(myobj.contains("cd"), false);
+// var gotStr = false, gotPos = false;
+// myobj = {toString : (function () {
+//     assertEq(gotPos, false);
+//     gotStr = true;
+//     return "xyz";
+// }),
+// contains : String.prototype.contains};
+// var idx = {valueOf : (function () {
+//     assertEq(gotStr, true);
+//     gotPos = true;
+//     return 42;
+// })};
+// myobj.contains("elephant", idx);
+// assertEq(gotPos, true);
+// assertEq("xyzzy".contains("zy\0", 2), false);
+// var dots = Array(10000).join('.');
+// assertEq(dots.contains("\x01", 10000), false);
+// assertEq(dots.contains("\0", 10000), false);
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -1123,16 +1123,17 @@ RopeMatch(JSContext *cx, JSString *texts
 
         pos += len;
     }
 
     *match = -1;
     return true;
 }
 
+#if 0
 /* ES6 20120708 draft 15.5.4.24. */
 static JSBool
 str_contains(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     // Steps 1 and 2
     RootedString str(cx, ThisToStringForStringProto(cx, args));
@@ -1168,16 +1169,17 @@ str_contains(JSContext *cx, unsigned arg
     // Step 7
     uint32_t patlen = patstr->length();
     const jschar *pat = patstr->chars();
 
     // Step 8
     args.rval().setBoolean(StringMatch(text, textlen, pat, patlen) >= 0);
     return true;
 }
+#endif
 
 static JSBool
 str_indexOf(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     RootedString str(cx, ThisToStringForStringProto(cx, args));
     if (!str)
         return false;
@@ -3097,17 +3099,19 @@ static JSFunctionSpec string_methods[] =
     /* 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("substring",         str_substring,         2,JSFUN_GENERIC_NATIVE),
     JS_FN("toLowerCase",       str_toLowerCase,       0,JSFUN_GENERIC_NATIVE),
     JS_FN("toUpperCase",       str_toUpperCase,       0,JSFUN_GENERIC_NATIVE),
     JS_FN("charAt",            js_str_charAt,         1,JSFUN_GENERIC_NATIVE),
     JS_FN("charCodeAt",        js_str_charCodeAt,     1,JSFUN_GENERIC_NATIVE),
+#if 0 // See bug 789036
     JS_FN("contains",          str_contains,          1,JSFUN_GENERIC_NATIVE),
+#endif
     JS_FN("indexOf",           str_indexOf,           1,JSFUN_GENERIC_NATIVE),
     JS_FN("lastIndexOf",       str_lastIndexOf,       1,JSFUN_GENERIC_NATIVE),
     JS_FN("startsWith",        str_startsWith,        1,JSFUN_GENERIC_NATIVE),
     JS_FN("endsWith",          str_endsWith,          1,JSFUN_GENERIC_NATIVE),
     JS_FN("trim",              str_trim,              0,JSFUN_GENERIC_NATIVE),
     JS_FN("trimLeft",          str_trimLeft,          0,JSFUN_GENERIC_NATIVE),
     JS_FN("trimRight",         str_trimRight,         0,JSFUN_GENERIC_NATIVE),
     JS_FN("toLocaleLowerCase", str_toLocaleLowerCase, 0,JSFUN_GENERIC_NATIVE),
--- a/toolkit/components/places/nsPlacesAutoComplete.js
+++ b/toolkit/components/places/nsPlacesAutoComplete.js
@@ -1401,17 +1401,17 @@ urlInlineComplete.prototype = {
         query.reset();
       }
 
       if (hasDomainResult) {
         // We got a match for a domain, we can add it immediately.
         // If the untrimmed value doesn't preserve the user's input just
         // ignore it and complete to the found domain.
         if (untrimmedDomain &&
-            !untrimmedDomain.toLowerCase().contains(this._originalSearchString.toLowerCase())) {
+            untrimmedDomain.toLowerCase().indexOf(this._originalSearchString.toLowerCase()) == -1) {
           untrimmedDomain = null;
         }
 
         // TODO (bug 754265): this is a temporary solution introduced while
         // waiting for a propert dedicated API.
         result.appendMatch(this._strippedPrefix + domain, untrimmedDomain);
 
         this._finishSearch();
@@ -1519,17 +1519,17 @@ urlInlineComplete.prototype = {
       url = url.slice(0, separatorIndex);
     }
 
     // Add the result.
     // If the untrimmed value doesn't preserve the user's input just
     // ignore it and complete to the found url.
     let untrimmedURL = prefix + url;
     if (untrimmedURL &&
-        !untrimmedURL.toLowerCase().contains(this._originalSearchString.toLowerCase())) {
+        untrimmedURL.toLowerCase().indexOf(this._originalSearchString.toLowerCase()) == -1) {
       untrimmedURL = null;
      }
 
     // TODO (bug 754265): this is a temporary solution introduced while
     // waiting for a propert dedicated API.
     this._result.appendMatch(this._strippedPrefix + url, untrimmedURL);
 
     // handleCompletion() will cause the result listener to be called, and