| Index: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reactions/Document.html
|
| diff --git a/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reactions/Document.html b/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reactions/Document.html
|
| index 13f0d81b9eac44cf1026c8b63ce215f0404b55db..0d60f06e15d275e47b1b2c16f92ff06bc708d5fc 100644
|
| --- a/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reactions/Document.html
|
| +++ b/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reactions/Document.html
|
| @@ -15,57 +15,101 @@
|
| <div id="log"></div>
|
| <script>
|
|
|
| -test(function () {
|
| - var element = define_new_custom_element();
|
| - var instance = document.createElement(element.name);
|
| +test_with_window(function (contentWindow, contentDocument) {
|
| + const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
|
| + const instance = contentDocument.createElement('custom-element');
|
| assert_array_equals(element.takeLog().types(), ['constructed']);
|
|
|
| - var newDoc = document.implementation.createHTMLDocument();
|
| + const newDoc = contentDocument.implementation.createHTMLDocument();
|
| newDoc.importNode(instance);
|
|
|
| assert_array_equals(element.takeLog().types(), []);
|
| }, 'importNode on Document must not construct a new custom element when importing a custom element into a window-less document');
|
|
|
| -test(function () {
|
| - var element = define_new_custom_element();
|
| - var template = document.createElement('template');
|
| - template.innerHTML = `<${element.name}></${element.name}>`;
|
| +test_with_window(function (contentWindow, contentDocument) {
|
| + const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
|
| + const template = contentDocument.createElement('template');
|
| + template.innerHTML = '<custom-element></custom-element>';
|
| assert_array_equals(element.takeLog().types(), []);
|
| - document.importNode(template.content, true);
|
| + contentDocument.importNode(template.content, true);
|
| assert_array_equals(element.takeLog().types(), ['constructed']);
|
| }, 'importNode on Document must construct a new custom element when importing a custom element from a template');
|
|
|
| -test(function () {
|
| - var element = define_new_custom_element();
|
| - var instance = document.createElement(element.name);
|
| +test_with_window(function (contentWindow, contentDocument) {
|
| + const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
|
| + const instance = contentDocument.createElement('custom-element');
|
| assert_array_equals(element.takeLog().types(), ['constructed']);
|
|
|
| - var newDoc = document.implementation.createHTMLDocument();
|
| + const newDoc = contentDocument.implementation.createHTMLDocument();
|
| newDoc.adoptNode(instance);
|
|
|
| - var logEntries = element.takeLog();
|
| + const logEntries = element.takeLog();
|
| assert_array_equals(logEntries.types(), ['adopted']);
|
| - assert_equals(logEntries.last().oldDocument, document);
|
| + assert_equals(logEntries.last().oldDocument, contentDocument);
|
| assert_equals(logEntries.last().newDocument, newDoc);
|
| }, 'adoptNode on Document must enqueue an adopted reaction when importing a custom element');
|
|
|
| -test(function () {
|
| - var element = define_new_custom_element();
|
| - var instance = document.createElement(element.name);
|
| +test_with_window(function (contentWindow, contentDocument) {
|
| + const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
|
| + const instance = contentDocument.createElement('custom-element');
|
|
|
| - var container = document.createElement('div');
|
| + const container = contentDocument.createElement('div');
|
| container.contentEditable = true;
|
| container.appendChild(instance);
|
| - document.body.appendChild(container);
|
| + contentDocument.body.appendChild(container);
|
|
|
| assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
|
|
|
| container.focus();
|
| - document.execCommand('delete', false, null);
|
| + contentDocument.execCommand('delete', false, null);
|
|
|
| assert_array_equals(element.takeLog().types(), ['disconnected']);
|
| }, 'execCommand on Document must enqueue a disconnected reaction when deleting a custom element from a contenteditable element');
|
|
|
| +test_with_window(function (contentWindow, contentDocument) {
|
| + const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
|
| +
|
| + contentDocument.title = '';
|
| + const title = contentDocument.querySelector('title');
|
| + const instance = contentDocument.createElement('custom-element');
|
| + title.appendChild(instance);
|
| + instance.textContent = 'hello';
|
| +
|
| + assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
|
| + assert_equals(title.innerHTML, '<custom-element>hello</custom-element>');
|
| +
|
| + title.text = 'world';
|
| + assert_equals(title.innerHTML, 'world');
|
| + assert_array_equals(element.takeLog().types(), ['disconnected']);
|
| +}, 'title on Document must enqueue disconnectedCallback when removing a custom element');
|
| +
|
| +test_with_window(function (contentWindow, contentDocument) {
|
| + const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
|
| +
|
| + const body = contentDocument.body;
|
| + body.innerHTML = '<custom-element>hello</custom-element>';
|
| +
|
| + assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
|
| + assert_equals(body.innerHTML, '<custom-element>hello</custom-element>');
|
| +
|
| + contentDocument.body = contentDocument.createElement('body');
|
| + assert_array_equals(element.takeLog().types(), ['disconnected']);
|
| +}, 'body on Document must enqueue disconnectedCallback when removing a custom element');
|
| +
|
| +test_with_window(function (contentWindow, contentDocument) {
|
| + const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
|
| +
|
| + const instance = contentDocument.createElement('custom-element');
|
| + const body = contentDocument.createElement('body');
|
| + body.appendChild(instance);
|
| +
|
| + assert_array_equals(element.takeLog().types(), ['constructed']);
|
| + assert_equals(body.innerHTML, '<custom-element></custom-element>');
|
| +
|
| + contentDocument.body = body;
|
| + assert_array_equals(element.takeLog().types(), ['connected']);
|
| +}, 'body on Document must enqueue connectedCallback when inserting a custom element');
|
| +
|
| </script>
|
| </body>
|
| </html>
|
|
|