Bug 992521 - Part 3: Make script run when not in document, but contained by a ShadowRoot with a host in document. r=smaug
authorWilliam Chen <wchen@mozilla.com>
Sat, 07 Jun 2014 01:42:54 -0700
changeset 206601 a93e92a37640bc09123f486e5d8142fe4035fa8c
parent 206600 8968e7307508e5cba5e1ee7597cb507afbeb6486
child 206602 cb404958dd812a2a3f1c12fe81395be14aeed0c5
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs992521
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 992521 - Part 3: Make script run when not in document, but contained by a ShadowRoot with a host in document. r=smaug
content/base/src/nsScriptElement.cpp
content/html/content/src/HTMLScriptElement.cpp
--- a/content/base/src/nsScriptElement.cpp
+++ b/content/base/src/nsScriptElement.cpp
@@ -109,18 +109,18 @@ bool
 nsScriptElement::MaybeProcessScript()
 {
   nsCOMPtr<nsIContent> cont =
     do_QueryInterface((nsIScriptElement*) this);
 
   NS_ASSERTION(cont->DebugGetSlots()->mMutationObservers.Contains(this),
                "You forgot to add self as observer");
 
-  if (mAlreadyStarted || !mDoneAddingChildren || !cont->IsInDoc() ||
-      mMalformed || !HasScriptContent()) {
+  if (mAlreadyStarted || !mDoneAddingChildren ||
+      !cont->GetCrossShadowCurrentDoc() || mMalformed || !HasScriptContent()) {
     return false;
   }
 
   FreezeUriAsyncDefer();
 
   mAlreadyStarted = true;
 
   nsIDocument* ownerDoc = cont->OwnerDoc();
--- a/content/html/content/src/HTMLScriptElement.cpp
+++ b/content/html/content/src/HTMLScriptElement.cpp
@@ -57,17 +57,17 @@ HTMLScriptElement::BindToTree(nsIDocumen
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers)
 {
   nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
                                                  aBindingParent,
                                                  aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (aDocument) {
+  if (GetCrossShadowCurrentDoc()) {
     MaybeProcessScript();
   }
 
   return NS_OK;
 }
 
 bool
 HTMLScriptElement::ParseAttribute(int32_t aNamespaceID,