haikuwebkit/LayoutTests/fast/custom-elements/disconnected-callback-in-de...

47 lines
1.7 KiB
HTML
Raw Permalink Normal View History

ASSERTION FAILED: m_items.isEmpty() in CustomElementReactionQueue destructor https://bugs.webkit.org/show_bug.cgi?id=162029 <rdar://problem/28945851> Reviewed by Chris Dumez. Source/WebCore: The bug was caused by Document::removedLastRef enqueuing disconnectedCallback during a tear down. Don't enqueue a disconnectedCallback while a document is getting torn down since that should not be observable to author scripts. The connected, adopted, and attributeChanged callbacks are immune from this problem since they don't happen during a document destruction. Note that this was also the case prior to this patch since the disconnectedCallback would have been added to the current CustomElementReactionQueue which will be destructed without invoking callbacks (or hit a release assertion added in r208785 and r209426 for now). Tests: fast/custom-elements/disconnected-callback-in-detached-iframe.html fast/custom-elements/element-queue-during-document-destruction.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded): Added an assertion that document's refCount hasn't reached zero yet. (WebCore::CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded): Fixed the bug. (WebCore::CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded): Added the same assertion. (WebCore::CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded): Ditto. LayoutTests: Added a regression test that reliably reproduces the crash in DumpRenderTree / WebKitTestRunner. Also added a W3C style testharness.js test for the behavior I broke in an earlier iteration of the patch. * fast/custom-elements/disconnected-callback-in-detached-iframe-expected.txt: Added. * fast/custom-elements/disconnected-callback-in-detached-iframe.html: Added. * fast/custom-elements/element-queue-during-document-destruction-expected.txt: Added. * fast/custom-elements/element-queue-during-document-destruction.html: Added. Canonical link: https://commits.webkit.org/183241@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-09 00:53:32 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Custom Elements: disconnectedCallback must be enqueued inside a detached iframe</title>
<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
<meta name="assert" content="disconnectedCallback must be enqueued inside a detached iframe">
<meta name="help" content="https://dom.spec.whatwg.org/#concept-node-remove">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
Layout tests outside of the WPT import should not use resources from it https://bugs.webkit.org/show_bug.cgi?id=212661 Reviewed by Youenn Fablet. Some layout tests were using resource files from the imported WPT tests. This is an issue because updating the WPT tests may break this tests in the future. To fix this the used resource files are copied inside the main folder of each test and the tests modified to use them. On top of that, some tests are de-duplicates (in favor of the WPT versions, which are the same). This is the list of tests de-duplicated: canvas/philip/tests/2d.drawImage.incomplete.emptysrc.html -> imported/w3c/web-platform-tests/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.incomplete.emptysrc.html canvas/philip/tests/2d.drawImage.incomplete.nosrc.html -> imported/w3c/web-platform-tests/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.incomplete.nosrc.html canvas/philip/tests/2d.drawImage.incomplete.removedsrc.html -> imported/w3c/web-platform-tests/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.incomplete.removedsrc.html canvas/philip/tests/2d.pattern.image.incomplete.emptysrc.html -> imported/w3c/web-platform-tests/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.incomplete.emptysrc.html canvas/philip/tests/2d.pattern.image.incomplete.removedsrc.html -> imported/w3c/web-platform-tests/html/canvas/element/fill-and-stroke-styles/2d.pattern.image.incomplete.removedsrc.html fast/shadow-dom/capturing-and-bubbling-event-listeners-across-shadow-trees.html -> imported/w3c/web-platform-tests/shadow-dom/capturing-and-bubbling-event-listeners-across-shadow-trees.html * canvas/philip/tests/2d.drawImage.incomplete.emptysrc-expected.txt: Removed. * canvas/philip/tests/2d.drawImage.incomplete.emptysrc.html: Removed. * canvas/philip/tests/2d.drawImage.incomplete.nosrc-expected.txt: Removed. * canvas/philip/tests/2d.drawImage.incomplete.nosrc.html: Removed. * canvas/philip/tests/2d.drawImage.incomplete.removedsrc-expected.txt: Removed. * canvas/philip/tests/2d.drawImage.incomplete.removedsrc.html: Removed. * canvas/philip/tests/2d.pattern.image.incomplete.emptysrc-expected.txt: Removed. * canvas/philip/tests/2d.pattern.image.incomplete.emptysrc.html: Removed. * canvas/philip/tests/2d.pattern.image.incomplete.removedsrc-expected.txt: Removed. * canvas/philip/tests/2d.pattern.image.incomplete.removedsrc.html: Removed. * fast/css/resources/shadow-helper.js: Added. (getElementByShadowIds): (ceClass.): (installCustomElement): * fast/css/shadow-parts/exportparts-syntax.html: * fast/css/shadow-parts/invalidation-class-before-after.html: * fast/css/shadow-parts/invalidation-class-descendant-combinator-export.html: * fast/css/shadow-parts/invalidation-class-descendant-combinator.html: * fast/css/shadow-parts/invalidation-class-sibling-combinator-export.html: * fast/css/shadow-parts/invalidation-class-sibling-combinator.html: * fast/custom-elements/DOMImplementation-createDocument.html: * fast/custom-elements/adopting-from-frameless-document.html: * fast/custom-elements/disconnected-callback-in-detached-iframe.html: * fast/custom-elements/document-createElementNS.html: * fast/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html: * fast/custom-elements/perform-microtask-checkpoint-before-construction.html: * fast/custom-elements/reactions-for-webkit-extensions.html: * fast/custom-elements/resources/custom-elements-helpers.js: Added. (create_window_in_test): (test_with_window): (prototype.attributeChangedCallback): (prototype.connectedCallback): (prototype.disconnectedCallback): (prototype.adoptedCallback): (return.takeLog): (create_constructor_log): (assert_constructor_log_entry): (create_connected_callback_log): (assert_connected_log_entry): (create_disconnected_callback_log): (assert_disconnected_log_entry): (assert_adopted_log_entry): (create_adopted_callback_log): (create_attribute_changed_callback_log): (assert_attribute_log_entry): (define_new_custom_element.CustomElement): (define_new_custom_element.CustomElement.prototype.attributeChangedCallback): (define_new_custom_element.CustomElement.prototype.connectedCallback): (define_new_custom_element.CustomElement.prototype.disconnectedCallback): (define_new_custom_element.CustomElement.prototype.adoptedCallback): (define_new_custom_element.return.takeLog): (CustomElement): (CustomElement.prototype.attributeChangedCallback): (CustomElement.prototype.connectedCallback): (CustomElement.prototype.disconnectedCallback): (CustomElement.prototype.adoptedCallback): * fast/custom-elements/resources/reactions.js: Added. (testNodeConnector): (testNodeDisconnector): (testInsertingMarkup): (testParsingMarkup): (prototype.test): (testReflectBooleanAttribute): (testAttributeAdder): * fast/custom-elements/throw-on-dynamic-markup-insertion-counter-construct.html: * fast/custom-elements/throw-on-dynamic-markup-insertion-counter-reactions.html: * fast/images/resources/green-256x256.png: Added. * fast/images/sizes-dynamic-001-expected.html: * fast/images/sizes-dynamic-001.html: * fast/images/sizes-dynamic-002-expected.html: * fast/images/sizes-dynamic-002.html: * fast/shadow-dom/capturing-and-bubbling-event-listeners-across-shadow-trees-expected.txt: Removed. * fast/shadow-dom/capturing-and-bubbling-event-listeners-across-shadow-trees.html: Removed. * mathml/non-core/frac-linethickness-001-expected.html: * mathml/non-core/frac-linethickness-001.html: * mathml/non-core/frac-linethickness-002-expected.html: * mathml/non-core/frac-linethickness-002.html: * mathml/non-core/lengths-1.html: * mathml/non-core/lengths-2.html: * mathml/non-core/lengths-3.html: * mathml/presentation/radical-bar-visibility.html: * mathml/resources/fraction-rulethickness10000.woff: Added. * mathml/resources/radical-degreebottomraisepercent25-rulethickness1000.woff: Added. * mathml/resources/xheight500.woff: Added. Canonical link: https://commits.webkit.org/225809@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-10 15:35:24 +00:00
<script src="resources/custom-elements-helpers.js"></script>
<script src="resources/reactions.js"></script>
ASSERTION FAILED: m_items.isEmpty() in CustomElementReactionQueue destructor https://bugs.webkit.org/show_bug.cgi?id=162029 <rdar://problem/28945851> Reviewed by Chris Dumez. Source/WebCore: The bug was caused by Document::removedLastRef enqueuing disconnectedCallback during a tear down. Don't enqueue a disconnectedCallback while a document is getting torn down since that should not be observable to author scripts. The connected, adopted, and attributeChanged callbacks are immune from this problem since they don't happen during a document destruction. Note that this was also the case prior to this patch since the disconnectedCallback would have been added to the current CustomElementReactionQueue which will be destructed without invoking callbacks (or hit a release assertion added in r208785 and r209426 for now). Tests: fast/custom-elements/disconnected-callback-in-detached-iframe.html fast/custom-elements/element-queue-during-document-destruction.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded): Added an assertion that document's refCount hasn't reached zero yet. (WebCore::CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded): Fixed the bug. (WebCore::CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded): Added the same assertion. (WebCore::CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded): Ditto. LayoutTests: Added a regression test that reliably reproduces the crash in DumpRenderTree / WebKitTestRunner. Also added a W3C style testharness.js test for the behavior I broke in an earlier iteration of the patch. * fast/custom-elements/disconnected-callback-in-detached-iframe-expected.txt: Added. * fast/custom-elements/disconnected-callback-in-detached-iframe.html: Added. * fast/custom-elements/element-queue-during-document-destruction-expected.txt: Added. * fast/custom-elements/element-queue-during-document-destruction.html: Added. Canonical link: https://commits.webkit.org/183241@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209582 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-12-09 00:53:32 +00:00
</head>
<body>
<div id="log"></div>
<script>
function create_iframe_and_wait_for_onload() {
return new Promise(function (resolve) {
let iframe = document.createElement('iframe');
iframe.onload = function () { resolve(iframe); }
document.body.appendChild(iframe);
});
}
let element = define_custom_element_in_window(window, 'test-element');
promise_test(() => {
return create_iframe_and_wait_for_onload().then((iframe) => {
let testElement = document.createElement('test-element');
assert_array_equals(element.takeLog().types(), ['constructed']);
let contentDocument = iframe.contentDocument;
iframe.contentDocument.body.appendChild(testElement);
assert_array_equals(element.takeLog().types(), ['adopted', 'connected']);
iframe.remove();
assert_array_equals(element.takeLog().types(), []);
contentDocument.body.remove();
assert_array_equals(element.takeLog().types(), ['disconnected']);
});
}, 'Removing a custom element inside a detached iframe must enqueue disconnectedCallback');
</script>
</body>
</html>