Skip to content

Commit

Permalink
Backed out changeset 29a6664e8f73 (bug 1319342) for wpt failures in N…
Browse files Browse the repository at this point in the history
…ode-cloneNode.html a=backout

MozReview-Commit-ID: 2FoC3zDqXO2
  • Loading branch information
KWierso committed Oct 2, 2017
1 parent 3ca5249 commit fee639d
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 31 deletions.
28 changes: 5 additions & 23 deletions dom/base/nsNodeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,37 +477,19 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
return nullptr;
}

if (CustomElementRegistry::IsCustomElementEnabled() && clone->IsElement()) {
if (clone->IsElement()) {
// The cloned node may be a custom element that may require
// enqueing upgrade reaction.
// enqueing created callback and prototype swizzling.
Element* elem = clone->AsElement();
CustomElementDefinition* definition = nullptr;
RefPtr<nsIAtom> tagAtom = nodeInfo->NameAtom();
if (nsContentUtils::IsCustomElementName(tagAtom)) {
definition =
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
nodeInfo->LocalName(),
nodeInfo->NamespaceID());
if (definition) {
elem->SetCustomElementData(new CustomElementData(tagAtom));
nsContentUtils::EnqueueUpgradeReaction(elem, definition);
}
if (nsContentUtils::IsCustomElementName(nodeInfo->NameAtom())) {
nsContentUtils::SetupCustomElement(elem);
} else {
// Check if node may be custom element by type extension.
// ex. <button is="x-button">
nsAutoString extension;
if (elem->GetAttr(kNameSpaceID_None, nsGkAtoms::is, extension) &&
!extension.IsEmpty()) {
definition =
nsContentUtils::LookupCustomElementDefinition(nodeInfo->GetDocument(),
nodeInfo->LocalName(),
nodeInfo->NamespaceID(),
&extension);
if (definition) {
RefPtr<nsIAtom> typeAtom = NS_Atomize(extension);
elem->SetCustomElementData(new CustomElementData(typeAtom));
nsContentUtils::EnqueueUpgradeReaction(elem, definition);
}
nsContentUtils::SetupCustomElement(elem, &extension);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions dom/tests/mochitest/webcomponents/mochitest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ skip-if = stylo # bug 1293844
skip-if = stylo # bug 1293844
[test_custom_element_adopt_callbacks.html]
[test_custom_element_callback_innerhtml.html]
[test_custom_element_clone_callbacks.html]
[test_custom_element_clone_callbacks_extended.html]
[test_custom_element_htmlconstructor.html]
skip-if = os == 'android' # bug 1323645
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1081039
-->
<head>
<title>Test callbacks for cloned custom elements.</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1081039">Bug 1081039</a>
<script>

SimpleTest.waitForExplicitFinish();

// Test to make sure created callback is called on clones that are upgraded and clones
// created after registering the custom element.

var callbackCalledOnUpgrade = false;
var callbackCalledOnClone = false;

var foo = document.createElement("x-foo");
var fooClone = foo.cloneNode(true);

var p = Object.create(HTMLElement.prototype);
p.createdCallback = function() {
is(this.__proto__, p, "Correct prototype should be set on custom elements.");

if (this == fooClone) {
// Callback called for the element created before registering the custom element.
// Should be called on element upgrade.
is(callbackCalledOnUpgrade, false, "Upgrade should only be called once per clone.");
callbackCalledOnUpgrade = true;
} else if (this != foo) {
// Callback called for the element created after registering the custom element.
is(callbackCalledOnClone, false, "Upgrade should only be called once per clone.");
callbackCalledOnClone = true;
}

if (callbackCalledOnUpgrade && callbackCalledOnClone) {
SimpleTest.finish();
}
};

document.registerElement("x-foo", { prototype: p });

var anotherFooClone = foo.cloneNode(true);

SimpleTest.waitForExplicitFinish();

</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[reaction-timing.html]
type: testharness
[Calling Node.prototype.cloneNode(false) must push a new element queue to the processing stack]
expected: FAIL

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
[importNode on Document must construct a new custom element when importing a custom element]
expected: FAIL

[importNode on Document must construct a new custom element when importing a custom element from a template]
expected: FAIL

[execCommand on Document must enqueue a disconnected reaction when deleting a custom element from a contenteditable element]
expected: FAIL

Expand Down
10 changes: 10 additions & 0 deletions testing/web-platform/meta/custom-elements/reactions/Node.html.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Node.html]
type: testharness
[cloneNode on Node must enqueue an attributeChanged reaction when cloning an element with an observed attribute]
expected: FAIL

[cloneNode on Node must not enqueue an attributeChanged reaction when cloning an element with an unobserved attribute]
expected: FAIL

[cloneNode on Node must enqueue an attributeChanged reaction when cloning an element only for observed attributes]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
[Range.html]
type: testharness
[cloneContents on Range must enqueue an attributeChanged reaction when cloning an element with an observed attribute]
expected: FAIL

[cloneContents on Range must not enqueue an attributeChanged reaction when cloning an element with an unobserved attribute]
expected: FAIL

[cloneContents on Range must enqueue an attributeChanged reaction when cloning an element only for observed attributes]
expected: FAIL

[createContextualFragment on Range must construct a custom element]
expected: FAIL

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Node-cloneNode.html]
type: testharness
[Node.prototype.cloneNode(true) must set parentNode, previousSibling, and nextSibling before upgrading custom elements]
expected: FAIL

[HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself after super() call]
expected: FAIL

[HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed due to a custom element constructor constructing itself before super() call]
expected: FAIL

[Upgrading a custom element must throw InvalidStateError when the custom element's constructor returns another element]
expected: FAIL
16 changes: 8 additions & 8 deletions testing/web-platform/meta/dom/nodes/Node-cloneNode.html.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[Node-cloneNode.html]
type: testharness
[Node.cloneNode]
expected: FAIL

[createElement(dialog)]
expected:
if os == "linux": PASS
if os == "mac": FAIL
if os == "win": FAIL
expected: FAIL

[implementation.createDocument]
expected:
if os == "linux": PASS
if os == "mac": FAIL
if os == "win": FAIL
expected: FAIL

[createElement(applet)]
expected: FAIL

0 comments on commit fee639d

Please sign in to comment.