else if (Compare(key, NS_LITERAL_STRING("type"),nsCaseInsensitiveStringComparator()) == 0) {
else if (key.Equals(NS_LITERAL_STRING("type"), nsCaseInsensitiveStringComparator())) {
XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,                               const PRUint32 aLineNumber){  nsresult rv = NS_OK;  PRBool isJavaScript = PR_TRUE;  const char* jsVersionString = nsnull;  // Look for SRC attribute and look for a LANGUAGE attribute  nsAutoString src;  while (*aAttributes) {      const nsDependentString key(aAttributes[0]);      if (Compare(key, NS_LITERAL_STRING("src"),nsCaseInsensitiveStringComparator()) == 0) {          src.Assign(aAttributes[1]);      }      else if (Compare(key, NS_LITERAL_STRING("type"),nsCaseInsensitiveStringComparator()) == 0) {          nsAutoString  type(aAttributes[1]);          nsAutoString  mimeType;          nsAutoString  params;          SplitMimeType(type, mimeType, params);          isJavaScript = mimeType.EqualsIgnoreCase("application/x-javascript") ||                         mimeType.EqualsIgnoreCase("text/javascript");          if (isJavaScript) {              JSVersion jsVersion = JSVERSION_DEFAULT;              if (params.Find("version=", PR_TRUE) == 0) {                  if (params.Length() != 11 || params[8] != '1' || params[9] != '.')                      jsVersion = JSVERSION_UNKNOWN;                  else switch (params[10]) {                      case '0': jsVersion = JSVERSION_1_0; break;                      case '1': jsVersion = JSVERSION_1_1; break;                      case '2': jsVersion = JSVERSION_1_2; break;                      case '3': jsVersion = JSVERSION_1_3; break;                      case '4': jsVersion = JSVERSION_1_4; break;                      case '5': jsVersion = JSVERSION_1_5; break;                      default:  jsVersion = JSVERSION_UNKNOWN;                  }              }              jsVersionString = JS_VersionToString(jsVersion);          }      }      else if (Compare(key, NS_LITERAL_STRING("language"),nsCaseInsensitiveStringComparator()) == 0) {        nsAutoString  lang(aAttributes[1]);        isJavaScript = nsParserUtils::IsJavaScriptLanguage(lang, &jsVersionString);      }      aAttributes += 2;  }  // Don't process scripts that aren't JavaScript  if (isJavaScript) {      nsXULPrototypeScript* script =          new nsXULPrototypeScript(aLineNumber,                                   jsVersionString);      if (! script)          return NS_ERROR_OUT_OF_MEMORY;      // If there is a SRC attribute...      if (! src.IsEmpty()) {          // Use the SRC attribute value to load the URL          rv = NS_NewURI(getter_AddRefs(script->mSrcURI), src, mDocumentURL);          if (NS_FAILED(rv)) {              delete script;              return rv;          }      }      // XXXbe temporary, until we serialize/deserialize everything from      //       the nsXULPrototypeDocument on down...      nsCOMPtr<nsIFastLoadService> fastLoadService;      nsCOMPtr<nsIObjectInputStream> objectInput;      nsXULDocument::GetFastLoadService(getter_AddRefs(fastLoadService));      if (fastLoadService)          fastLoadService->GetInputStream(getter_AddRefs(objectInput));      if (objectInput) {          PRBool useXULCache = PR_TRUE;          if (script->mSrcURI) {              // NB: we must check the XUL script cache early, to avoid              // multiple deserialization attempts for a given script, which              // would exhaust the multiplexed stream containing the singly              // serialized script.  Note that nsXULDocument::LoadScript              // checks the XUL script cache too, in order to handle the              // serialization case.              //              // We need do this only for <script src='strres.js'> and the              // like, i.e., out-of-line scripts that are included by several              // different XUL documents multiplexed in the FastLoad file.              gXULCache->GetEnabled(&useXULCache);              if (useXULCache) {                  gXULCache->GetScript(script->mSrcURI,                                       NS_REINTERPRET_CAST(void**, &script->mJSObject));              }          }          if (! script->mJSObject) {              nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner(do_QueryInterface(mPrototype));              nsCOMPtr<nsIScriptGlobalObject> globalObject;              globalOwner->GetScriptGlobalObject(getter_AddRefs(globalObject));              NS_ASSERTION(globalObject != nsnull, "no prototype global object!");              nsCOMPtr<nsIScriptContext> scriptContext;              globalObject->GetContext(getter_AddRefs(scriptContext));              NS_ASSERTION(scriptContext != nsnull,                           "no prototype script context!");              // Keep track of FastLoad failure via rv2, so we can              // AbortFastLoads if things look bad.              nsresult rv2 = NS_OK;              if (script->mSrcURI) {                  nsXPIDLCString spec;                  script->mSrcURI->GetSpec(getter_Copies(spec));                  rv2 = fastLoadService->StartMuxedDocument(script->mSrcURI,                                                            spec,                                                            nsIFastLoadService::NS_FASTLOAD_READ);                  if (NS_SUCCEEDED(rv2))                      rv2 = fastLoadService->SelectMuxedDocument(script->mSrcURI);              } else {                  // An inline script: check FastLoad multiplexing direction                  // and skip script->Deserialize if we're not reading from a                  // muxed stream to get inline objects that are contained in                  // the current document.                  PRInt32 direction;                  fastLoadService->GetDirection(&direction);                  if (direction != nsIFastLoadService::NS_FASTLOAD_READ)                      rv2 = NS_ERROR_NOT_AVAILABLE;              }              // Don't reflect errors into rv: mJSObject will be null              // after any error, which suffices to cause the script to              // be reloaded (from the src= URI, if any) and recompiled.              // We're better off slow-loading than bailing out due to a              // FastLoad error.              if (NS_SUCCEEDED(rv2))                  rv2 = script->Deserialize(objectInput, scriptContext);              if (NS_SUCCEEDED(rv2) && script->mSrcURI) {                  rv2 = fastLoadService->EndMuxedDocument(script->mSrcURI);                  if (NS_SUCCEEDED(rv2)) {                      // We must reselect the including XUL document now,                      // in case the next script in it is an inline one                      // whose data comes from its stream, not from the                      // now-exhausted document that was multiplexed for                      // script->mSrcURI.  Inline scripts are compiled in                      // XULContentSinkImpl::CloseContainer.                      rv2 = fastLoadService->SelectMuxedDocument(mDocumentURL);                  }              }              if (NS_SUCCEEDED(rv2)) {                  if (useXULCache && script->mSrcURI) {                      PRBool isChrome = PR_FALSE;                      script->mSrcURI->SchemeIs("chrome", &isChrome);                      if (isChrome) {                          gXULCache->PutScript(script->mSrcURI,                                               NS_REINTERPRET_CAST(void*, script->mJSObject));                      }                  }              } else {                  // If script->mSrcURI is not in the FastLoad multiplex,                  // rv2 will be NS_ERROR_NOT_AVAILABLE and we'll try to                  // update the FastLoad file to hold a serialization of                  // this script, once it has finished loading.                  if (rv2 != NS_ERROR_NOT_AVAILABLE)                      nsXULDocument::AbortFastLoads();              }          }      }      nsVoidArray* children;      rv = mContextStack.GetTopChildren(&children);      if (NS_FAILED(rv)) {          delete script;          return rv;      }      children->AppendElement(script);      mConstrainSize = PR_FALSE;      mContextStack.Push(script, mState);      mState = eInScript;  }  return NS_OK;}