Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: LayoutTests/imported/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/detached-callback-with-browsing-context-test.html

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/imported/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/detached-callback-with-browsing-context-test.html
diff --git a/LayoutTests/imported/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/detached-callback-with-browsing-context-test.html b/LayoutTests/imported/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/detached-callback-with-browsing-context-test.html
new file mode 100644
index 0000000000000000000000000000000000000000..60835f2e6fdd0cd0af969b9140570584cad4b515
--- /dev/null
+++ b/LayoutTests/imported/web-platform-tests/custom-elements/custom-element-lifecycle/types-of-callbacks/detached-callback-with-browsing-context-test.html
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Detached callback of a custom element should be called if document has browsing context</title>
+<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
+<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
+<meta name="assert" content="detached callback ... must be enqueued whenever custom element is removed from the document and this document has a browsing context.">
+<link rel="help" href="http://www.w3.org/TR/custom-elements/#types-of-callbacks">
+<script src="../../../../../resources/testharness.js"></script>
+<script src="../../../../../resources/testharnessreport.js"></script>
+<script src="../../testcommon.js"></script>
+<link rel="stylesheet" href="../../../../../resources/testharness.css">
+</head>
+<body>
+<div id="log"></div>
+<script>
+testInIFrame('../../resources/x-element.html', function(doc) {
+ var proto = newHTMLElementPrototype();
+ doc.registerElement('x-element', {prototype: proto});
+ var customElement = doc.querySelector('#x-element');
+ doc.body.removeChild(customElement);
+ assert_equals(proto.detachedCallbackCalledCounter, 1, 'Callback detached should be ' +
+ 'called if custom element is removed from the document with browsing context');
+}, 'Test detached callback is called if custom element is removed by method removeChild() ' +
+ 'from document with browsing context');
+
+
+testInIFrame('../../resources/blank.html', function(doc) {
+ doc.body.innerHTML = '<div id="x-a-parent"><x-a id="x-a"></x-a></div>';
+ var proto = newHTMLElementPrototype();
+ doc.registerElement('x-a', {prototype: proto});
+ var div = doc.querySelector('#x-a-parent');
+ doc.body.removeChild(div);
+ assert_equals(proto.detachedCallbackCalledCounter, 1, 'Callback detached should be ' +
+ 'called if custom element is removed from the document with browsing context');
+}, 'Test detached callback is called if ancestor node of custom element ' +
+ 'is removed by method removeChild() from document with browsing context');
+
+
+testInIFrame('../../resources/x-element.html', function(doc) {
+ var proto = newHTMLElementPrototype();
+ doc.registerElement('x-element', {prototype: proto});
+ var customElement = doc.querySelector('#x-element');
+ var div = doc.createElement('div');
+ doc.body.replaceChild(div, customElement);
+ assert_equals(proto.detachedCallbackCalledCounter, 1, 'Callback detached should be ' +
+ 'called if custom element is removed from the document with browsing context');
+}, 'Test detached callback is called if custom element is removed by method replaceChild() ' +
+ 'from document with browsing context');
+
+
+testInIFrame('../../resources/blank.html', function(doc) {
+ var proto = newHTMLElementPrototype();
+ doc.registerElement('x-b', {prototype: proto});
+ doc.body.innerHTML = '<div id="x-b-parent"><x-b id="x-b"></x-b></div>';
+ var parent = doc.querySelector('#x-b-parent');
+ var replacement = doc.createElement('div');
+ doc.body.replaceChild(replacement, parent);
+ assert_equals(proto.detachedCallbackCalledCounter, 1, 'Callback detached should be ' +
+ 'called if custom element is removed from the document with browsing context');
+}, 'Test detached callback is called if ancestor node of custom element ' +
+ 'is removed by method replaceChild() from document with browsing context');
+
+
+testInIFrame('../../resources/x-element.html', function(doc) {
+ var proto = newHTMLElementPrototype();
+ doc.registerElement('x-element', {prototype: proto});
+ doc.body.innerHTML = '';
+ assert_equals(proto.detachedCallbackCalledCounter, 1, 'Callback detached should be ' +
+ 'called if custom element is removed from the document with browsing context');
+}, 'Test detached callback is called after changing custom element direct parent ' +
+ 'innerHTML property in the document with browsing context');
+
+
+testInIFrame('../../resources/blank.html', function(doc) {
+ doc.body.innerHTML = '<div><x-c></x-c></div>';
+ var proto = newHTMLElementPrototype();
+ doc.registerElement('x-c', {prototype: proto});
+ doc.body.innerHTML = '';
+ assert_equals(proto.detachedCallbackCalledCounter, 1, 'Callback detached should be ' +
+ 'called if custom element is removed from the document with browsing context');
+}, 'Test detached callback is called after changing custom element ancestor ' +
+ 'innerHTML property in the document with browsing context');
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698