зеркало из https://github.com/mozilla/pjs.git
Bug 592656 part 1 - Use the current parser-inserted script as the insertion point key. r=jonas, a=blocking2.0-final.
--HG-- extra : rebase_source : 92320d48b27c984e25c72be6dafbaef9d6133038
This commit is contained in:
Родитель
25b8c49032
Коммит
726d362bda
|
@ -729,6 +729,8 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
|
|||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
|
||||
nsCOMPtr<nsINode> scriptElem = do_QueryInterface(aRequest->mElement);
|
||||
|
||||
// If there's no script text, we try to get it from the element
|
||||
if (aRequest->mIsInline) {
|
||||
// XXX This is inefficient - GetText makes multiple
|
||||
|
@ -740,14 +742,18 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
|
|||
else {
|
||||
script = &aRequest->mScriptText;
|
||||
|
||||
nsCOMPtr<nsIContent> eltAsContent = do_QueryInterface(aRequest->mElement);
|
||||
NS_ASSERTION(eltAsContent, "Script should QI to nsIContent.");
|
||||
doc = eltAsContent->GetOwnerDoc();
|
||||
doc = scriptElem->GetOwnerDoc();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptElement> oldParserInsertedScript;
|
||||
PRUint32 parserCreated = aRequest->mElement->GetParserCreated();
|
||||
if (parserCreated) {
|
||||
oldParserInsertedScript = mCurrentParserInsertedScript;
|
||||
mCurrentParserInsertedScript = aRequest->mElement;
|
||||
}
|
||||
|
||||
FireScriptAvailable(NS_OK, aRequest);
|
||||
|
||||
nsCOMPtr<nsINode> scriptElem = do_QueryInterface(aRequest->mElement);
|
||||
PRBool runScript = PR_TRUE;
|
||||
nsContentUtils::DispatchTrustedEvent(scriptElem->GetOwnerDoc(),
|
||||
scriptElem,
|
||||
|
@ -756,15 +762,15 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
|
|||
|
||||
nsresult rv = NS_OK;
|
||||
if (runScript) {
|
||||
aRequest->mElement->BeginEvaluating();
|
||||
if (doc) {
|
||||
doc->BeginEvaluatingExternalScript();
|
||||
}
|
||||
aRequest->mElement->BeginEvaluating();
|
||||
rv = EvaluateScript(aRequest, *script);
|
||||
aRequest->mElement->EndEvaluating();
|
||||
if (doc) {
|
||||
doc->EndEvaluatingExternalScript();
|
||||
}
|
||||
aRequest->mElement->EndEvaluating();
|
||||
|
||||
nsContentUtils::DispatchTrustedEvent(scriptElem->GetOwnerDoc(),
|
||||
scriptElem,
|
||||
|
@ -774,6 +780,10 @@ nsScriptLoader::ProcessRequest(nsScriptLoadRequest* aRequest)
|
|||
|
||||
FireScriptEvaluated(rv, aRequest);
|
||||
|
||||
if (parserCreated) {
|
||||
mCurrentParserInsertedScript = oldParserInsertedScript;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,11 @@ public:
|
|||
return mCurrentScript;
|
||||
}
|
||||
|
||||
nsIScriptElement* GetCurrentParserInsertedScript()
|
||||
{
|
||||
return mCurrentParserInsertedScript;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the loader is enabled or not.
|
||||
* When disabled, processing of new script elements is disabled.
|
||||
|
@ -322,6 +327,7 @@ private:
|
|||
nsTArray<PreloadInfo> mPreloads;
|
||||
|
||||
nsCOMPtr<nsIScriptElement> mCurrentScript;
|
||||
nsCOMPtr<nsIScriptElement> mCurrentParserInsertedScript;
|
||||
// XXXbz do we want to cycle-collect these or something? Not sure.
|
||||
nsTArray< nsRefPtr<nsScriptLoader> > mPendingChildLoaders;
|
||||
PRUint32 mBlockerCount;
|
||||
|
|
|
@ -2890,7 +2890,7 @@ nsHTMLDocument::GenerateParserKey(void)
|
|||
// The script loader provides us with the currently executing script element,
|
||||
// which is guaranteed to be unique per script.
|
||||
if (nsHtml5Module::sEnabled) {
|
||||
nsIScriptElement* script = mScriptLoader->GetCurrentScript();
|
||||
nsIScriptElement* script = mScriptLoader->GetCurrentParserInsertedScript();
|
||||
if (script && mParser && mParser->IsScriptCreated()) {
|
||||
nsCOMPtr<nsIParser> creatorParser = script->GetCreatorParser();
|
||||
if (creatorParser != mParser) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>document.write() from script-inserted inline scripts and script@onload</title>
|
||||
</head>
|
||||
<body>
|
||||
1 2 3 4 5 6 7 8 13 14 15
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>document.write() from script-inserted inline scripts and script@onload</title>
|
||||
</head>
|
||||
<body>
|
||||
1
|
||||
<script>
|
||||
function write(num) {
|
||||
document.write(num + " ");
|
||||
}
|
||||
write(2);
|
||||
document.write("\u003Cscript src='data:text/javascript,write(3)'>\u003C/script> 4 \u003Cscript>write(5)\u003C/script>");
|
||||
var s = document.createElement("script");
|
||||
s.textContent = "write(6)";
|
||||
document.body.appendChild(s);
|
||||
write(7);
|
||||
document.write("\u003Cscript src='data:text/javascript,write(8)' onload='scriptload()'>\u003C/script> 13 \u003Cscript>write(14)\u003C/script>");
|
||||
write(15);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -2,3 +2,4 @@
|
|||
== bug577418-1.html bug577418-1-ref.html
|
||||
== bug582788-1.html bug582788-1-ref.html
|
||||
== bug582940-1.html bug582940-1-ref.html
|
||||
== bug592656-1.html bug592656-1-ref.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче