Add Sony to domain affiliations on team page
[WebKit-https.git] / Websites / perf.webkit.org / browser-tests / editable-text-tests.js
index 0cdf8f89f2592bf933e57806f0df7619b57d4f45..cfed690d6186f4c24d0f955922e5191fd65bd844 100644 (file)
@@ -2,27 +2,6 @@
 describe('EditableText', () => {
     const scripts = ['instrumentation.js', 'components/base.js', 'components/editable-text.js'];
 
-    function waitToRender(context)
-    {
-        if (!context._dummyComponent) {
-            const ComponentBase = context.symbols.ComponentBase;
-            context._dummyComponent = class SomeComponent extends ComponentBase {
-                constructor(resolve)
-                {
-                    super();
-                    this._resolve = resolve;
-                }
-                render() { setTimeout(this._resolve, 0); }
-            }
-            ComponentBase.defineElement('dummy-component', context._dummyComponent);
-        }
-        return new Promise((resolve) => {
-            const instance = new context._dummyComponent(resolve);
-            context.document.body.appendChild(instance.element());
-            instance.enqueueToRender();
-        });
-    }
-
     it('show the set text', () => {
         const context = new BrowsingContext();
         let editableText;
@@ -31,14 +10,14 @@ describe('EditableText', () => {
             editableText = new EditableText;
             context.document.body.appendChild(editableText.element());
             editableText.enqueueToRender();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
-            expect(editableText.content().textContent).toNotInclude('hello');
+            expect(editableText.content().textContent).to.not.contain('hello');
             editableText.setText('hello');
             editableText.enqueueToRender();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
-            expect(editableText.content().textContent).toInclude('hello');
+            expect(editableText.content().textContent).to.contain('hello');
         });
     });
 
@@ -51,18 +30,18 @@ describe('EditableText', () => {
             context.document.body.appendChild(editableText.element());
             editableText.setText('hello');
             editableText.enqueueToRender();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
-            expect(editableText.content().querySelector('input').offsetHeight).toBe(0);
-            expect(editableText.content().textContent).toInclude('hello');
-            expect(editableText.content().querySelector('a').textContent).toInclude('Edit');
-            expect(editableText.content().querySelector('a').textContent).toNotInclude('Save');
+            expect(editableText.content().querySelector('input').offsetHeight).to.be(0);
+            expect(editableText.content().textContent).to.contain('hello');
+            expect(editableText.content().querySelector('a').textContent).to.contain('Edit');
+            expect(editableText.content().querySelector('a').textContent).to.not.contain('Save');
             editableText.content().querySelector('a').click();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
-            expect(editableText.content().querySelector('input').offsetHeight).toNotBe(0);
-            expect(editableText.content().querySelector('a').textContent).toNotInclude('Edit');
-            expect(editableText.content().querySelector('a').textContent).toInclude('Save');
+            expect(editableText.content().querySelector('input').offsetHeight).to.not.be(0);
+            expect(editableText.content().querySelector('a').textContent).to.not.contain('Edit');
+            expect(editableText.content().querySelector('a').textContent).to.contain('Save');
         });
     });
 
@@ -77,21 +56,21 @@ describe('EditableText', () => {
             editableText.setText('hello');
             editableText.enqueueToRender();
             editableText.listenToAction('update', () => updateCount++);
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             editableText.content().querySelector('a').click();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             const input = editableText.content().querySelector('input');
-            expect(input.offsetHeight).toNotBe(0);
-            expect(editableText.editedText()).toBe('hello');
+            expect(input.offsetHeight).to.not.be(0);
+            expect(editableText.editedText()).to.be('hello');
             input.value = 'world';
-            expect(editableText.editedText()).toBe('world');
-            expect(updateCount).toBe(0);
+            expect(editableText.editedText()).to.be('world');
+            expect(updateCount).to.be(0);
             editableText.content().querySelector('a').click();
-            expect(updateCount).toBe(1);
-            expect(editableText.editedText()).toBe('world');
-            expect(editableText.text()).toBe('hello');
+            expect(updateCount).to.be(1);
+            expect(editableText.editedText()).to.be('world');
+            expect(editableText.text()).to.be('hello');
         });
     });
 
