| Index: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/resources/custom-elements-helpers.js
|
| diff --git a/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/resources/custom-elements-helpers.js b/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/resources/custom-elements-helpers.js
|
| index d8318ebda901756b5d50ad27729ee4c0acf15699..20ae66b4fae6b64f5de4a501098daeb76a0698d0 100644
|
| --- a/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/resources/custom-elements-helpers.js
|
| +++ b/third_party/WebKit/LayoutTests/imported/wpt/custom-elements/resources/custom-elements-helpers.js
|
| @@ -16,11 +16,69 @@ function test_with_window(f, name, srcdoc) {
|
| promise_test((t) => {
|
| return create_window_in_test(t, srcdoc)
|
| .then((w) => {
|
| - f(w);
|
| + f(w, w.document);
|
| });
|
| }, name);
|
| }
|
|
|
| +function define_custom_element_in_window(window, name, observedAttributes) {
|
| + let log = [];
|
| +
|
| + class CustomElement extends window.HTMLElement {
|
| + constructor() {
|
| + super();
|
| + log.push(create_constructor_log(this));
|
| + }
|
| + attributeChangedCallback(...args) {
|
| + log.push(create_attribute_changed_callback_log(this, ...args));
|
| + }
|
| + connectedCallback() { log.push(create_connected_callback_log(this)); }
|
| + disconnectedCallback() { log.push(create_disconnected_callback_log(this)); }
|
| + adoptedCallback(oldDocument, newDocument) { log.push({type: 'adopted', element: this, oldDocument: oldDocument, newDocument: newDocument}); }
|
| + }
|
| + CustomElement.observedAttributes = observedAttributes;
|
| +
|
| + window.customElements.define(name, CustomElement);
|
| +
|
| + return {
|
| + name: name,
|
| + class: CustomElement,
|
| + takeLog: function () {
|
| + let currentLog = log; log = [];
|
| + currentLog.types = () => currentLog.map((entry) => entry.type);
|
| + currentLog.last = () => currentLog[currentLog.length - 1];
|
| + return currentLog;
|
| + }
|
| + };
|
| +}
|
| +
|
| +function create_constructor_log(element) {
|
| + return {type: 'constructed', element: element};
|
| +}
|
| +
|
| +function assert_constructor_log_entry(log, element) {
|
| + assert_equals(log.type, 'constructed');
|
| + assert_equals(log.element, element);
|
| +}
|
| +
|
| +function create_connected_callback_log(element) {
|
| + return {type: 'connected', element: element};
|
| +}
|
| +
|
| +function assert_connected_log_entry(log, element) {
|
| + assert_equals(log.type, 'connected');
|
| + assert_equals(log.element, element);
|
| +}
|
| +
|
| +function create_disconnected_callback_log(element) {
|
| + return {type: 'disconnected', element: element};
|
| +}
|
| +
|
| +function assert_disconnected_log_entry(log, element) {
|
| + assert_equals(log.type, 'disconnected');
|
| + assert_equals(log.element, element);
|
| +}
|
| +
|
| function create_attribute_changed_callback_log(element, name, oldValue, newValue, namespace) {
|
| return {
|
| type: 'attributeChanged',
|
|
|