Backed out changeset 65b36a89443f (bug 1487649) for failing mochitest chrome at layout/base/tests/chrome/test_printpreview.xu
authorAndreea Pavel <apavel@mozilla.com>
Fri, 31 Aug 2018 23:52:40 +0300
changeset 482699 80a2b4e9547cb80289ae49e6a7dc98345addb4d0
parent 482698 6932f13cab4b201c3f1501adce7ef43b23ca80b0
child 482700 64efa7d65fd1bdf6a7326ce758469453339d7d3d
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
bugs1487649
milestone63.0a1
backs out65b36a89443f61fda759a9398f3ee0a9270fdfdf
Backed out changeset 65b36a89443f (bug 1487649) for failing mochitest chrome at layout/base/tests/chrome/test_printpreview.xu
dom/base/nsNodeUtils.cpp
layout/base/tests/chrome/printpreview_helper.xul
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -605,18 +605,23 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNod
     }
   }
 
   if (aDeep && aNode->IsElement()) {
     if (aClone) {
       if (clone->OwnerDoc()->IsStaticDocument()) {
         ShadowRoot* originalShadowRoot = aNode->AsElement()->GetShadowRoot();
         if (originalShadowRoot) {
+          ShadowRootInit init;
+          init.mMode = originalShadowRoot->Mode();
           RefPtr<ShadowRoot> newShadowRoot =
-            clone->AsElement()->AttachShadowWithoutNameChecks(originalShadowRoot->Mode());
+            clone->AsElement()->AttachShadow(init, aError);
+          if (NS_WARN_IF(aError.Failed())) {
+            return nullptr;
+          }
 
           newShadowRoot->CloneInternalDataFrom(originalShadowRoot);
           for (nsIContent* origChild = originalShadowRoot->GetFirstChild();
                origChild;
                origChild = origChild->GetNextSibling()) {
             nsCOMPtr<nsINode> child =
               CloneAndAdopt(origChild, aClone, aDeep, nodeInfoManager,
                             aReparentScope, aNodesWithProperties, newShadowRoot,
--- a/layout/base/tests/chrome/printpreview_helper.xul
+++ b/layout/base/tests/chrome/printpreview_helper.xul
@@ -301,51 +301,16 @@ async function runTest8() {
     iframeElement.addEventListener("message", resolve, { capture: true, once: true });
     iframeElement.setAttribute("src", "printpreview_font_api.html");
   });
   printpreview();
   ctx2.drawWindow(window.frames[1], 0, 0, 400, 400, "rgb(255,255,255)");
   exitprintpreview();
   ok(compareCanvases(), "Printing pages with fonts loaded from CSS and JS should be the same.");
 
-  requestAnimationFrame(function() { setTimeout(runTest9); } );
-}
-
-// Test for bug 1487649
-async function runTest9() {
-  window.frames[0].document.body.innerHTML = `
-    <svg width="100" height="100">
-      <rect width='100' height='100' fill='lime'/>
-    </svg>
-  `;
-
-  printpreview();
-  ctx1.drawWindow(window.frames[1], 0, 0, 400, 400, "rgb(255,255,255)");
-  exitprintpreview();
-
-  window.frames[0].document.body.innerHTML = `
-    <svg width="100" height="100">
-      <defs>
-        <g id="useme">
-          <rect width='100' height='100' fill='lime'/>
-        </g>
-      </defs>
-      <use href="#useme" />
-    </svg>
-  `;
-
-  // Ensure the <use> shadow tree is created so we test what we want to test.
-  await new Promise(resolve => requestAnimationFrame(resolve));
-  await new Promise(resolve => requestAnimationFrame(resolve));
-
-  printpreview();
-  ctx2.drawWindow(window.frames[1], 0, 0, 400, 400, "rgb(255,255,255)");
-  exitprintpreview();
-  ok(compareCanvases(), "Printing <use> subtrees should create same output");
-
   finish();
 }
 
 ]]></script>
 <table style="border: 1px solid black;" xmlns="http://www.w3.org/1999/xhtml">
 <tr><th>Print preview canvas 1</th><th>Print preview canvas 2</th></tr>
 <tr>
 <td><canvas height="400" width="400"></canvas></td>