Bug 1658469 - Don't clone UA widgets for printing. r=smaug

We run the widget initialization code regardless on bind, and some of it
doesn't deal with shadow roots being already populated.

Differential Revision: https://phabricator.services.mozilla.com/D86952
This commit is contained in:
Emilio Cobos Álvarez 2020-08-14 16:27:49 +00:00
Родитель 91527a2bb0
Коммит 4af1306128
3 изменённых файлов: 10 добавлений и 3 удалений

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

@ -95,6 +95,8 @@ JSObject* ShadowRoot::WrapNode(JSContext* aCx,
}
void ShadowRoot::CloneInternalDataFrom(ShadowRoot* aOther) {
MOZ_ASSERT(!aOther->IsUAWidget());
size_t sheetCount = aOther->SheetCount();
for (size_t i = 0; i < sheetCount; ++i) {
StyleSheet* sheet = aOther->SheetAt(i);

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

@ -3305,7 +3305,7 @@ already_AddRefed<nsINode> nsINode::CloneAndAdopt(
// Clone the Shadow DOM
ShadowRoot* originalShadowRoot = aNode->AsElement()->GetShadowRoot();
if (originalShadowRoot) {
if (originalShadowRoot && !originalShadowRoot->IsUAWidget()) {
RefPtr<ShadowRoot> newShadowRoot =
clone->AsElement()->AttachShadowWithoutNameChecks(
originalShadowRoot->Mode());

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

@ -424,7 +424,7 @@ async function compareFiles(src1, src2, options = {}) {
await new Promise((resolve) => {
iframeElement.addEventListener("load", resolve, { capture: true, once: true });
iframeElement.setAttribute("src", BASE + src1);
iframeElement.setAttribute("src", new URL(src1, BASE).href);
});
if (messagePromise) {
@ -438,7 +438,7 @@ async function compareFiles(src1, src2, options = {}) {
await new Promise((resolve) => {
iframeElement.addEventListener("load", resolve, { capture: true, once: true });
iframeElement.setAttribute("src", BASE + src2);
iframeElement.setAttribute("src", new URL(src2, BASE).href);
});
await printpreview(options.ref || options);
@ -551,6 +551,11 @@ async function runTest20() {
exitprintpreview();
requestAnimationFrame(() => setTimeout(runTest21));
}
async function runTest21() {
await compareFiles("data:text/html,<audio controls>", "data:text/html,<audio controls >"); // Shouldn't crash.
finish();
}