Bug 1113959 - Do not enqueue custom element attached and detached callbacks when there is no browsing context. r=smaug

This commit is contained in:
William Chen 2014-12-22 22:35:32 -08:00
parent c83bdf33f5
commit 5b6b5d74fd
4 changed files with 6 additions and 31 deletions

View File

@ -1461,7 +1461,9 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// Being added to a document.
SetInDocument();
if (GetCustomElementData()) {
// Attached callback must be enqueued whenever custom element is inserted into a
// document and this document has a browsing context.
if (GetCustomElementData() && aDocument->GetDocShell()) {
// Enqueue an attached callback for the custom element.
aDocument->EnqueueLifecycleCallback(nsIDocument::eAttached, this);
}
@ -1673,7 +1675,9 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
document->ClearBoxObjectFor(this);
if (GetCustomElementData()) {
// Detached must be enqueued whenever custom element is removed from
// the document and this document has a browsing context.
if (GetCustomElementData() && document->GetDocShell()) {
// Enqueue a detached callback for the custom element.
document->EnqueueLifecycleCallback(nsIDocument::eDetached, this);
}

View File

@ -1,14 +1,8 @@
[attached-callback-move-element-test.html]
type: testharness
[Test attached callback if moving custom element inside document without browsing context]
expected: FAIL
[Test attached callback if moving custom element from document without browsing context to document with browsing context]
expected: FAIL
[Test attached callback if moving custom element from document with browsing context to document without browsing context]
expected: FAIL
[Test attached callback if moving custom element from document with browsing context to document with browsing context]
expected: FAIL

View File

@ -1,8 +0,0 @@
[detached-callback-move-element-test.html]
type: testharness
[Test detached callback is not called if moving custom element inside document without browsing context]
expected: FAIL
[Test detached callback is not called if moving custom element from document without browsing context to document with browsing context]
expected: FAIL

View File

@ -1,20 +1,5 @@
[detached-callback-no-browsing-context-test.html]
type: testharness
[Test detached callback if custom element is created via innerHTML property. Document has no browsing context]
expected: FAIL
[Test detached callback if custom element is via innerHTML property before registration of a custom element. Document has no browsing context]
expected: FAIL
[Test detached callback if removing custom element via innerHTML property. Document has no browsing context]
expected: FAIL
[Test detached callback if removing perent of custom element. Document has no browsing context]
expected: FAIL
[Test detached callback if removing perent of custom element via innerHTML property. Document has no browsing context]
expected: FAIL
[Test detached callback is not called, if document\'s window is navigated to another document and custom element is removed]
expected: FAIL