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.

Depends on D26822

Differential Revision: https://phabricator.services.mozilla.com/D26823

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brendan Dahl 2019-04-10 06:36:06 +00:00
Родитель 9f4543e6a1
Коммит 0d976daec9
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -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);