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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reactions/Document.html

Issue 2446483002: Import wpt@c5a14f553cba5f197743b9af605a84eddd8692a2 (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Custom Elements: CEReactions on ParentNode interface</title> 4 <title>Custom Elements: CEReactions on Document interface</title>
5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> 5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
6 <meta name="assert" content="importNode and adoptNode of Document interface must have CEReactions"> 6 <meta name="assert" content="importNode and adoptNode of Document interface must have CEReactions">
7 <meta name="help" content="https://dom.spec.whatwg.org/#document"> 7 <meta name="help" content="https://dom.spec.whatwg.org/#document">
8 <meta name="help" content="https://html.spec.whatwg.org/#document">
8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script> 10 <script src="/resources/testharnessreport.js"></script>
10 <script src="../resources/custom-elements-helpers.js"></script> 11 <script src="../resources/custom-elements-helpers.js"></script>
11 <script src="./resources/reactions.js"></script> 12 <script src="./resources/reactions.js"></script>
12 </head> 13 </head>
13 <body> 14 <body>
14 <div id="log"></div> 15 <div id="log"></div>
15 <script> 16 <script>
16 17
17 test(function () { 18 test(function () {
18 var element = define_new_custom_element(); 19 var element = define_new_custom_element();
19 var instance = document.createElement(element.name); 20 var instance = document.createElement(element.name);
20 assert_array_equals(element.takeLog().types(), ['constructed']); 21 assert_array_equals(element.takeLog().types(), ['constructed']);
21 22
22 var newDoc = document.implementation.createHTMLDocument(); 23 var newDoc = document.implementation.createHTMLDocument();
23 newDoc.importNode(instance); 24 newDoc.importNode(instance);
24 25
25 var logEntries = element.takeLog(); 26 assert_array_equals(element.takeLog().types(), []);
26 assert_array_equals(logEntries.types(), ['constructed']); 27 }, 'importNode on Document must not construct a new custom element when importin g a custom element into a window-less document');
27 assert_equals(logEntries.last().oldDocument, document);
28 assert_equals(logEntries.last().newDocument, newDoc);
29 }, 'importNode on Document must construct a new custom element when importing a custom element');
30 28
31 test(function () { 29 test(function () {
32 var element = define_new_custom_element(); 30 var element = define_new_custom_element();
31 var template = document.createElement('template');
32 template.innerHTML = `<${element.name}></${element.name}>`;
33 assert_array_equals(element.takeLog().types(), []);
34 document.importNode(template.content, true);
35 assert_array_equals(element.takeLog().types(), ['constructed']);
36 }, 'importNode on Document must construct a new custom element when importing a custom element from a template');
37
38 test(function () {
39 var element = define_new_custom_element();
33 var instance = document.createElement(element.name); 40 var instance = document.createElement(element.name);
34 assert_array_equals(element.takeLog().types(), ['constructed']); 41 assert_array_equals(element.takeLog().types(), ['constructed']);
35 42
36 var newDoc = document.implementation.createHTMLDocument(); 43 var newDoc = document.implementation.createHTMLDocument();
37 newDoc.adoptNode(instance); 44 newDoc.adoptNode(instance);
38 45
39 var logEntries = element.takeLog(); 46 var logEntries = element.takeLog();
40 assert_array_equals(logEntries.types(), ['adopted']); 47 assert_array_equals(logEntries.types(), ['adopted']);
41 assert_equals(logEntries.last().oldDocument, document); 48 assert_equals(logEntries.last().oldDocument, document);
42 assert_equals(logEntries.last().newDocument, newDoc); 49 assert_equals(logEntries.last().newDocument, newDoc);
43 }, 'adoptNode on Document must enqueue an adopted reaction when importing a cust om element'); 50 }, 'adoptNode on Document must enqueue an adopted reaction when importing a cust om element');
44 51
52 test(function () {
53 var element = define_new_custom_element();
54 var instance = document.createElement(element.name);
55
56 var container = document.createElement('div');
57 container.contentEditable = true;
58 container.appendChild(instance);
59 document.body.appendChild(container);
60
61 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ;
62
63 container.focus();
64 document.execCommand('delete', false, null);
65
66 assert_array_equals(element.takeLog().types(), ['disconnected']);
67 }, 'execCommand on Document must enqueue a disconnected reaction when deleting a custom element from a contenteditable element');
68
45 </script> 69 </script>
46 </body> 70 </body>
47 </html> 71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698