Bug 824312 - Drop support for JSVersion <= 1.5. r=waldo
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Thu, 03 Jan 2013 13:56:13 +0900
changeset 126519 c5e54ecc16014f06a78d4b5db889566f5e95b019
parent 126518 fdc11970821514bc9040f202cc99650ee087b55c
child 126520 d436c91b52c59611ba83ff5fad22f0244a3bea7b
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs824312
milestone20.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 824312 - Drop support for JSVersion <= 1.5. r=waldo
content/base/src/nsContentUtils.cpp
js/src/jsapi-tests/testVersion.cpp
js/src/jsapi.cpp
js/src/jspubtd.h
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -775,30 +775,24 @@ nsContentUtils::GetPseudoAttributeValue(
 
 bool
 nsContentUtils::IsJavaScriptLanguage(const nsString& aName, uint32_t *aFlags)
 {
   JSVersion version = JSVERSION_UNKNOWN;
 
   if (aName.LowerCaseEqualsLiteral("javascript") ||
       aName.LowerCaseEqualsLiteral("livescript") ||
-      aName.LowerCaseEqualsLiteral("mocha")) {
+      aName.LowerCaseEqualsLiteral("mocha") ||
+      aName.LowerCaseEqualsLiteral("javascript1.0") ||
+      aName.LowerCaseEqualsLiteral("javascript1.1") ||
+      aName.LowerCaseEqualsLiteral("javascript1.2") ||
+      aName.LowerCaseEqualsLiteral("javascript1.3") ||
+      aName.LowerCaseEqualsLiteral("javascript1.4") ||
+      aName.LowerCaseEqualsLiteral("javascript1.5")) {
     version = JSVERSION_DEFAULT;
-  } else if (aName.LowerCaseEqualsLiteral("javascript1.0")) {
-    version = JSVERSION_1_0;
-  } else if (aName.LowerCaseEqualsLiteral("javascript1.1")) {
-    version = JSVERSION_1_1;
-  } else if (aName.LowerCaseEqualsLiteral("javascript1.2")) {
-    version = JSVERSION_1_2;
-  } else if (aName.LowerCaseEqualsLiteral("javascript1.3")) {
-    version = JSVERSION_1_3;
-  } else if (aName.LowerCaseEqualsLiteral("javascript1.4")) {
-    version = JSVERSION_1_4;
-  } else if (aName.LowerCaseEqualsLiteral("javascript1.5")) {
-    version = JSVERSION_1_5;
   } else if (aName.LowerCaseEqualsLiteral("javascript1.6")) {
     version = JSVERSION_1_6;
   } else if (aName.LowerCaseEqualsLiteral("javascript1.7")) {
     version = JSVERSION_1_7;
   } else if (aName.LowerCaseEqualsLiteral("javascript1.8")) {
     version = JSVERSION_1_8;
   }
 
@@ -813,22 +807,22 @@ JSVersion
 nsContentUtils::ParseJavascriptVersion(const nsAString& aVersionStr)
 {
   if (aVersionStr.Length() != 3 || aVersionStr[0] != '1' ||
       aVersionStr[1] != '.') {
     return JSVERSION_UNKNOWN;
   }
 
   switch (aVersionStr[2]) {
-  case '0': return JSVERSION_1_0;
-  case '1': return JSVERSION_1_1;
-  case '2': return JSVERSION_1_2;
-  case '3': return JSVERSION_1_3;
-  case '4': return JSVERSION_1_4;
-  case '5': return JSVERSION_1_5;
+  case '0': /* fall through */
+  case '1': /* fall through */
+  case '2': /* fall through */
+  case '3': /* fall through */
+  case '4': /* fall through */
+  case '5': return JSVERSION_DEFAULT;
   case '6': return JSVERSION_1_6;
   case '7': return JSVERSION_1_7;
   case '8': return JSVERSION_1_8;
   default:  return JSVERSION_UNKNOWN;
   }
 }
 
 void
--- a/js/src/jsapi-tests/testVersion.cpp
+++ b/js/src/jsapi-tests/testVersion.cpp
@@ -19,17 +19,17 @@ struct VersionFixture;
  */
 
 static VersionFixture *callbackData = NULL;
 
 JSBool CheckVersionHasMoarXML(JSContext *cx, unsigned argc, jsval *vp);
 JSBool DisableMoarXMLOption(JSContext *cx, unsigned argc, jsval *vp);
 JSBool CallSetVersion17(JSContext *cx, unsigned argc, jsval *vp);
 JSBool CheckNewScriptNoXML(JSContext *cx, unsigned argc, jsval *vp);
-JSBool OverrideVersion15(JSContext *cx, unsigned argc, jsval *vp);
+JSBool OverrideVersion18(JSContext *cx, unsigned argc, jsval *vp);
 JSBool CaptureVersion(JSContext *cx, unsigned argc, jsval *vp);
 JSBool CheckOverride(JSContext *cx, unsigned argc, jsval *vp);
 JSBool EvalScriptVersion16(JSContext *cx, unsigned argc, jsval *vp);
 
 struct VersionFixture : public JSAPITest
 {
     JSVersion captured;
 
@@ -39,17 +39,17 @@ struct VersionFixture : public JSAPITest
         JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_ALLOW_XML);
         callbackData = this;
         captured = JSVERSION_UNKNOWN;
         js::RootedObject global(cx, JS_GetGlobalObject(cx));
         return JS_DefineFunction(cx, global, "checkVersionHasMoarXML", CheckVersionHasMoarXML, 0, 0) &&
                JS_DefineFunction(cx, global, "disableMoarXMLOption", DisableMoarXMLOption, 0, 0) &&
                JS_DefineFunction(cx, global, "callSetVersion17", CallSetVersion17, 0, 0) &&
                JS_DefineFunction(cx, global, "checkNewScriptNoXML", CheckNewScriptNoXML, 0, 0) &&
-               JS_DefineFunction(cx, global, "overrideVersion15", OverrideVersion15, 0, 0) &&
+               JS_DefineFunction(cx, global, "overrideVersion18", OverrideVersion18, 0, 0) &&
                JS_DefineFunction(cx, global, "captureVersion", CaptureVersion, 0, 0) &&
                JS_DefineFunction(cx, global, "checkOverride", CheckOverride, 1, 0) &&
                JS_DefineFunction(cx, global, "evalScriptVersion16",
                                  EvalScriptVersion16, 0, 0);
     }
 
     JSScript *fakeScript(const char *contents, size_t length) {
         js::RootedObject global(cx, JS_GetGlobalObject(cx));
@@ -144,19 +144,19 @@ DisableMoarXMLOption(JSContext *cx, unsi
 
 JSBool
 CheckNewScriptNoXML(JSContext *cx, unsigned argc, jsval *vp)
 {
     return callbackData->checkNewScriptNoXML();
 }
 
 JSBool
-OverrideVersion15(JSContext *cx, unsigned argc, jsval *vp)
+OverrideVersion18(JSContext *cx, unsigned argc, jsval *vp)
 {
-    if (!callbackData->setVersion(JSVERSION_1_5))
+    if (!callbackData->setVersion(JSVERSION_1_8))
         return false;
     return callbackData->checkVersionIsOverridden();
 }
 
 JSBool
 EvalScriptVersion16(JSContext *cx, unsigned argc, jsval *vp)
 {
     JS_ASSERT(argc == 1);
@@ -216,59 +216,59 @@ END_FIXTURE_TEST(VersionFixture, testVer
 /*
  * When re-entering the virtual machine through a *Version API the version
  * is no longer forced -- it continues with its natural push/pop oriented
  * version progression.  This is maintained by the |AutoVersionAPI| class in
  * jsapi.cpp.
  */
 BEGIN_FIXTURE_TEST(VersionFixture, testVersion_EntryLosesOverride)
 {
-    EXEC("overrideVersion15(); evalScriptVersion16('checkOverride(false); captureVersion()');");
+    EXEC("overrideVersion18(); evalScriptVersion16('checkOverride(false); captureVersion()');");
     CHECK_EQUAL(captured, JSVERSION_1_6);
 
     /*
      * Override gets propagated to default version as non-override when you leave the VM's execute
      * call.
      */
-    CHECK_EQUAL(JS_GetVersion(cx), JSVERSION_1_5);
+    CHECK_EQUAL(JS_GetVersion(cx), JSVERSION_1_8);
     CHECK(!cx->isVersionOverridden());
     return true;
 }
 END_FIXTURE_TEST(VersionFixture, testVersion_EntryLosesOverride)
 
 /*
  * EvalScriptVersion does not propagate overrides to its caller, it
  * restores things exactly as they were before the call. This is as opposed to
  * the normal (no Version suffix) API which propagates overrides
  * to the caller.
  */
 BEGIN_FIXTURE_TEST(VersionFixture, testVersion_ReturnLosesOverride)
 {
     CHECK_EQUAL(JS_GetVersion(cx), JSVERSION_ECMA_5);
     EXEC(
         "checkOverride(false);"
-        "evalScriptVersion16('overrideVersion15();');"
+        "evalScriptVersion16('overrideVersion18();');"
         "checkOverride(false);"
         "captureVersion();"
     );
     CHECK_EQUAL(captured, JSVERSION_ECMA_5);
     return true;
 }
 END_FIXTURE_TEST(VersionFixture, testVersion_ReturnLosesOverride)
 
 BEGIN_FIXTURE_TEST(VersionFixture, testVersion_EvalPropagatesOverride)
 {
     CHECK_EQUAL(JS_GetVersion(cx), JSVERSION_ECMA_5);
     EXEC(
         "checkOverride(false);"
-        "eval('overrideVersion15();');"
+        "eval('overrideVersion18();');"
         "checkOverride(true);"
         "captureVersion();"
     );
-    CHECK_EQUAL(captured, JSVERSION_1_5);
+    CHECK_EQUAL(captured, JSVERSION_1_8);
     return true;
 }
 END_FIXTURE_TEST(VersionFixture, testVersion_EvalPropagatesOverride)
 
 BEGIN_TEST(testVersion_AllowXML)
 {
     JSBool ok;
 
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1312,42 +1312,38 @@ JS_SetVersion(JSContext *cx, JSVersion n
 #ifdef DEBUG
     unsigned coptsBefore = cx->getCompileOptions();
 #endif
     JSVersion oldVersion = cx->findVersion();
     JSVersion oldVersionNumber = VersionNumber(oldVersion);
     if (oldVersionNumber == newVersionNumber)
         return oldVersionNumber; /* No override actually occurs! */
 
-    /* We no longer support 1.4 or below. */
-    if (newVersionNumber != JSVERSION_DEFAULT && newVersionNumber <= JSVERSION_1_4)
-        return oldVersionNumber;
-
     VersionCopyFlags(&newVersion, oldVersion);
     cx->maybeOverrideVersion(newVersion);
     JS_ASSERT(cx->getCompileOptions() == coptsBefore);
     return oldVersionNumber;
 }
 
 static struct v2smap {
     JSVersion   version;
     const char  *string;
 } v2smap[] = {
-    {JSVERSION_1_0,     "1.0"},
-    {JSVERSION_1_1,     "1.1"},
-    {JSVERSION_1_2,     "1.2"},
-    {JSVERSION_1_3,     "1.3"},
-    {JSVERSION_1_4,     "1.4"},
     {JSVERSION_ECMA_3,  "ECMAv3"},
-    {JSVERSION_1_5,     "1.5"},
     {JSVERSION_1_6,     "1.6"},
     {JSVERSION_1_7,     "1.7"},
     {JSVERSION_1_8,     "1.8"},
     {JSVERSION_ECMA_5,  "ECMAv5"},
     {JSVERSION_DEFAULT, js_default_str},
+    {JSVERSION_DEFAULT, "1.0"},
+    {JSVERSION_DEFAULT, "1.1"},
+    {JSVERSION_DEFAULT, "1.2"},
+    {JSVERSION_DEFAULT, "1.3"},
+    {JSVERSION_DEFAULT, "1.4"},
+    {JSVERSION_DEFAULT, "1.5"},
     {JSVERSION_UNKNOWN, NULL},          /* must be last, NULL is sentinel */
 };
 
 JS_PUBLIC_API(const char *)
 JS_VersionToString(JSVersion version)
 {
     int i;
 
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -67,35 +67,26 @@ typedef uint16_t  jschar;
 #endif
 
 /*
  * Run-time version enumeration.  See jsversion.h for compile-time counterparts
  * to these values that may be selected by the JS_VERSION macro, and tested by
  * #if expressions.
  */
 typedef enum JSVersion {
-    JSVERSION_1_0     = 100,
-    JSVERSION_1_1     = 110,
-    JSVERSION_1_2     = 120,
-    JSVERSION_1_3     = 130,
-    JSVERSION_1_4     = 140,
     JSVERSION_ECMA_3  = 148,
-    JSVERSION_1_5     = 150,
     JSVERSION_1_6     = 160,
     JSVERSION_1_7     = 170,
     JSVERSION_1_8     = 180,
     JSVERSION_ECMA_5  = 185,
     JSVERSION_DEFAULT = 0,
     JSVERSION_UNKNOWN = -1,
     JSVERSION_LATEST  = JSVERSION_ECMA_5
 } JSVersion;
 
-#define JSVERSION_IS_ECMA(version) \
-    ((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3)
-
 /* Result of typeof operator enumeration. */
 typedef enum JSType {
     JSTYPE_VOID,                /* undefined */
     JSTYPE_OBJECT,              /* object */
     JSTYPE_FUNCTION,            /* function */
     JSTYPE_STRING,              /* string */
     JSTYPE_NUMBER,              /* number */
     JSTYPE_BOOLEAN,             /* boolean */