зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset ed0cc9f86583::b6b642efbb74 (bug 1396620) for static failure at dom/base/CustomElementRegistry.cpp r=backout on a CLOSED TREE
Backed out changeset b6b642efbb74 (bug 1396620) Backed out changeset ed0cc9f86583 (bug 1396620)
This commit is contained in:
Родитель
5f90902bda
Коммит
cb136d6136
|
@ -23,6 +23,40 @@ CustomElementCallback::Call()
|
|||
{
|
||||
IgnoredErrorResult rv;
|
||||
switch (mType) {
|
||||
case nsIDocument::eCreated:
|
||||
{
|
||||
// For the duration of this callback invocation, the element is being created
|
||||
// flag must be set to true.
|
||||
mOwnerData->mElementIsBeingCreated = true;
|
||||
|
||||
// The callback hasn't actually been invoked yet, but we need to flip
|
||||
// this now in order to enqueue the connected callback. This is a spec
|
||||
// bug (w3c bug 27437).
|
||||
mOwnerData->mCreatedCallbackInvoked = true;
|
||||
|
||||
// If ELEMENT is connected, enqueue connected callback for ELEMENT.
|
||||
nsIDocument* document = mThisObject->GetComposedDoc();
|
||||
if (document) {
|
||||
NodeInfo* ni = mThisObject->NodeInfo();
|
||||
nsDependentAtomString extType(mOwnerData->mType);
|
||||
|
||||
// We need to do this because at this point, CustomElementDefinition is
|
||||
// not set to CustomElementData yet, so EnqueueLifecycleCallback will
|
||||
// fail to find the CE definition for this custom element.
|
||||
// This will go away eventually since there is no created callback in v1.
|
||||
CustomElementDefinition* definition =
|
||||
nsContentUtils::LookupCustomElementDefinition(document,
|
||||
ni->LocalName(), ni->NamespaceID(),
|
||||
extType.IsEmpty() ? nullptr : &extType);
|
||||
|
||||
nsContentUtils::EnqueueLifecycleCallback(
|
||||
nsIDocument::eConnected, mThisObject, nullptr, nullptr, definition);
|
||||
}
|
||||
|
||||
static_cast<LifecycleCreatedCallback *>(mCallback.get())->Call(mThisObject, rv);
|
||||
mOwnerData->mElementIsBeingCreated = false;
|
||||
break;
|
||||
}
|
||||
case nsIDocument::eConnected:
|
||||
static_cast<LifecycleConnectedCallback *>(mCallback.get())->Call(mThisObject, rv);
|
||||
break;
|
||||
|
@ -52,10 +86,12 @@ CustomElementCallback::Traverse(nsCycleCollectionTraversalCallback& aCb) const
|
|||
|
||||
CustomElementCallback::CustomElementCallback(Element* aThisObject,
|
||||
nsIDocument::ElementCallbackType aCallbackType,
|
||||
mozilla::dom::CallbackFunction* aCallback)
|
||||
mozilla::dom::CallbackFunction* aCallback,
|
||||
CustomElementData* aOwnerData)
|
||||
: mThisObject(aThisObject),
|
||||
mCallback(aCallback),
|
||||
mType(aCallbackType)
|
||||
mType(aCallbackType),
|
||||
mOwnerData(aOwnerData)
|
||||
{
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
|
@ -97,6 +133,8 @@ CustomElementData::CustomElementData(nsAtom* aType)
|
|||
|
||||
CustomElementData::CustomElementData(nsAtom* aType, State aState)
|
||||
: mType(aType)
|
||||
, mElementIsBeingCreated(false)
|
||||
, mCreatedCallbackInvoked(true)
|
||||
, mState(aState)
|
||||
{
|
||||
}
|
||||
|
@ -320,6 +358,12 @@ CustomElementRegistry::SetupCustomElement(Element* aElement,
|
|||
// and we don't need to do anything more.
|
||||
return;
|
||||
}
|
||||
|
||||
// Enqueuing the created callback will set the CustomElementData on the
|
||||
// element, causing prototype swizzling to occur in Element::WrapObject.
|
||||
// We make it synchronously for createElement/createElementNS in order to
|
||||
// pass tests. It'll be removed when we deprecate custom elements v0.
|
||||
SyncInvokeReactions(nsIDocument::eCreated, aElement, definition);
|
||||
}
|
||||
|
||||
/* static */ UniquePtr<CustomElementCallback>
|
||||
|
@ -337,6 +381,12 @@ CustomElementRegistry::CreateCustomElementCallback(
|
|||
// Let CALLBACK be the callback associated with the key NAME in CALLBACKS.
|
||||
CallbackFunction* func = nullptr;
|
||||
switch (aType) {
|
||||
case nsIDocument::eCreated:
|
||||
if (aDefinition->mCallbacks->mCreatedCallback.WasPassed()) {
|
||||
func = aDefinition->mCallbacks->mCreatedCallback.Value();
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDocument::eConnected:
|
||||
if (aDefinition->mCallbacks->mConnectedCallback.WasPassed()) {
|
||||
func = aDefinition->mCallbacks->mConnectedCallback.Value();
|
||||
|
@ -367,9 +417,17 @@ CustomElementRegistry::CreateCustomElementCallback(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (aType == nsIDocument::eCreated) {
|
||||
elementData->mCreatedCallbackInvoked = false;
|
||||
} else if (!elementData->mCreatedCallbackInvoked) {
|
||||
// Callbacks other than created callback must not be enqueued
|
||||
// until after the created callback has been invoked.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Add CALLBACK to ELEMENT's callback queue.
|
||||
auto callback =
|
||||
MakeUnique<CustomElementCallback>(aCustomElement, aType, func);
|
||||
MakeUnique<CustomElementCallback>(aCustomElement, aType, func, elementData);
|
||||
|
||||
if (aArgs) {
|
||||
callback->SetArgs(*aArgs);
|
||||
|
@ -381,6 +439,26 @@ CustomElementRegistry::CreateCustomElementCallback(
|
|||
return Move(callback);
|
||||
}
|
||||
|
||||
void
|
||||
CustomElementRegistry::SyncInvokeReactions(nsIDocument::ElementCallbackType aType,
|
||||
Element* aCustomElement,
|
||||
CustomElementDefinition* aDefinition)
|
||||
{
|
||||
auto callback = CreateCustomElementCallback(aType, aCustomElement, nullptr,
|
||||
nullptr, aDefinition);
|
||||
if (!callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
UniquePtr<CustomElementReaction> reaction(Move(
|
||||
MakeUnique<CustomElementCallbackReaction>(Move(callback))));
|
||||
|
||||
RefPtr<SyncInvokeReactionRunnable> runnable =
|
||||
new SyncInvokeReactionRunnable(Move(reaction), aCustomElement);
|
||||
|
||||
nsContentUtils::AddScriptRunner(runnable);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType aType,
|
||||
Element* aCustomElement,
|
||||
|
@ -478,7 +556,9 @@ static const char* kLifeCycleCallbackNames[] = {
|
|||
"connectedCallback",
|
||||
"disconnectedCallback",
|
||||
"adoptedCallback",
|
||||
"attributeChangedCallback"
|
||||
"attributeChangedCallback",
|
||||
// The life cycle callbacks from v0 spec.
|
||||
"createdCallback"
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -951,6 +1031,11 @@ CustomElementRegistry::Upgrade(Element* aElement,
|
|||
|
||||
// Step 9.
|
||||
aElement->SetCustomElementDefinition(aDefinition);
|
||||
|
||||
// This is for old spec.
|
||||
nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eCreated,
|
||||
aElement, nullptr,
|
||||
nullptr, aDefinition);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
|
@ -1122,6 +1207,11 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementDefinition)
|
|||
cb.NoteXPCOMChild(callbacks->mAttributeChangedCallback.Value());
|
||||
}
|
||||
|
||||
if (callbacks->mCreatedCallback.WasPassed()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCallbacks->mCreatedCallback");
|
||||
cb.NoteXPCOMChild(callbacks->mCreatedCallback.Value());
|
||||
}
|
||||
|
||||
if (callbacks->mConnectedCallback.WasPassed()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCallbacks->mConnectedCallback");
|
||||
cb.NoteXPCOMChild(callbacks->mConnectedCallback.Value());
|
||||
|
|
|
@ -51,7 +51,8 @@ class CustomElementCallback
|
|||
public:
|
||||
CustomElementCallback(Element* aThisObject,
|
||||
nsIDocument::ElementCallbackType aCallbackType,
|
||||
CallbackFunction* aCallback);
|
||||
CallbackFunction* aCallback,
|
||||
CustomElementData* aOwnerData);
|
||||
void Traverse(nsCycleCollectionTraversalCallback& aCb) const;
|
||||
void Call();
|
||||
void SetArgs(LifecycleCallbackArgs& aArgs)
|
||||
|
@ -78,6 +79,9 @@ private:
|
|||
// used by the attribute changed callback.
|
||||
LifecycleCallbackArgs mArgs;
|
||||
LifecycleAdoptedCallbackArgs mAdoptedCallbackArgs;
|
||||
// CustomElementData that contains this callback in the
|
||||
// callback queue.
|
||||
CustomElementData* mOwnerData;
|
||||
};
|
||||
|
||||
class CustomElementConstructor final : public CallbackFunction
|
||||
|
@ -113,6 +117,11 @@ struct CustomElementData
|
|||
// Custom element type, for <button is="x-button"> or <x-button>
|
||||
// this would be x-button.
|
||||
RefPtr<nsAtom> mType;
|
||||
// Element is being created flag as described in the custom elements spec.
|
||||
bool mElementIsBeingCreated;
|
||||
// Flag to determine if the created callback has been invoked, thus it
|
||||
// determines if other callbacks can be enqueued.
|
||||
bool mCreatedCallbackInvoked;
|
||||
// Custom element state as described in the custom element spec.
|
||||
State mState;
|
||||
// custom element reaction queue as described in the custom element spec.
|
||||
|
@ -381,6 +390,10 @@ public:
|
|||
void GetCustomPrototype(nsAtom* aAtom,
|
||||
JS::MutableHandle<JSObject*> aPrototype);
|
||||
|
||||
void SyncInvokeReactions(nsIDocument::ElementCallbackType aType,
|
||||
Element* aCustomElement,
|
||||
CustomElementDefinition* aDefinition);
|
||||
|
||||
/**
|
||||
* Upgrade an element.
|
||||
* https://html.spec.whatwg.org/multipage/scripting.html#upgrades
|
||||
|
@ -463,6 +476,31 @@ private:
|
|||
CustomElementRegistry* mRegistry;
|
||||
};
|
||||
|
||||
class SyncInvokeReactionRunnable : public mozilla::Runnable {
|
||||
public:
|
||||
SyncInvokeReactionRunnable(
|
||||
UniquePtr<CustomElementReaction> aReaction, Element* aCustomElement)
|
||||
: Runnable(
|
||||
"dom::CustomElementRegistry::SyncInvokeReactionRunnable")
|
||||
, mReaction(Move(aReaction))
|
||||
, mCustomElement(aCustomElement)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
// It'll never throw exceptions, because all the exceptions are handled
|
||||
// by Lifecycle*Callback::Call function.
|
||||
ErrorResult rv;
|
||||
mReaction->Invoke(mCustomElement, rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
UniquePtr<CustomElementReaction> mReaction;
|
||||
Element* mCustomElement;
|
||||
};
|
||||
|
||||
public:
|
||||
nsISupports* GetParentObject() const;
|
||||
|
||||
|
|
|
@ -527,10 +527,6 @@ Element::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
data->mType, &customProto);
|
||||
if (customProto &&
|
||||
NodePrincipal()->SubsumesConsideringDomain(nsContentUtils::ObjectPrincipal(customProto))) {
|
||||
// The custom element prototype could be in different compartment.
|
||||
if (!JS_WrapObject(aCx, &customProto)) {
|
||||
return nullptr;
|
||||
}
|
||||
// Just go ahead and create with the right proto up front. Set
|
||||
// customProto to null to flag that we don't need to do any post-facto
|
||||
// proto fixups here.
|
||||
|
|
|
@ -10192,6 +10192,27 @@ nsContentUtils::GetElementDefinitionIfObservingAttr(Element* aCustomElement,
|
|||
return definition;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsContentUtils::SyncInvokeReactions(nsIDocument::ElementCallbackType aType,
|
||||
Element* aElement,
|
||||
CustomElementDefinition* aDefinition)
|
||||
{
|
||||
MOZ_ASSERT(aElement);
|
||||
|
||||
nsIDocument* doc = aElement->OwnerDoc();
|
||||
nsPIDOMWindowInner* window(doc->GetInnerWindow());
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<CustomElementRegistry> registry(window->CustomElements());
|
||||
if (!registry) {
|
||||
return;
|
||||
}
|
||||
|
||||
registry->SyncInvokeReactions(aType, aElement, aDefinition);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsContentUtils::EnqueueUpgradeReaction(Element* aElement,
|
||||
CustomElementDefinition* aDefinition)
|
||||
|
|
|
@ -3047,6 +3047,10 @@ public:
|
|||
nsAtom* aExtensionType,
|
||||
nsAtom* aAttrName);
|
||||
|
||||
static void SyncInvokeReactions(nsIDocument::ElementCallbackType aType,
|
||||
Element* aCustomElement,
|
||||
mozilla::dom::CustomElementDefinition* aDefinition);
|
||||
|
||||
static void EnqueueUpgradeReaction(Element* aElement,
|
||||
mozilla::dom::CustomElementDefinition* aDefinition);
|
||||
|
||||
|
|
|
@ -6448,6 +6448,9 @@ nsDocument::CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value*
|
|||
|
||||
element->SetCustomElementDefinition(definition);
|
||||
|
||||
// It'll be removed when we deprecate custom elements v0.
|
||||
nsContentUtils::SyncInvokeReactions(nsIDocument::eCreated, element,
|
||||
definition);
|
||||
NS_ENSURE_TRUE(element, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -2851,6 +2851,7 @@ public:
|
|||
}
|
||||
|
||||
enum ElementCallbackType {
|
||||
eCreated,
|
||||
eConnected,
|
||||
eDisconnected,
|
||||
eAdopted,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var proto = Object.create(HTMLElement.prototype);
|
||||
proto.magicNumber = 42;
|
||||
proto.connectedCallback = function() {
|
||||
proto.createdCallback = function() {
|
||||
finishTest(this.magicNumber === 42);
|
||||
};
|
||||
document.registerElement("x-foo", { prototype: proto });
|
||||
|
||||
document.firstChild.appendChild(document.createElement("x-foo"));
|
||||
document.createElement("x-foo");
|
||||
|
|
|
@ -21,13 +21,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
|
|||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
/** Test for Bug 1130028 **/
|
||||
var connectedCallbackCount = 0;
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// Callback should be called only once by element created in content.
|
||||
function connectedCallbackCalled() {
|
||||
connectedCallbackCount++;
|
||||
is(connectedCallbackCount, 1, "Connected callback called, should be called once in test.");
|
||||
var createdCallbackCount = 0;
|
||||
|
||||
// Callback should be called once by element created in chrome,
|
||||
// and once by element created in content.
|
||||
function createdCallbackCalled() {
|
||||
createdCallbackCount++;
|
||||
ok(true, "Created callback called, should be called twice in test.");
|
||||
is(this.magicNumber, 42, "Callback should be able to see the custom prototype.");
|
||||
if (createdCallbackCount == 2) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function startTests() {
|
||||
|
@ -39,13 +45,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
|
|||
|
||||
var proto = Object.create(frame.contentWindow.HTMLElement.prototype);
|
||||
proto.magicNumber = 42;
|
||||
proto.connectedCallback = connectedCallbackCalled;
|
||||
|
||||
proto.createdCallback = createdCallbackCalled;
|
||||
frame.contentDocument.registerElement("x-bar", { prototype: proto });
|
||||
is(connectedCallbackCount, 1, "Connected callback should be called by element created in content.");
|
||||
|
||||
var element = frame.contentDocument.createElement("x-bar");
|
||||
is(element.magicNumber, 42, "Should be able to see the custom prototype on created element.");
|
||||
frame.contentDocument.createElement("x-bar");
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
|
|
@ -26,8 +26,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function finishTest(canSeePrototype) {
|
||||
ok(true, "connectedCallback called when reigsterElement was called with an extended principal.");
|
||||
ok(canSeePrototype, "connectedCallback should be able to see custom prototype.");
|
||||
ok(true, "createdCallback called when reigsterElement was called with an extended principal.");
|
||||
ok(canSeePrototype, "createdCallback should be able to see custom prototype.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,16 @@ support-files =
|
|||
[test_bug1176757.html]
|
||||
[test_bug1276240.html]
|
||||
[test_content_element.html]
|
||||
[test_custom_element_adopt_callbacks.html]
|
||||
[test_custom_element_callback_innerhtml.html]
|
||||
skip-if = true # disabled - See bug 1390396
|
||||
[test_custom_element_clone_callbacks_extended.html]
|
||||
[test_custom_element_htmlconstructor.html]
|
||||
skip-if = os == 'android' # bug 1323645
|
||||
support-files =
|
||||
htmlconstructor_autonomous_tests.js
|
||||
htmlconstructor_builtin_tests.js
|
||||
[test_custom_element_import_node_created_callback.html]
|
||||
[test_custom_element_in_shadow.html]
|
||||
skip-if = true # disabled - See bug 1390396
|
||||
[test_custom_element_register_invalid_callbacks.html]
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1081039
|
||||
-->
|
||||
<head>
|
||||
<title>Test callbacks for adopted 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>
|
||||
<template id="template"><x-foo></x-foo></template>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1081039">Bug 1081039</a>
|
||||
<script>
|
||||
|
||||
var p = Object.create(HTMLElement.prototype);
|
||||
p.createdCallback = function() {
|
||||
ok(false, "Created callback should not be called for adopted node.");
|
||||
};
|
||||
|
||||
document.registerElement("x-foo", { prototype: p });
|
||||
|
||||
var template = document.getElementById("template");
|
||||
var adoptedFoo = document.adoptNode(template.content.firstChild);
|
||||
is(adoptedFoo.nodeName, "X-FOO");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1081039
|
||||
-->
|
||||
<head>
|
||||
<title>Test callbacks for cloned extended 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 created after
|
||||
// registering the custom element.
|
||||
|
||||
var count = 0;
|
||||
var p = Object.create(HTMLButtonElement.prototype);
|
||||
p.createdCallback = function() { // should be called by createElement and cloneNode
|
||||
is(this.__proto__, p, "Correct prototype should be set on custom elements.");
|
||||
|
||||
if (++count == 2) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
|
||||
document.registerElement("x-foo", { prototype: p, extends: "button" });
|
||||
var foo = document.createElement("button", {is: "x-foo"});
|
||||
is(foo.getAttribute("is"), "x-foo");
|
||||
|
||||
var fooClone = foo.cloneNode(true);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1093680
|
||||
-->
|
||||
<head>
|
||||
<title>Test created callback order for imported custom element.</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<template id="template"><x-foo><span></span></x-foo></template>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1093680">Bug 1093680</a>
|
||||
<script>
|
||||
|
||||
var fooProtoCreatedCallbackCalled = false;
|
||||
var fooProto = Object.create(HTMLElement.prototype);
|
||||
fooProto.createdCallback = function() {
|
||||
ok(this.firstElementChild, "When the created callback is called, the element should already have a child because the callback should only be called after cloning all the contents.");
|
||||
fooProtoCreatedCallbackCalled = true;
|
||||
};
|
||||
|
||||
document.registerElement("x-foo", { prototype: fooProto });
|
||||
|
||||
var template = document.getElementById("template");
|
||||
|
||||
// Importing node will implicityly clone the conent in the main document.
|
||||
var adoptedFoo = document.importNode(template.content, true);
|
||||
|
||||
ok(fooProtoCreatedCallbackCalled, "Created callback should be called after importing custom element into document");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -19,6 +19,7 @@ const testWindow = iframe.contentDocument.defaultView;
|
|||
// This is for backward compatibility.
|
||||
// We should do the same checks for the callbacks from v0 spec.
|
||||
[
|
||||
'createdCallback',
|
||||
'attributeChangedCallback',
|
||||
].forEach(callback => {
|
||||
var c = class {};
|
||||
|
|
|
@ -14,6 +14,37 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=783129
|
|||
<script>
|
||||
var container = document.getElementById("container");
|
||||
|
||||
function createdCallbackFromMainDoc() {
|
||||
var createdCallbackCalled = false;
|
||||
var assocDoc = document.implementation.createHTMLDocument();
|
||||
|
||||
var proto = Object.create(HTMLElement.prototype);
|
||||
proto.createdCallback = function() {
|
||||
is(createdCallbackCalled, false, "created callback should only be called once in this tests.");
|
||||
createdCallbackCalled = true;
|
||||
runNextTest();
|
||||
};
|
||||
|
||||
assocDoc.registerElement("x-associated-doc-callback-elem", { prototype: proto });
|
||||
document.createElement("x-associated-doc-callback-elem");
|
||||
}
|
||||
|
||||
function createdCallbackFromDocHTMLNamespace() {
|
||||
var createdCallbackCalled = false;
|
||||
var assocDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html", null);
|
||||
var somediv = assocDoc.createElement("div");
|
||||
|
||||
var proto = Object.create(HTMLElement.prototype);
|
||||
proto.createdCallback = function() {
|
||||
is(createdCallbackCalled, false, "created callback should only be called once in this tests.");
|
||||
createdCallbackCalled = true;
|
||||
runNextTest();
|
||||
};
|
||||
|
||||
assocDoc.registerElement("x-assoc-doc-with-ns-callback-elem", { prototype: proto });
|
||||
document.createElement("x-assoc-doc-with-ns-callback-elem");
|
||||
}
|
||||
|
||||
function registerNoRegistryDoc() {
|
||||
var assocDoc = document.implementation.createDocument(null, "html");
|
||||
try {
|
||||
|
@ -34,6 +65,8 @@ function runNextTest() {
|
|||
}
|
||||
|
||||
var testFunctions = [
|
||||
createdCallbackFromMainDoc,
|
||||
createdCallbackFromDocHTMLNamespace,
|
||||
registerNoRegistryDoc,
|
||||
SimpleTest.finish
|
||||
];
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
callback LifecycleCreatedCallback = void();
|
||||
callback LifecycleConnectedCallback = void();
|
||||
callback LifecycleDisconnectedCallback = void();
|
||||
callback LifecycleAdoptedCallback = void(Document? oldDocument,
|
||||
|
@ -20,6 +21,7 @@ callback LifecycleAttributeChangedCallback = void(DOMString attrName,
|
|||
DOMString? namespaceURI);
|
||||
|
||||
dictionary LifecycleCallbacks {
|
||||
LifecycleCreatedCallback? createdCallback;
|
||||
LifecycleConnectedCallback? connectedCallback;
|
||||
LifecycleDisconnectedCallback? disconnectedCallback;
|
||||
LifecycleAdoptedCallback? adoptedCallback;
|
||||
|
|
|
@ -16,14 +16,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1094930
|
|||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var proto = {
|
||||
connectedCallback: function() {
|
||||
ok(true, "connectedCallback was called");
|
||||
createdCallback: function() {
|
||||
ok(true, "createdCallback was called");
|
||||
SimpleTest.finish()
|
||||
}
|
||||
};
|
||||
|
||||
var f = document.registerElement.call(frames[0].document, "x-foo", { prototype: proto });
|
||||
frames[0].document.firstChild.appendChild(new f());
|
||||
var inst = new f();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче