Bug 1543245 - Prevent HTML script tags from loading twice when using PrototypeDocument. r=smaug

HTML script tags were being loaded once by the element when it was bound
to the tree and a second time by the PrototypeDocumentContentSink. This
patch disables the script element from loading itself.

Differential Revision: https://phabricator.services.mozilla.com/D26823
This commit is contained in:
Brendan Dahl 2019-04-08 14:01:29 -07:00
parent 67a7d1d576
commit 4ac9a7a0eb

View File

@ -1034,6 +1034,15 @@ nsresult PrototypeDocumentContentSink::CreateElementFromPrototype(
rv = AddAttributes(aPrototype, result);
if (NS_FAILED(rv)) return rv;
if (xtfNi->Equals(nsGkAtoms::script, kNameSpaceID_XHTML) ||
xtfNi->Equals(nsGkAtoms::script, kNameSpaceID_SVG)) {
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(result);
MOZ_ASSERT(sele, "Node didn't QI to script.");
// Script loading is handled by the this content sink, so prevent the
// script from loading when it is bound to the document.
sele->PreventExecution();
}
}
result.forget(aResult);