PR_FALSE);
PR_FALSE, PR_FALSE);
HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode){  nsresult rv = NS_OK;  PRBool isJavaScript = PR_TRUE;  const char* jsVersionString = nsnull;  PRInt32 i, ac = aNode.GetAttributeCount();  // Look for SRC attribute and look for a LANGUAGE attribute  nsAutoString src;  for (i = 0; i < ac; i++) {    nsAutoString key(aNode.GetKeyAt(i));    if (key.EqualsIgnoreCase("src")) {      GetAttributeValueAt(aNode, i, src);    }    else if (key.EqualsIgnoreCase("type")) {      nsAutoString  type;      GetAttributeValueAt(aNode, i, type);      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 (key.EqualsIgnoreCase("language")) {      nsAutoString  lang;             GetAttributeValueAt(aNode, i, lang);      isJavaScript = nsParserUtils::IsJavaScriptLanguage(lang, &jsVersionString);    }    else if (key.EqualsIgnoreCase("charset")) {      //charset from script charset tag      nsAutoString  charset;      GetAttributeValueAt(aNode, i, charset);      NS_WITH_SERVICE(nsICharsetAlias, calias, kCharsetAliasCID, &rv);      if(NS_SUCCEEDED(rv) && (nsnull != calias) )      {       rv = calias->GetPreferred(charset, mScriptCharset);      } else {       mScriptCharset = charset;      }    }  }  // Create content object  NS_ASSERTION(mCurrentContext->mStackPos > 0, "leaf w/o container");  if (mCurrentContext->mStackPos <= 0) {    return NS_ERROR_FAILURE;  }  nsIHTMLContent* parent = mCurrentContext->mStack[mCurrentContext->mStackPos-1].mContent;  nsIHTMLContent* element = nsnull;  nsCOMPtr<nsINodeInfo> nodeInfo;  mNodeInfoManager->GetNodeInfo(nsHTMLAtoms::script, nsnull, kNameSpaceID_None,                                *getter_AddRefs(nodeInfo));  rv = NS_CreateHTMLElement(&element, nodeInfo);  if (NS_SUCCEEDED(rv)) {    PRInt32 id;    mDocument->GetAndIncrementContentID(&id);        element->SetContentID(id);    // Add in the attributes and add the style content object to the    // head container.    element->SetDocument(mDocument, PR_FALSE, PR_TRUE);    rv = AddAttributes(aNode, element);    if (NS_FAILED(rv)) {      NS_RELEASE(element);      return rv;    }    if (mCurrentContext->mStack[mCurrentContext->mStackPos-1].mInsertionPoint != -1) {      parent->InsertChildAt(element,                             mCurrentContext->mStack[mCurrentContext->mStackPos-1].mInsertionPoint++,                             PR_FALSE);    }    else {      parent->AppendChildTo(element, PR_FALSE);    }  }  else {    return rv;  }    // Create a text node holding the content  // First, get the text content of the script tag  nsAutoString script;  script.Assign(aNode.GetSkippedContent());  if (script.Length() > 0) {    nsIContent* text;    rv = NS_NewTextNode(&text);    if (NS_OK == rv) {      nsIDOMText* tc;      rv = text->QueryInterface(NS_GET_IID(nsIDOMText), (void**)&tc);      if (NS_OK == rv) {        tc->SetData(script);        NS_RELEASE(tc);      }      element->AppendChildTo(text, PR_FALSE);      text->SetDocument(mDocument, PR_FALSE, PR_TRUE);      NS_RELEASE(text);    }  }  NS_RELEASE(element);  // Don't include script loading and evaluation in the stopwatch  // that is measuring content creation time  MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::ProcessSCRIPTTag()\n"));  MOZ_TIMER_STOP(mWatch);  // Don't process scripts that aren't JavaScript and don't process  // scripts that are inside iframes, noframe, or noscript tags,  // or if the script context has script evaluation disabled:  PRBool scriptsEnabled = PR_TRUE;  nsCOMPtr<nsIScriptGlobalObject> globalObject;  mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));  if (globalObject)  {    nsCOMPtr<nsIScriptContext> context;    if (NS_SUCCEEDED(globalObject->GetContext(getter_AddRefs(context)))        && context)      context->GetScriptsEnabled(&scriptsEnabled);  }  if (scriptsEnabled && isJavaScript && !mNumOpenIFRAMES && !mInsideNoXXXTag) {    mScriptLanguageVersion = jsVersionString;    // If there is a SRC attribute...    if (src.Length() > 0) {      // Use the SRC attribute value to load the URL      {        rv = NS_NewURI(getter_AddRefs(mScriptURI), src, mDocumentBaseURL);      }      if (NS_OK != rv) {        return rv;      }      // Check that this page is allowed to load this URI.      NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager,                       NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);      if (NS_FAILED(rv))           return rv;      rv = securityManager->CheckLoadURI(mDocumentBaseURL, mScriptURI, nsIScriptSecurityManager::ALLOW_CHROME);      if (NS_FAILED(rv))           return rv;      // After the security manager, the content-policy stuff gets a veto      // For pinkerton: a symphony for string conversion, in 3 parts.      nsXPIDLCString urlCString;      mScriptURI->GetSpec(getter_Copies(urlCString));      nsAutoString url;      url.AssignWithConversion((const char *)urlCString);      nsCOMPtr<nsIDOMElement> DOMElement = do_QueryInterface(element, &rv);            PRBool shouldLoad = PR_TRUE;      if (NS_SUCCEEDED(rv) &&          (rv = NS_CheckContentLoadPolicy(nsIContentPolicy::CONTENT_SCRIPT,                                          url, DOMElement, &shouldLoad),           NS_SUCCEEDED(rv)) &&          !shouldLoad) {        // content-policy veto causes silent failure        return NS_OK;      }      nsCOMPtr<nsILoadGroup> loadGroup;      nsCOMPtr<nsIStreamLoader> loader;      mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));      // supply a prompter if you have one. this allows modal dialogs put up      // from within this new stream loader to have proper parenting. but it's      // not fatal if there isn't a prompter.      nsCOMPtr<nsIInterfaceRequestor> promptcall(do_QueryInterface(mWebShell));      rv = NS_NewStreamLoader(getter_AddRefs(loader), mScriptURI, this,                              nsnull, loadGroup, promptcall,                              nsIChannel::FORCE_RELOAD);      if (NS_OK == rv) {        rv = NS_ERROR_HTMLPARSER_BLOCK;      }    }    else {      PRBool bodyPresent = PreEvaluateScript();      PRUint32 lineNo = (PRUint32)aNode.GetSourceLineNumber();      nsIURI *docURI = mDocument->GetDocumentURL();      EvaluateScript(script, docURI, lineNo, jsVersionString);      NS_IF_RELEASE(docURI);      PostEvaluateScript(bodyPresent);      // If the parse was disabled as a result of this evaluate script      // (for example, if the script document.wrote a SCRIPT SRC= tag,      // we remind the parser to block.      if ((nsnull != mParser) && (PR_FALSE == mParser->IsParserEnabled())) {        rv = NS_ERROR_HTMLPARSER_BLOCK;      }    }  }  return rv;}