mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1102502 - Fire custom elements attachedCallback when elements are created and inserted into the document by the parser. r=smaug
This commit is contained in:
parent
86409607b7
commit
f20229f5d0
@ -445,13 +445,27 @@ CustomElementCallback::Call()
|
||||
ErrorResult 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 attached callback. This is a spec
|
||||
// bug (w3c bug 27437).
|
||||
mOwnerData->mCreatedCallbackInvoked = true;
|
||||
|
||||
// If ELEMENT is in a document and this document has a browsing context,
|
||||
// enqueue attached callback for ELEMENT.
|
||||
nsIDocument* document = mThisObject->GetUncomposedDoc();
|
||||
if (document && document->GetDocShell()) {
|
||||
document->EnqueueLifecycleCallback(nsIDocument::eAttached, mThisObject);
|
||||
}
|
||||
|
||||
static_cast<LifecycleCreatedCallback *>(mCallback.get())->Call(mThisObject, rv);
|
||||
mOwnerData->mElementIsBeingCreated = false;
|
||||
break;
|
||||
}
|
||||
case nsIDocument::eAttached:
|
||||
static_cast<LifecycleAttachedCallback *>(mCallback.get())->Call(mThisObject, rv);
|
||||
break;
|
||||
@ -6274,16 +6288,6 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
|
||||
}
|
||||
|
||||
EnqueueLifecycleCallback(nsIDocument::eCreated, elem, nullptr, definition);
|
||||
//XXXsmaug It is unclear if we should use GetComposedDoc() here.
|
||||
if (elem->GetUncomposedDoc()) {
|
||||
// Normally callbacks can not be enqueued until the created
|
||||
// callback has been invoked, however, the attached callback
|
||||
// in element upgrade is an exception so pretend the created
|
||||
// callback has been invoked.
|
||||
elem->GetCustomElementData()->mCreatedCallbackInvoked = true;
|
||||
|
||||
EnqueueLifecycleCallback(nsIDocument::eAttached, elem, nullptr, definition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ support-files =
|
||||
[test_bug1017896.html]
|
||||
[test_content_element.html]
|
||||
[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_nested_content_element.html]
|
||||
|
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1102502
|
||||
-->
|
||||
<head>
|
||||
<title>Test for attached callback for element created in the document by the parser</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=1102502">Bug 1102502</a>
|
||||
<div id="container"></div>
|
||||
|
||||
<script>
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var attachedCallbackCount = 0;
|
||||
|
||||
var p = Object.create(HTMLElement.prototype);
|
||||
|
||||
p.createdCallback = function() {
|
||||
ok(true, "createdCallback called.");
|
||||
};
|
||||
|
||||
p.attachedCallback = function() {
|
||||
ok(true, "attachedCallback should be called when the parser creates an element in the document.");
|
||||
attachedCallbackCount++;
|
||||
// attachedCallback should be called twice, once for the element created for innerHTML and
|
||||
// once for the element created in this document.
|
||||
if (attachedCallbackCount == 2) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
document.registerElement("x-foo", { prototype: p });
|
||||
|
||||
var container = document.getElementById("container");
|
||||
container.innerHTML = '<x-foo></x-foo>';
|
||||
|
||||
</script>
|
||||
|
||||
<x-foo></x-foo>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,11 +0,0 @@
|
||||
[attached-callback-test.html]
|
||||
type: testharness
|
||||
[Test attached callback if custom element is created via innerHTML property before registration. Document has no browsing context]
|
||||
expected: FAIL
|
||||
|
||||
[Test attached callback if custom element is unregistered]
|
||||
expected: FAIL
|
||||
|
||||
[Test attached callback. Registered element is created via innerHTML property. Document has browsing context]
|
||||
expected: FAIL
|
||||
|
@ -1,17 +1,8 @@
|
||||
[created-callback-invocation-order-test.html]
|
||||
type: testharness
|
||||
[Test attached callback is enqueued after created callback]
|
||||
expected: FAIL
|
||||
|
||||
[Test attributeChanged callback is not enqueued before created callback started. Document has browsing context]
|
||||
expected: FAIL
|
||||
|
||||
[Test attached callback is enqueued after created callback, but before created callback had started]
|
||||
expected: FAIL
|
||||
|
||||
[Test attached callback is enqueued after created callback had started]
|
||||
expected: FAIL
|
||||
|
||||
[Test detached callback is enqueued after created callback had started]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user