@@ -106,27 +85,27 @@ describe('EditableText', () => {
             editableText.setText('hello');
             editableText.enqueueToRender();
             editableText.listenToAction('update', () => updateCount++);
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             editableText.content().querySelector('a').click();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             const input = editableText.content().querySelector('input');
-            expect(input.offsetHeight).toNotBe(0);
-            expect(editableText.editedText()).toBe('hello');
+            expect(input.offsetHeight).to.not.be(0);
+            expect(editableText.editedText()).to.be('hello');
             input.value = 'world';
-            expect(updateCount).toBe(0);
+            expect(updateCount).to.be(0);
 
             const focusableElement = document.createElement('div');
             focusableElement.setAttribute('tabindex', 0);
             document.body.appendChild(focusableElement);
             focusableElement.focus();
 
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
-            expect(editableText.content().querySelector('input').offsetHeight).toBe(0);
-            expect(editableText.text()).toBe('hello');
-            expect(updateCount).toBe(0);
+            expect(editableText.content().querySelector('input').offsetHeight).to.be(0);
+            expect(editableText.text()).to.be('hello');
+            expect(updateCount).to.be(0);
         });
     });
 
@@ -141,23 +120,23 @@ describe('EditableText', () => {
             editableText.setText('hello');
             editableText.enqueueToRender();
             editableText.listenToAction('update', () => updateCount++);
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             editableText.content().querySelector('a').click();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             const input = editableText.content().querySelector('input');
-            expect(input.offsetHeight).toNotBe(0);
-            expect(editableText.editedText()).toBe('hello');
+            expect(input.offsetHeight).to.not.be(0);
+            expect(editableText.editedText()).to.be('hello');
             input.value = 'world';
-            expect(updateCount).toBe(0);
+            expect(updateCount).to.be(0);
             editableText.content().querySelector('a').focus();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
-            expect(editableText.content().querySelector('input').offsetHeight).toNotBe(0);
+            expect(editableText.content().querySelector('input').offsetHeight).to.not.be(0);
             editableText.content().querySelector('a').click();
-            expect(editableText.editedText()).toBe('world');
-            expect(updateCount).toBe(1);
+            expect(editableText.editedText()).to.be('world');
+            expect(updateCount).to.be(1);
         });
     });
 
@@ -172,28 +151,28 @@ describe('EditableText', () => {
             editableText.setText('hello');
             editableText.enqueueToRender();
             editableText.listenToAction('update', () => updateCount++);
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             editableText.content('action-button').click();
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
             const input = editableText.content('text-field');
-            expect(input.offsetHeight).toNotBe(0);
-            expect(editableText.editedText()).toBe('hello');
+            expect(input.offsetHeight).to.not.be(0);
+            expect(editableText.editedText()).to.be('hello');
             input.value = 'world';
-            expect(updateCount).toBe(0);
-            return waitToRender(context);
+            expect(updateCount).to.be(0);
+            return waitForComponentsToRender(context);
         }).then(() => {
             editableText.content('action-button').dispatchEvent(new MouseEvent('mousedown'));
-            return new Promise((resolve) => setTimeout(resolve, 0));
+            return wait(0);
         }).then(() => {
             editableText.content('text-field').blur();
             editableText.content('action-button').dispatchEvent(new MouseEvent('mouseup'));
-            return waitToRender(context);
+            return waitForComponentsToRender(context);
         }).then(() => {
-            expect(editableText.content('text-field').offsetHeight).toBe(0);
-            expect(updateCount).toBe(1);
-            expect(editableText.editedText()).toBe('world');
+            expect(editableText.content('text-field').offsetHeight).to.be(0);
+            expect(updateCount).to.be(1);
+            expect(editableText.editedText()).to.be('world');
         });
     });