From 0d976daec97c4df38b87cd225e120707382d3745 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 10 Apr 2019 06:36:06 +0000 Subject: [PATCH] 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 --- dom/prototype/PrototypeDocumentContentSink.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom/prototype/PrototypeDocumentContentSink.cpp b/dom/prototype/PrototypeDocumentContentSink.cpp index f27985550167..c7bce8f278a7 100644 --- a/dom/prototype/PrototypeDocumentContentSink.cpp +++ b/dom/prototype/PrototypeDocumentContentSink.cpp @@ -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 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);