From 4d36a203c09d2e04bf4304ba4a5b63f66b3e2adf Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sat, 21 Sep 2019 15:32:30 +0900 Subject: [PATCH 01/18] Use latest lanthan --- e2e/blacklist.test.js | 37 +++++----- e2e/clipboard.test.js | 48 ++++++------- e2e/command_addbookmark.test.js | 37 +++++----- e2e/command_bdelete.test.js | 102 +++++++++++++-------------- e2e/command_buffer.test.js | 120 +++++++++++++++----------------- e2e/command_open.test.js | 67 +++++++++--------- e2e/command_quit.test.js | 66 +++++++++--------- e2e/command_tabopen.test.js | 67 +++++++++--------- e2e/command_winopen.test.js | 68 +++++++++--------- e2e/completion.test.js | 51 +++++++------- e2e/completion_buffers.test.js | 67 +++++++++--------- e2e/completion_open.test.js | 77 ++++++++++---------- e2e/completion_set.test.js | 36 +++++----- e2e/console.test.js | 73 +++++++++---------- e2e/follow.test.js | 108 ++++++++++++++-------------- e2e/follow_properties.test.js | 80 +++++++++++---------- e2e/lib/Console.js | 12 ++-- e2e/mark.test.js | 71 ++++++++++--------- e2e/navigate.test.js | 102 +++++++++++++-------------- e2e/options.test.js | 50 +++++++------ e2e/options_form.test.js | 67 +++++++++--------- e2e/repeat.test.js | 43 ++++++------ e2e/scroll.test.js | 97 +++++++++++++------------- e2e/tab.test.js | 72 ++++++++++--------- e2e/zoom.test.js | 28 ++++---- 25 files changed, 814 insertions(+), 832 deletions(-) diff --git a/e2e/blacklist.test.js b/e2e/blacklist.test.js index fa8e8db..8a8996e 100644 --- a/e2e/blacklist.test.js +++ b/e2e/blacklist.test.js @@ -1,8 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const settings = require('./settings'); +const { Builder } = require('lanthan'); +const { By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -19,26 +20,24 @@ describe("navigate test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } http.close(); }); @@ -56,21 +55,21 @@ describe("navigate test", () => { }, }); - await session.navigateTo(`http://127.0.0.1:${port}/a`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/a`); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('j'); // not works - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageYOffset, 0); - await session.navigateTo(`http://127.0.0.1:${port}/ab`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/ab`); + body = await webdriver.findElement(By.css('body')); await body.sendKeys('j'); // works - pageYOffset = await session.executeScript(() => window.pageYOffset); + pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageYOffset, 64); }); }); diff --git a/e2e/clipboard.test.js b/e2e/clipboard.test.js index 82e45fc..df31770 100644 --- a/e2e/clipboard.test.js +++ b/e2e/clipboard.test.js @@ -1,12 +1,11 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const clipboard = require('./lib/clipboard'); const settings = require('./settings'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -20,18 +19,19 @@ describe("navigate test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); await browser.storage.local.set({ settings, @@ -39,8 +39,8 @@ describe("navigate test", () => { }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } http.close(); }); @@ -53,8 +53,8 @@ describe("navigate test", () => { }) it('should copy current URL by y', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/#should_copy_url`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/#should_copy_url`); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('y'); await eventually(async() => { @@ -64,8 +64,8 @@ describe("navigate test", () => { }); it('should open an URL from clipboard by p', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/`); + let body = await webdriver.findElement(By.css('body')); await clipboard.write(`http://127.0.0.1:${port}/#open_from_clipboard`); await body.sendKeys('p'); @@ -77,11 +77,11 @@ describe("navigate test", () => { }); it('should open an URL from clipboard to new tab by P', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/`); + let body = await webdriver.findElement(By.css('body')); await clipboard.write(`http://127.0.0.1:${port}/#open_to_new_tab`); - await body.sendKeys(Key.Shift, 'p'); + await body.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -93,8 +93,8 @@ describe("navigate test", () => { }); it('should open search result with keywords in clipboard by p', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/`); + let body = await webdriver.findElement(By.css('body')); await clipboard.write(`an apple`); await body.sendKeys('p'); @@ -106,11 +106,11 @@ describe("navigate test", () => { }); it('should open search result with keywords in clipboard to new tabby P', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/`); + let body = await webdriver.findElement(By.css('body')); await clipboard.write(`an apple`); - await body.sendKeys(Key.Shift, 'p'); + await body.sendKeys(Key.SHIFT, 'p'); await eventually(async() => { let tabs = await browser.tabs.query({}); diff --git a/e2e/command_addbookmark.test.js b/e2e/command_addbookmark.test.js index e8995bc..68d1c6d 100644 --- a/e2e/command_addbookmark.test.js +++ b/e2e/command_addbookmark.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -22,41 +21,39 @@ const newApp = () => { describe('addbookmark command test', () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); beforeEach(async() => { - await session.navigateTo(`http://127.0.0.1:${port}/happy`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/happy`); }); it('should add a bookmark from the current page', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('addbookmark how to be happy', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('addbookmark how to be happy', Key.ENTER); await eventually(async() => { var bookmarks = await browser.bookmarks.search({ title: 'how to be happy' }); diff --git a/e2e/command_bdelete.test.js b/e2e/command_bdelete.test.js index 1f416db..aae5b67 100644 --- a/e2e/command_bdelete.test.js +++ b/e2e/command_bdelete.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -23,27 +22,24 @@ const newApp = () => { describe('bdelete/bdeletes command test', () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); @@ -59,22 +55,22 @@ describe('bdelete/bdeletes command test', () => { await browser.tabs.create({ url: `http://127.0.0.1:${port}/site5` }) await eventually(async() => { - let handles = await session.getWindowHandles(); + let handles = await webdriver.getAllWindowHandles(); assert.equal(handles.length, 5); - await session.switchToWindow(handles[2]); - await session.findElementByCSS('iframe'); + await webdriver.switchTo().window(handles[2]); + await webdriver.findElement(By.css('iframe')); }); await new Promise((resolve) => setTimeout(resolve, 100)); }); it('should delete an unpinned tab by bdelete command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdelete site5', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdelete site5', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -88,12 +84,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should not delete an pinned tab by bdelete command by bdelete command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdelete site1', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdelete site1', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -102,42 +98,42 @@ describe('bdelete/bdeletes command test', () => { }); it('should show an error when no tabs are matched by bdelete command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdelete xyz', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdelete xyz', Key.ENTER); await eventually(async() => { - let p = await session.findElementByCSS('.vimvixen-console-error'); + let p = await webdriver.findElement(By.css('.vimvixen-console-error')); let text = await p.getText(); assert.equal(text, 'No matching buffer for xyz'); }); }); it('should show an error when more than one tabs are matched by bdelete command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdelete site', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdelete site', Key.ENTER); await eventually(async() => { - let p = await session.findElementByCSS('.vimvixen-console-error'); + let p = await webdriver.findElement(By.css('.vimvixen-console-error')); let text = await p.getText(); assert.equal(text, 'More than one match for site'); }); }); it('should delete an unpinned tab by bdelete! command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdelete! site5', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdelete! site5', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -151,12 +147,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete an pinned tab by bdelete! command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdelete! site1', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdelete! site1', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -170,12 +166,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete unpinned tabs by bdeletes command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdeletes site', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdeletes site', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -188,12 +184,12 @@ describe('bdelete/bdeletes command test', () => { }); it('should delete both pinned and unpinned tabs by bdeletes! command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('bdeletes! site', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('bdeletes! site', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); diff --git a/e2e/command_buffer.test.js b/e2e/command_buffer.test.js index bf94428..b3336dc 100644 --- a/e2e/command_buffer.test.js +++ b/e2e/command_buffer.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -23,27 +22,24 @@ const newApp = () => { describe('buffer command test', () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); @@ -58,22 +54,22 @@ describe('buffer command test', () => { } await eventually(async() => { - let handles = await session.getWindowHandles(); + let handles = await webdriver.getAllWindowHandles(); assert.equal(handles.length, 5); - await session.switchToWindow(handles[2]); - await session.findElementByCSS('iframe'); + await webdriver.switchTo().window(handles[2]); + await webdriver.findElement(By.css('iframe')); }); await new Promise((resolve) => setTimeout(resolve, 100)); }); it('should do nothing by buffer command with no parameters', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); @@ -82,12 +78,12 @@ describe('buffer command test', () => { }); it('should select a tab by buffer command with a number', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); @@ -96,41 +92,41 @@ describe('buffer command test', () => { }); it('should should an out of range error by buffer commands', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer 0', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer 0', Key.ENTER); await eventually(async() => { - let p = await session.findElementByCSS('.vimvixen-console-error'); + let p = await webdriver.findElement(By.css('.vimvixen-console-error')); let text = await p.getText(); assert.equal(text, 'tab 0 does not exist'); }); - await session.switchToParentFrame(); - body = await session.findElementByCSS('body'); + await webdriver.switchTo().parentFrame(); + body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - input = await session.findElementByCSS('input'); - await input.sendKeys('buffer 9', Key.Enter); + await webdriver.switchTo().frame(0); + input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer 9', Key.ENTER); await eventually(async() => { - let p = await session.findElementByCSS('.vimvixen-console-error'); + let p = await webdriver.findElement(By.css('.vimvixen-console-error')); let text = await p.getText(); assert.equal(text, 'tab 9 does not exist'); }); }); it('should select a tab by buffer command with a title', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer my_site1', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer my_site1', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); @@ -139,12 +135,12 @@ describe('buffer command test', () => { }); it('should select a tab by buffer command with an URL', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer /site1', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer /site1', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); @@ -153,15 +149,15 @@ describe('buffer command test', () => { }); it('should select tabs rotately', async() => { - let handles = await session.getWindowHandles(); - await session.switchToWindow(handles[4]); + let handles = await webdriver.getAllWindowHandles(); + await webdriver.switchTo().window(handles[4]); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer site', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer site', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); @@ -170,12 +166,12 @@ describe('buffer command test', () => { }); it('should do nothing by ":buffer %"', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer %', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer %', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); @@ -184,15 +180,15 @@ describe('buffer command test', () => { }); it('should selects last selected tab by ":buffer #"', async() => { - let handles = await session.getWindowHandles(); - await session.switchToWindow(handles[1]); + let handles = await webdriver.getAllWindowHandles(); + await webdriver.switchTo().window(handles[1]); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('buffer #', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('buffer #', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); diff --git a/e2e/command_open.test.js b/e2e/command_open.test.js index 0d41f96..ccf7393 100644 --- a/e2e/command_open.test.js +++ b/e2e/command_open.test.js @@ -1,11 +1,10 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { @@ -30,20 +29,18 @@ const newApp = () => { describe("open command test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); http = newApp().listen(port); await browser.storage.local.set({ @@ -53,22 +50,22 @@ describe("open command test", () => { after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); beforeEach(async() => { - await session.navigateTo(`http://127.0.0.1:${port}`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + body = await webdriver.findElement(By.css('body')); }) it('should open default search for keywords by open command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('open an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('open an apple', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }); @@ -80,9 +77,9 @@ describe("open command test", () => { it('should open certain search page for keywords by open command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('open yahoo an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('open yahoo an apple', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }) @@ -94,9 +91,9 @@ describe("open command test", () => { it('should open default engine with empty keywords by open command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('open', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('open', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }) @@ -108,9 +105,9 @@ describe("open command test", () => { it('should open certain search page for empty keywords by open command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('open yahoo', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('open yahoo', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }) @@ -122,9 +119,9 @@ describe("open command test", () => { it('should open a site with domain by open command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('open i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('open i-beam.org', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }) @@ -136,9 +133,9 @@ describe("open command test", () => { it('should open a site with URL by open command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('open https://i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('open https://i-beam.org', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({ active: true }) diff --git a/e2e/command_quit.test.js b/e2e/command_quit.test.js index ee4c2d8..07e770a 100644 --- a/e2e/command_quit.test.js +++ b/e2e/command_quit.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -23,27 +22,24 @@ const newApp = () => { describe('quit/quitall command test', () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); @@ -58,22 +54,22 @@ describe('quit/quitall command test', () => { } await eventually(async() => { - let handles = await session.getWindowHandles(); + let handles = await webdriver.getAllWindowHandles(); assert.equal(handles.length, 5); - await session.switchToWindow(handles[2]); - await session.findElementByCSS('iframe'); + await webdriver.switchTo().window(handles[2]); + await webdriver.findElement(By.css('iframe')); }); await new Promise((resolve) => setTimeout(resolve, 100)); }); it('should current tab by q command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('q', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('q', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -82,12 +78,12 @@ describe('quit/quitall command test', () => { }); it('should current tab by quit command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('quit', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('quit', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -96,12 +92,12 @@ describe('quit/quitall command test', () => { }); it('should current tab by qa command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('qa', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('qa', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -110,12 +106,12 @@ describe('quit/quitall command test', () => { }); it('should current tab by quitall command', async() => { - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - await input.sendKeys('quitall', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + await input.sendKeys('quitall', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); diff --git a/e2e/command_tabopen.test.js b/e2e/command_tabopen.test.js index 9c5cf3a..78f5d7f 100644 --- a/e2e/command_tabopen.test.js +++ b/e2e/command_tabopen.test.js @@ -1,11 +1,10 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { @@ -30,22 +29,20 @@ const newApp = () => { describe("tabopen command test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { http = newApp().listen(port); + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; await browser.storage.local.set({ settings, }); @@ -53,8 +50,8 @@ describe("tabopen command test", () => { after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); @@ -64,16 +61,16 @@ describe("tabopen command test", () => { await browser.tabs.remove(tab.id); } - await session.navigateTo(`http://127.0.0.1:${port}`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + body = await webdriver.findElement(By.css('body')); }) it('should open default search for keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen an apple', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -86,9 +83,9 @@ describe("tabopen command test", () => { it('should open certain search page for keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen yahoo an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen yahoo an apple', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -101,9 +98,9 @@ describe("tabopen command test", () => { it('should open default engine with empty keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -116,9 +113,9 @@ describe("tabopen command test", () => { it('should open certain search page for empty keywords by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen yahoo', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen yahoo', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -131,9 +128,9 @@ describe("tabopen command test", () => { it('should open a site with domain by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen i-beam.org', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -146,9 +143,9 @@ describe("tabopen command test", () => { it('should open a site with URL by tabopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('tabopen https://i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('tabopen https://i-beam.org', Key.ENTER); await eventually(async() => { let tabs = await browser.tabs.query({}); diff --git a/e2e/command_winopen.test.js b/e2e/command_winopen.test.js index 536d759..149d775 100644 --- a/e2e/command_winopen.test.js +++ b/e2e/command_winopen.test.js @@ -1,11 +1,10 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { @@ -30,22 +29,19 @@ const newApp = () => { describe("winopen command test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { http = newApp().listen(port); - - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); await browser.storage.local.set({ settings, }); @@ -53,8 +49,8 @@ describe("winopen command test", () => { after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); @@ -64,16 +60,16 @@ describe("winopen command test", () => { await browser.windows.remove(win.id); } - await session.navigateTo(`http://127.0.0.1:${port}`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + body = await webdriver.findElement(By.css('body')); }) it('should open default search for keywords by winopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('winopen an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('winopen an apple', Key.ENTER); await eventually(async() => { let wins = await browser.windows.getAll(); @@ -88,9 +84,9 @@ describe("winopen command test", () => { it('should open certain search page for keywords by winopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('winopen yahoo an apple', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('winopen yahoo an apple', Key.ENTER); await eventually(async() => { let wins = await browser.windows.getAll(); @@ -105,9 +101,9 @@ describe("winopen command test", () => { it('should open default engine with empty keywords by winopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('winopen', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('winopen', Key.ENTER); await eventually(async() => { let wins = await browser.windows.getAll(); @@ -122,9 +118,9 @@ describe("winopen command test", () => { it('should open certain search page for empty keywords by winopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('winopen yahoo', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('winopen yahoo', Key.ENTER); await eventually(async() => { let wins = await browser.windows.getAll(); @@ -139,9 +135,9 @@ describe("winopen command test", () => { it('should open a site with domain by winopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('winopen i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('winopen i-beam.org', Key.ENTER); await eventually(async() => { let wins = await browser.windows.getAll(); @@ -156,9 +152,9 @@ describe("winopen command test", () => { it('should open a site with URL by winopen command ', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys('winopen https://i-beam.org', Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys('winopen https://i-beam.org', Key.ENTER); await eventually(async() => { let wins = await browser.windows.getAll(); diff --git a/e2e/completion.test.js b/e2e/completion.test.js index 5d910c6..fc87df0 100644 --- a/e2e/completion.test.js +++ b/e2e/completion.test.js @@ -1,13 +1,12 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const Console = require('./lib/Console'); -const Key = lanthan.Key; - const newApp = () => { let app = express(); app.get('/', (req, res) => { @@ -22,20 +21,18 @@ const newApp = () => { describe("general completion test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); http = newApp().listen(port); await browser.storage.local.set({ @@ -45,21 +42,21 @@ describe("general completion test", () => { after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); beforeEach(async() => { - await session.navigateTo(`http://127.0.0.1:${port}`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + body = await webdriver.findElement(By.css('body')); }); it('should all commands on empty line', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await eventually(async() => { let items = await c.getCompletions(); @@ -74,8 +71,8 @@ describe("general completion test", () => { it('should only commands filtered by prefix', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('b'); await eventually(async() => { @@ -91,8 +88,8 @@ describe("general completion test", () => { it('selects completion items by / keys', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('b'); await eventually(async() => { @@ -100,7 +97,7 @@ describe("general completion test", () => { assert.equal(items.length, 4); }); - await c.sendKeys(Key.Tab); + await c.sendKeys(Key.TAB); await eventually(async() => { let items = await c.getCompletions(); assert(items[1].highlight) @@ -109,7 +106,7 @@ describe("general completion test", () => { assert.equal(v, 'buffer'); }); - await c.sendKeys(Key.Tab, Key.Tab); + await c.sendKeys(Key.TAB, Key.TAB); await eventually(async() => { let items = await c.getCompletions(); assert(items[3].highlight) @@ -118,13 +115,13 @@ describe("general completion test", () => { assert.equal(v, 'bdeletes'); }); - await c.sendKeys(Key.Tab); + await c.sendKeys(Key.TAB); await eventually(async() => { let v = await c.currentValue(); assert.equal(v, 'b'); }); - await c.sendKeys(Key.Shift, Key.Tab); + await c.sendKeys(Key.SHIFT, Key.TAB); await eventually(async() => { let items = await c.getCompletions(); assert(items[3].highlight) diff --git a/e2e/completion_buffers.test.js b/e2e/completion_buffers.test.js index de26747..87d2397 100644 --- a/e2e/completion_buffers.test.js +++ b/e2e/completion_buffers.test.js @@ -1,12 +1,11 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); const Console = require('./lib/Console'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const newApp = () => { @@ -26,20 +25,18 @@ const newApp = () => { describe("completion on buffer/bdelete/bdeletes", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); http = newApp().listen(port); await browser.storage.local.set({ @@ -49,8 +46,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); @@ -67,12 +64,12 @@ describe("completion on buffer/bdelete/bdeletes", () => { } await eventually(async() => { - let handles = await session.getWindowHandles(); + let handles = await webdriver.getAllWindowHandles(); assert.equal(handles.length, 5); - await session.switchToWindow(handles[2]); - await session.findElementByCSS('iframe'); + await webdriver.switchTo().window(handles[2]); + await webdriver.findElement(By.css('iframe')); }); - body = await session.findElementByCSS('body'); + body = await webdriver.findElement(By.css('body')); await new Promise((resolve) => setTimeout(resolve, 100)); }); @@ -80,8 +77,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should all tabs by "buffer" command with empty params', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('buffer '); await eventually(async() => { @@ -102,8 +99,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should filter items with URLs by keywords on "buffer" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('buffer title_site2'); await eventually(async() => { @@ -118,8 +115,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should filter items with titles by keywords on "buffer" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('buffer /site2'); await eventually(async() => { @@ -132,8 +129,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should show one item by number on "buffer" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('buffer 2'); await eventually(async() => { @@ -147,8 +144,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should show unpinned tabs "bdelete" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('bdelete site'); await eventually(async() => { @@ -163,8 +160,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should show unpinned tabs "bdeletes" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('bdelete site'); await eventually(async() => { @@ -179,8 +176,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should show both pinned and unpinned tabs "bdelete!" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('bdelete! site'); await eventually(async() => { @@ -197,8 +194,8 @@ describe("completion on buffer/bdelete/bdeletes", () => { it('should show both pinned and unpinned tabs "bdeletes!" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('bdeletes! site'); await eventually(async() => { diff --git a/e2e/completion_open.test.js b/e2e/completion_open.test.js index 5828768..b2b7484 100644 --- a/e2e/completion_open.test.js +++ b/e2e/completion_open.test.js @@ -4,10 +4,10 @@ const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); +const { Builder } = require('lanthan'); +const { By, Key } = require('selenium-webdriver'); const Console = require('./lib/Console'); -const Key = lanthan.Key; - const newApp = () => { let app = express(); @@ -23,20 +23,18 @@ const newApp = () => { describe("completion on open/tabopen/winopen commands", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); http = newApp().listen(port); await browser.storage.local.set({ @@ -44,26 +42,26 @@ describe("completion on open/tabopen/winopen commands", () => { }); // Add item into hitories - await session.navigateTo(`https://i-beam.org/404`); + await webdriver.navigate().to(`https://i-beam.org/404`); }); after(async() => { http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); beforeEach(async() => { - await session.navigateTo(`http://127.0.0.1:${port}`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + body = await webdriver.findElement(By.css('body')); }); it('should show completions from search engines, bookmarks, and histories by "open" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('open '); await eventually(async() => { @@ -77,8 +75,8 @@ describe("completion on open/tabopen/winopen commands", () => { it('should filter items with URLs by keywords on "open" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('open https://'); await eventually(async() => { @@ -91,8 +89,8 @@ describe("completion on open/tabopen/winopen commands", () => { it('should filter items with titles by keywords on "open" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('open getting'); await eventually(async() => { @@ -105,8 +103,8 @@ describe("completion on open/tabopen/winopen commands", () => { it('should filter items with titles by keywords on "tabopen" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('tabopen https://'); await eventually(async() => { @@ -119,8 +117,8 @@ describe("completion on open/tabopen/winopen commands", () => { it('should filter items with titles by keywords on "winopen" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('winopen https://'); await eventually(async() => { @@ -131,24 +129,26 @@ describe("completion on open/tabopen/winopen commands", () => { }) it('should display only specified items in "complete" property by set command', async() => { - let c = new Console(session); + let c = new Console(webdriver); const execCommand = async(line) => { await body.sendKeys(':'); - await session.switchToFrame(0); - await c.sendKeys(line, Key.Enter); - await session.switchToParentFrame(); + await webdriver.switchTo().frame(0); + await c.sendKeys(line, Key.ENTER); + await new Promise(resolve => setTimeout(resolve, 100)); + await webdriver.switchTo().parentFrame(); } const typeCommand = async(...keys) => { await body.sendKeys(':'); - await session.switchToFrame(0); + await webdriver.switchTo().frame(0); await c.sendKeys(...keys); } const cancel = async() => { - await c.sendKeys(Key.Escape); - await session.switchToParentFrame(); + await c.sendKeys(Key.ESCAPE); + await new Promise(resolve => setTimeout(resolve, 100)); + await webdriver.switchTo().parentFrame(); } await execCommand('set complete=sbh'); @@ -189,17 +189,18 @@ describe("completion on open/tabopen/winopen commands", () => { }; await browser.storage.local.set({ settings, }); - let c = new Console(session); + let c = new Console(webdriver); const typeCommand = async(...keys) => { await body.sendKeys(':'); - await session.switchToFrame(0); + await webdriver.switchTo().frame(0); await c.sendKeys(...keys); } const cancel = async() => { - await c.sendKeys(Key.Escape); - await session.switchToParentFrame(); + await c.sendKeys(Key.ESCAPE); + await new Promise(resolve => setTimeout(resolve, 100)); + await webdriver.switchTo().parentFrame(); } await browser.storage.local.set({ settings: { diff --git a/e2e/completion_set.test.js b/e2e/completion_set.test.js index cf5ff5b..a6ec248 100644 --- a/e2e/completion_set.test.js +++ b/e2e/completion_set.test.js @@ -5,25 +5,23 @@ const assert = require('assert'); const eventually = require('./eventually'); const settings = require('./settings'); const Console = require('./lib/Console'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By } = require('selenium-webdriver'); describe("completion on set commands", () => { const port = 12321; - let firefox; + let lanthan; let session; let browser; let body; before(async() => { - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); await browser.storage.local.set({ settings, @@ -31,21 +29,21 @@ describe("completion on set commands", () => { }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }); beforeEach(async() => { - await session.navigateTo(`about:blank`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`about:blank`); + body = await webdriver.findElement(By.css('body')); }); it('should show all property names by "set" command with empty params', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('set '); await eventually(async() => { @@ -62,8 +60,8 @@ describe("completion on set commands", () => { it('should show filtered property names by "set" command', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); - let c = new Console(session); + await webdriver.switchTo().frame(0); + let c = new Console(webdriver); await c.sendKeys('set no'); await eventually(async() => { diff --git a/e2e/console.test.js b/e2e/console.test.js index 6f6341f..131a4ef 100644 --- a/e2e/console.test.js +++ b/e2e/console.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { Key, By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -23,102 +22,106 @@ const newApp = () => { describe("console test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let tab; let body; before(async() => { - firefox = await lanthan.firefox(); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; http = newApp().listen(port); + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { - http.close(); - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); + } + if (http) { + http.close(); } }); beforeEach(async() => { - await session.navigateTo(`http://127.0.0.1:${port}`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + body = await webdriver.findElement(By.css('body')); }); it('open console with :', async() => { await body.sendKeys(':'); - await session.switchToFrame(0); + await webdriver.switchTo().frame(0); - let input = await session.findElementByCSS('input'); + let input = await webdriver.findElement(By.css('input')); assert.equal(await input.isDisplayed(), true); }); it('open console with open command by o', async() => { await body.sendKeys('o'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, 'open '); }); it('open console with open command and current URL by O', async() => { - await body.sendKeys(Key.Shift, 'o'); + await body.sendKeys(Key.SHIFT, 'o'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, `open http://127.0.0.1:${port}/`); }); it('open console with tabopen command by t', async() => { await body.sendKeys('t'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, 'tabopen '); }); it('open console with tabopen command and current URL by T', async() => { - await body.sendKeys(Key.Shift, 't'); + await body.sendKeys(Key.SHIFT, 't'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, `tabopen http://127.0.0.1:${port}/`); }); it('open console with winopen command by w', async() => { await body.sendKeys('w'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, 'winopen '); }); it('open console with winopen command and current URL by W', async() => { - await body.sendKeys(Key.Shift, 'W'); + await body.sendKeys(Key.SHIFT, 'W'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, `winopen http://127.0.0.1:${port}/`); }); it('open console with buffer command by b', async() => { await body.sendKeys('b'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, `buffer `); }); it('open console with addbookmark command with title by a', async() => { await body.sendKeys('a'); - await session.switchToFrame(0); - let value = await session.executeScript(() => document.querySelector('input').value); + await webdriver.switchTo().frame(0); + let value = await webdriver.executeScript(() => document.querySelector('input').value); assert.equal(value, `addbookmark Hello, world!`); }); }); diff --git a/e2e/follow.test.js b/e2e/follow.test.js index 7e49119..336d673 100644 --- a/e2e/follow.test.js +++ b/e2e/follow.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { Key, By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -119,9 +118,9 @@ const newApp = () => { return app; }; -const waitForHints = async(session) => { +const waitForHints = async(webdriver) => { await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert(hints.length > 0); }); }; @@ -130,24 +129,27 @@ describe('follow test', () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - - firefox = await lanthan.firefox(); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); + } + if (http) { + http.close(); } - http.close(); }); afterEach(async() => { @@ -158,45 +160,49 @@ describe('follow test', () => { }); it('should focus an input by f', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/follow-input`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/follow-input`); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('f'); - await waitForHints(session); + await waitForHints(webdriver); await body.sendKeys('a'); - let tagName = await session.executeScript(() => document.activeElement.tagName); + let tagName = await webdriver.executeScript(() => document.activeElement.tagName); assert.equal(tagName.toLowerCase(), 'input'); }); it('should open a link by f', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/`); - let body = await session.findElementByCSS('body'); - await body.sendKeys('f', 'a'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys('f'); + await waitForHints(webdriver); + await body.sendKeys('a'); - let hash = await session.executeScript('location.pathname'); - await body.sendKeys(hash, '/hello'); + await eventually(async() => { + let hash = await webdriver.executeScript('return location.pathname'); + assert.equal(hash, '/hello'); + }); }); it('should focus an input by F', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/follow-input`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/follow-input`); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'f'); - await waitForHints(session); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'f'); + await waitForHints(webdriver); await body.sendKeys('a'); - let tagName = await session.executeScript(() => document.activeElement.tagName); + let tagName = await webdriver.executeScript(() => document.activeElement.tagName); assert.equal(tagName.toLowerCase(), 'input'); }); it('should open a link to new tab by F', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/`); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'f'); - await waitForHints(session); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'f'); + await waitForHints(webdriver); await body.sendKeys('a'); await eventually(async() => { @@ -208,49 +214,49 @@ describe('follow test', () => { }); it('should show hints of links in area', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/area`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/area`); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'f'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'f'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 3); }); }); it('should shows hints only in viewport', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/test1`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/test1`); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'f'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'f'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 1); }); }); it('should shows hints only in window of the frame', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/test2`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/test2`); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'f'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'f'); - await session.switchToFrame(0); + await webdriver.switchTo().frame(0); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 1); }); }); it('should shows hints only in the frame', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/test3`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/test3`); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'f'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'f'); - await session.switchToFrame(0); + await webdriver.switchTo().frame(0); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 1); }); }); diff --git a/e2e/follow_properties.test.js b/e2e/follow_properties.test.js index 223923e..5e22a40 100644 --- a/e2e/follow_properties.test.js +++ b/e2e/follow_properties.test.js @@ -1,11 +1,10 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); const Console = require('./lib/Console'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { Key, By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -25,9 +24,9 @@ const newApp = () => { return app; }; -const waitForHints = async(session) => { +const waitForHints = async(webdriver) => { await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert(hints.length > 0); }); }; @@ -36,22 +35,20 @@ describe('follow properties test', () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; let body; before(async() => { http = newApp().listen(port); - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - }, - }); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); await browser.storage.local.set({ settings: { source: 'json', @@ -74,15 +71,15 @@ describe('follow properties test', () => { }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } http.close(); }); beforeEach(async() => { - await session.navigateTo(`http://127.0.0.1:${port}/`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/`); + body = await webdriver.findElement(By.css('body')); }); afterEach(async() => { @@ -95,7 +92,7 @@ describe('follow properties test', () => { it('should show hints with hintchars by settings', async () => { await body.sendKeys('f'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 5); assert.equal(await hints[0].getText(), 'J'); @@ -108,20 +105,20 @@ describe('follow properties test', () => { await body.sendKeys('j'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); - assert.equal(await hints[0].getStyle('display'), 'block'); - assert.equal(await hints[1].getStyle('display'), 'none'); - assert.equal(await hints[2].getStyle('display'), 'block'); - assert.equal(await hints[3].getStyle('display'), 'block'); - assert.equal(await hints[4].getStyle('display'), 'none'); + assert.equal(await hints[0].getCssValue('display'), 'block'); + assert.equal(await hints[1].getCssValue('display'), 'none'); + assert.equal(await hints[2].getCssValue('display'), 'block'); + assert.equal(await hints[3].getCssValue('display'), 'block'); + assert.equal(await hints[4].getCssValue('display'), 'none'); }); }); it('should open tab in background by background:false', async () => { - await body.sendKeys(Key.Shift, 'f'); + await body.sendKeys(Key.SHIFT, 'f'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 5); }); await body.sendKeys('jj'); @@ -134,9 +131,9 @@ describe('follow properties test', () => { }); it('should open tab in background by background:true', async () => { - await body.sendKeys(Key.Control, 'f'); + await body.sendKeys(Key.CONTROL, 'f'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 5); }); await body.sendKeys('jj'); @@ -149,16 +146,17 @@ describe('follow properties test', () => { }); it('should show hints with hintchars by settings', async () => { - let c = new Console(session); + let c = new Console(webdriver); await body.sendKeys(':'); - await session.switchToFrame(0); - await c.sendKeys('set hintchars=abc', Key.Enter); - await session.switchToParentFrame(); + await webdriver.switchTo().frame(0); + await c.sendKeys('set hintchars=abc', Key.ENTER); + await new Promise(resolve => setTimeout(resolve, 100)); + await webdriver.switchTo().parentFrame(); await body.sendKeys('f'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); assert.equal(hints.length, 5); assert.equal(await hints[0].getText(), 'A'); @@ -170,13 +168,13 @@ describe('follow properties test', () => { await body.sendKeys('a'); await eventually(async() => { - let hints = await session.findElementsByCSS('.vimvixen-hint'); + let hints = await webdriver.findElements(By.css(`.vimvixen-hint`)); - assert.equal(await hints[0].getStyle('display'), 'block'); - assert.equal(await hints[1].getStyle('display'), 'none'); - assert.equal(await hints[2].getStyle('display'), 'none'); - assert.equal(await hints[3].getStyle('display'), 'block'); - assert.equal(await hints[4].getStyle('display'), 'block'); + assert.equal(await hints[0].getCssValue('display'), 'block'); + assert.equal(await hints[1].getCssValue('display'), 'none'); + assert.equal(await hints[2].getCssValue('display'), 'none'); + assert.equal(await hints[3].getCssValue('display'), 'block'); + assert.equal(await hints[4].getCssValue('display'), 'block'); }); }); }); diff --git a/e2e/lib/Console.js b/e2e/lib/Console.js index 3a39b64..6016de1 100644 --- a/e2e/lib/Console.js +++ b/e2e/lib/Console.js @@ -1,22 +1,24 @@ +const { By } = require('selenium-webdriver'); + class Console { - constructor(session) { - this.session = session; + constructor(webdriver) { + this.webdriver = webdriver; } async sendKeys(...keys) { - let input = await this.session.findElementByCSS('input'); + let input = await this.webdriver.findElement(By.css('input')); input.sendKeys(...keys); } async currentValue() { - return await this.session.executeScript(() => { + return await this.webdriver.executeScript(() => { let input = document.querySelector('input'); return input.value; }); } async getCompletions() { - return await this.session.executeScript(() => { + return await this.webdriver.executeScript(() => { let items = document.querySelectorAll('.vimvixen-console-completion > li'); if (items.length === 0) { throw new Error('completion items not found'); diff --git a/e2e/mark.test.js b/e2e/mark.test.js index 8716c1e..cc32c85 100644 --- a/e2e/mark.test.js +++ b/e2e/mark.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -21,61 +20,65 @@ describe("mark test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { http = newApp().listen(port); - firefox = await lanthan.firefox(); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); + } + if (http) { + http.close(); } - http.close(); }); it('should set a local mark and jump to it', async () => { - await session.navigateTo(`http://127.0.0.1:${port}`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + let body = await webdriver.findElement(By.css('body')); - await session.executeScript(() => window.scrollTo(200, 200)); + await webdriver.executeScript(() => window.scrollTo(200, 200)); await body.sendKeys('m', 'a'); - await session.executeScript(() => window.scrollTo(500, 500)); + await webdriver.executeScript(() => window.scrollTo(500, 500)); await body.sendKeys('\'', 'a'); await eventually(async() => { - let pageXOffset = await session.executeScript(() => window.pageXOffset); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageXOffset = await webdriver.executeScript(() => window.pageXOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageXOffset, 200); assert.equal(pageYOffset, 200); }); }); it('should set a global mark and jump to it', async () => { - await session.navigateTo(`http://127.0.0.1:${port}#first`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}#first`); + let body = await webdriver.findElement(By.css('body')); - await session.executeScript(() => window.scrollTo(200, 200)); + await webdriver.executeScript(() => window.scrollTo(200, 200)); await body.sendKeys('m', 'A'); - await session.executeScript(() => window.scrollTo(500, 500)); + await webdriver.executeScript(() => window.scrollTo(500, 500)); await body.sendKeys('\'', 'A'); await eventually(async() => { - let pageXOffset = await session.executeScript(() => window.pageXOffset); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageXOffset = await webdriver.executeScript(() => window.pageXOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageXOffset, 200); assert.equal(pageYOffset, 200); }); await browser.tabs.create({ url: `http://127.0.0.1:${port}#second` }); - body = await session.findElementByCSS('body'); + body = await webdriver.findElement(By.css('body')); await body.sendKeys('\'', 'A'); await eventually(async() => { @@ -83,17 +86,17 @@ describe("mark test", () => { let url = new URL(tab.url); assert.equal(url.hash, '#first'); - let pageXOffset = await session.executeScript(() => window.pageXOffset); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageXOffset = await webdriver.executeScript(() => window.pageXOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageXOffset, 200); assert.equal(pageYOffset, 200); }); }); it('set a global mark and creates new tab from gone', async () => { - await session.navigateTo(`http://127.0.0.1:${port}#first`); - await session.executeScript(() => window.scrollTo(500, 500)); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}#first`); + await webdriver.executeScript(() => window.scrollTo(500, 500)); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('m', 'A'); let tab = (await browser.tabs.query({ active: true }))[0]; @@ -102,12 +105,12 @@ describe("mark test", () => { let handles; await eventually(async() => { - handles = await session.getWindowHandles(); + handles = await webdriver.getAllWindowHandles(); assert.equal(handles.length, 2); }); - await session.switchToWindow(handles[0]); - await session.navigateTo(`http://127.0.0.1:${port}#second`); - body = await session.findElementByCSS('body'); + await webdriver.switchTo().window(handles[0]); + await webdriver.navigate().to(`http://127.0.0.1:${port}#second`); + body = await webdriver.findElement(By.css('body')); await body.sendKeys('\'', 'A'); await eventually(async() => { diff --git a/e2e/navigate.test.js b/e2e/navigate.test.js index 17552e5..e4b8f69 100644 --- a/e2e/navigate.test.js +++ b/e2e/navigate.test.js @@ -1,10 +1,10 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { Options: FirefoxOptions } = require('selenium-webdriver/firefox'); +const { Key, By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -47,26 +47,26 @@ describe("navigate test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let browser; before(async() => { + let opts = new FirefoxOptions() + .setPreference('browser.startup.homepage', `http://127.0.0.1:${port}#home`); http = newApp().listen(port); - - firefox = await lanthan.firefox({ - prefs: { - 'browser.startup.homepage': `http://127.0.0.1:${port}#home`, - } - }); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .setOptions(opts) + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } http.close(); }); @@ -79,8 +79,8 @@ describe("navigate test", () => { }) it('should go to parent path without hash by gu', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/a/b/c`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/a/b/c`); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('g', 'u'); @@ -92,8 +92,8 @@ describe("navigate test", () => { }); it('should remove hash by gu', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/a/b/c#hash`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/a/b/c#hash`); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('g', 'u'); @@ -106,10 +106,10 @@ describe("navigate test", () => { }); it('should go to root path by gU', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/a/b/c#hash`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/a/b/c#hash`); + let body = await webdriver.findElement(By.css('body')); - await body.sendKeys('g', Key.Shift, 'u'); + await body.sendKeys('g', Key.SHIFT, 'u'); await eventually(async() => { let tab = (await browser.tabs.query({}))[0]; @@ -119,11 +119,11 @@ describe("navigate test", () => { }); it('should go back and forward in history by H and L', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/first`); - await session.navigateTo(`http://127.0.0.1:${port}/second`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/first`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/second`); + let body = await webdriver.findElement(By.css('body')); - await body.sendKeys(Key.Shift, 'h'); + await body.sendKeys(Key.SHIFT, 'h'); await eventually(async() => { let tab = (await browser.tabs.query({}))[0]; @@ -131,8 +131,8 @@ describe("navigate test", () => { assert.equal(url.pathname, `/first`) }); - body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'l'); + body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'l'); await eventually(async() => { tab = (await browser.tabs.query({}))[0]; @@ -142,9 +142,9 @@ describe("navigate test", () => { }); it('should go previous and next page in by [[ and ]]', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/pagenation-a/10`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/pagenation-a/10`); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('[', '['); await eventually(async() => { @@ -155,8 +155,8 @@ describe("navigate test", () => { }); it('should go next page in by ]]', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/pagenation-a/10`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/pagenation-a/10`); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(']', ']'); await eventually(async() => { @@ -167,9 +167,9 @@ describe("navigate test", () => { }); it('should go previous page in by ]]', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/pagenation-link/10`); + await webdriver.navigate().to(`http://127.0.0.1:${port}/pagenation-link/10`); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('[', '['); await eventually(async() => { @@ -180,8 +180,8 @@ describe("navigate test", () => { }); it('should go next page by in by [[', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/pagenation-link/10`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}/pagenation-link/10`); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(']', ']'); await eventually(async() => { @@ -192,8 +192,8 @@ describe("navigate test", () => { }); it('should go to home page into current tab by gh', async () => { - await session.navigateTo(`http://127.0.0.1:${port}`); - let body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('g', 'h'); await eventually(async() => { @@ -204,9 +204,9 @@ describe("navigate test", () => { }); it('should go to home page into current tab by gH', async () => { - await session.navigateTo(`http://127.0.0.1:${port}`); - let body = await session.findElementByCSS('body'); - await body.sendKeys('g', Key.Shift, 'H'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys('g', Key.SHIFT, 'H'); await eventually(async() => { let tabs = await browser.tabs.query({}); @@ -218,8 +218,8 @@ describe("navigate test", () => { }); it('should reload current tab by r', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/reload`); - await session.executeScript(() => window.scrollTo(500, 500)); + await webdriver.navigate().to(`http://127.0.0.1:${port}/reload`); + await webdriver.executeScript(() => window.scrollTo(500, 500)); let before await eventually(async() => { let tab = (await browser.tabs.query({}))[0]; @@ -227,7 +227,7 @@ describe("navigate test", () => { assert(before > 0); }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('r'); let after @@ -238,14 +238,14 @@ describe("navigate test", () => { }); await eventually(async() => { - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageYOffset, 500); }); }); it('should reload current tab without cache by R', async () => { - await session.navigateTo(`http://127.0.0.1:${port}/reload`); - await session.executeScript(() => window.scrollTo(500, 500)); + await webdriver.navigate().to(`http://127.0.0.1:${port}/reload`); + await webdriver.executeScript(() => window.scrollTo(500, 500)); let before await eventually(async() => { let tab = (await browser.tabs.query({}))[0]; @@ -253,8 +253,8 @@ describe("navigate test", () => { assert(before > 0); }); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'R'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'R'); let after await eventually(async() => { @@ -266,7 +266,7 @@ describe("navigate test", () => { // assert that the page offset is reset to 0, and 'eventually' is timed-out. await assert.rejects(async () => { await eventually(async() => { - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageYOffset, 500); }); }); diff --git a/e2e/options.test.js b/e2e/options.test.js index e8045c2..456c80b 100644 --- a/e2e/options.test.js +++ b/e2e/options.test.js @@ -1,8 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); +const { Builder } = require('lanthan'); +const { By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -18,31 +19,28 @@ const newApp = () => { describe("options page", () => { const port = 12321; let http; - let firefox; + let lanthan; let session; let browser; before(async() => { http = newApp().listen(port); - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - builder.addFile('build/settings.html'); - }, - }); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); + } + if (http) { + http.close(); } - - http.close(); }); beforeEach(async() => { @@ -53,15 +51,15 @@ describe("options page", () => { }) const updateTextarea = async(value) => { - let textarea = await session.findElementByCSS('textarea'); - await session.executeScript(`document.querySelector('textarea').value = '${value}'`) + let textarea = await webdriver.findElement(By.css('textarea')); + await webdriver.executeScript(`document.querySelector('textarea').value = '${value}'`) await textarea.sendKeys(' '); - await session.executeScript(() => document.querySelector('textarea').blur()); + await webdriver.executeScript(() => document.querySelector('textarea').blur()); } it('saves current config on blur', async () => { let url = await browser.runtime.getURL("build/settings.html") - await session.navigateTo(url); + await webdriver.navigate().to(url); await updateTextarea(`{ "blacklist": [ "https://example.com" ] }`); @@ -75,7 +73,7 @@ describe("options page", () => { assert.equal(settings.source, 'json') assert.equal(settings.json, '{ "blacklist": [ "https://example.com" ] } ') - let error = await session.findElementByCSS('.settings-ui-input-error'); + let error = await webdriver.findElement(By.css('.settings-ui-input-error')); let text = await error.getText(); assert.ok(text.startsWith('SyntaxError:')) }); @@ -83,17 +81,17 @@ describe("options page", () => { it('updates keymaps without reloading', async () => { await browser.tabs.create({ url: `http://127.0.0.1:${port}`, active: false }); let url = await browser.runtime.getURL("build/settings.html") - await session.navigateTo(url); + await webdriver.navigate().to(url); - let handles = await session.getWindowHandles(); await updateTextarea(`{ "keymaps": { "zz": { "type": "scroll.vertically", "count": 10 } } }`); - await session.switchToWindow(handles[1]); + let handles = await webdriver.getAllWindowHandles(); + await webdriver.switchTo().window(handles[1]); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('zz') - let y = await session.executeScript(() => window.pageYOffset); + let y = await webdriver.executeScript(() => window.pageYOffset); assert.equal(y, 640); }) }); diff --git a/e2e/options_form.test.js b/e2e/options_form.test.js index f86d995..4f41738 100644 --- a/e2e/options_form.test.js +++ b/e2e/options_form.test.js @@ -1,23 +1,20 @@ -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); +const { Builder } = require('lanthan'); +const { By } = require('selenium-webdriver'); describe("options form page", () => { - let firefox; - let session; + let lanthan; + let webdriver; let browser; beforeEach(async() => { - firefox = await lanthan.firefox({ - spy: path.join(__dirname, '..'), - builderf: (builder) => { - builder.addFile('build/settings.js'); - builder.addFile('build/settings.html'); - }, - }); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); let tabs = await browser.tabs.query({}); for (let tab of tabs.slice(1)) { @@ -26,37 +23,37 @@ describe("options form page", () => { }) afterEach(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); } }) const setBlacklistValue = async(nth, value) => { let selector = '.form-blacklist-form .column-url'; - let input = (await session.findElementsByCSS(selector))[nth]; + let input = (await webdriver.findElements(By.css(selector)))[nth]; await input.sendKeys(value); - await session.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); + await webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); } const setSearchEngineValue = async(nth, name, url) => { let selector = '.form-search-form input.column-name'; - let input = (await session.findElementsByCSS(selector))[nth]; + let input = (await webdriver.findElements(By.css(selector)))[nth]; await input.sendKeys(name); - await session.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); + await webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); selector = '.form-search-form input.column-url'; - input = (await session.findElementsByCSS(selector))[nth]; + input = (await webdriver.findElements(By.css(selector)))[nth]; await input.sendKeys(url); - await session.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); + await webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); } it('switch to form settings', async () => { let url = await browser.runtime.getURL("build/settings.html") - await session.navigateTo(url); + await webdriver.navigate().to(url); - let useFormInput = await session.findElementByCSS('#setting-source-form'); + let useFormInput = await webdriver.findElement(By.css('#setting-source-form')); await useFormInput.click(); - await session.acceptAlert(); + await webdriver.switchTo().alert().accept(); let { settings } = await browser.storage.local.get('settings'); assert.equal(settings.source, 'form') @@ -64,19 +61,19 @@ describe("options form page", () => { it('add blacklist', async () => { let url = await browser.runtime.getURL("build/settings.html") - await session.navigateTo(url); + await webdriver.navigate().to(url); - let useFormInput = await session.findElementByCSS('#setting-source-form'); + let useFormInput = await webdriver.findElement(By.css('#setting-source-form')); await useFormInput.click(); - await session.acceptAlert(); - await session.executeScript(() => window.scrollBy(0, 1000)); + await webdriver.switchTo().alert().accept(); + await webdriver.executeScript(() => window.scrollBy(0, 1000)); // assert default let settings = (await browser.storage.local.get('settings')).settings; assert.deepEqual(settings.form.blacklist, []) // add blacklist items - let addButton = await session.findElementByCSS('.form-blacklist-form .ui-add-button'); + let addButton = await webdriver.findElement(By.css('.form-blacklist-form .ui-add-button')) await addButton.click(); await setBlacklistValue(0, 'google.com') @@ -90,7 +87,7 @@ describe("options form page", () => { assert.deepEqual(settings.form.blacklist, ['google.com', 'yahoo.com']) // delete first item - let deleteButton = (await session.findElementsByCSS('.form-blacklist-form .ui-delete-button'))[0]; + let deleteButton = (await webdriver.findElements(By.css('.form-blacklist-form .ui-delete-button')))[0]; await deleteButton.click() settings = (await browser.storage.local.get('settings')).settings; @@ -99,23 +96,23 @@ describe("options form page", () => { it('add search engines', async () => { let url = await browser.runtime.getURL("build/settings.html") - await session.navigateTo(url); + await webdriver.navigate().to(url); - let useFormInput = await session.findElementByCSS('#setting-source-form'); + let useFormInput = await webdriver.findElement(By.css('#setting-source-form')); await useFormInput.click(); - await session.acceptAlert(); + await webdriver.switchTo().alert().accept(); // assert default let settings = (await browser.storage.local.get('settings')).settings; assert.deepEqual(settings.form.search.default, 'google'); // change default - let radio = (await session.findElementsByCSS('.form-search-form input[type=radio]'))[2]; + let radio = (await webdriver.findElements(By.css('.form-search-form input[type=radio]')))[2]; await radio.click(); settings = (await browser.storage.local.get('settings')).settings; assert.deepEqual(settings.form.search.default, 'bing'); - let addButton = await session.findElementByCSS('.form-search-form .ui-add-button'); + let addButton = await webdriver.findElement(By.css('.form-search-form .ui-add-button')) await addButton.click(); await setSearchEngineValue(6, 'yippy', 'https://www.yippy.com/search?query={}'); diff --git a/e2e/repeat.test.js b/e2e/repeat.test.js index 4072005..b068b18 100644 --- a/e2e/repeat.test.js +++ b/e2e/repeat.test.js @@ -1,10 +1,9 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { Key, By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -20,44 +19,48 @@ describe("tab test", () => { const url = `http://127.0.0.1:${port}/`; let http; - let firefox; - let session; + let lanthan; + let webdriver let browser; let tabs; before(async() => { - firefox = await lanthan.firefox(); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); http = newApp().listen(port); - await session.navigateTo(`${url}`); + await webdriver.navigate().to(`${url}`); }); after(async() => { - http.close(); - if (firefox) { - await firefox.close(); + if (http) { + http.close(); + } + if (lanthan) { + await lanthan.quit(); } }); it('repeats last operation', async () => { let before = await browser.tabs.query({}); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); - await session.switchToFrame(0); - let input = await session.findElementByCSS('input'); - input.sendKeys(`tabopen ${url}newtab`, Key.Enter); + await webdriver.switchTo().frame(0); + let input = await webdriver.findElement(By.css('input')); + input.sendKeys(`tabopen ${url}newtab`, Key.ENTER); await eventually(async() => { let current = await browser.tabs.query({ url: `*://*/newtab` }); assert.equal(current.length, 1); }); - body = await session.findElementByCSS('body'); + body = await webdriver.findElement(By.css('body')); await body.sendKeys('.'); await eventually(async() => { @@ -72,7 +75,7 @@ describe("tab test", () => { } let before = await browser.tabs.query({}); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('d'); await eventually(async() => { @@ -81,7 +84,7 @@ describe("tab test", () => { }); await browser.tabs.update(before[2].id, { active: true }); - body = await session.findElementByCSS('body'); + body = await webdriver.findElement(By.css('body')); await body.sendKeys('.'); await eventually(async() => { diff --git a/e2e/scroll.test.js b/e2e/scroll.test.js index 0ce3ec6..b728f47 100644 --- a/e2e/scroll.test.js +++ b/e2e/scroll.test.js @@ -1,9 +1,8 @@ const express = require('express'); -const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { Key, By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -20,131 +19,135 @@ describe("scroll test", () => { const port = 12321; let http; - let firefox; - let session; + let lanthan; + let webdriver; let body; before(async() => { http = newApp().listen(port); - firefox = await lanthan.firefox(); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); }); after(async() => { - if (firefox) { - await firefox.close(); + if (lanthan) { + await lanthan.quit(); + } + if (http) { + http.close(); } - http.close(); }); beforeEach(async() => { - await session.navigateTo(`http://127.0.0.1:${port}`); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to(`http://127.0.0.1:${port}`); + body = await webdriver.findElement(By.css('body')); }); it('scrolls up by k', async () => { await body.sendKeys('j'); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageYOffset, 64); }); it('scrolls down by j', async () => { - await session.executeScript(() => window.scrollTo(0, 200)); + await webdriver.executeScript(() => window.scrollTo(0, 200)); await body.sendKeys('k'); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageYOffset, 136); }); it('scrolls left by h', async () => { - await session.executeScript(() => window.scrollTo(100, 100)); + await webdriver.executeScript(() => window.scrollTo(100, 100)); await body.sendKeys('h'); - let pageXOffset = await session.executeScript(() => window.pageXOffset); + let pageXOffset = await webdriver.executeScript(() => window.pageXOffset); assert.equal(pageXOffset, 36); }); it('scrolls left by l', async () => { - await session.executeScript(() => window.scrollTo(100, 100)); + await webdriver.executeScript(() => window.scrollTo(100, 100)); await body.sendKeys('l'); - let pageXOffset = await session.executeScript(() => window.pageXOffset); + let pageXOffset = await webdriver.executeScript(() => window.pageXOffset); assert.equal(pageXOffset, 164); }); it('scrolls top by gg', async () => { - await session.executeScript(() => window.scrollTo(0, 100)); + await webdriver.executeScript(() => window.scrollTo(0, 100)); await body.sendKeys('g', 'g'); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert.equal(pageYOffset, 0); }); it('scrolls bottom by G', async () => { - await session.executeScript(() => window.scrollTo(0, 100)); - await body.sendKeys(Key.Shift, 'g'); + await webdriver.executeScript(() => window.scrollTo(0, 100)); + await body.sendKeys(Key.SHIFT, 'g'); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert(pageYOffset > 5000); }); it('scrolls bottom by 0', async () => { - await session.executeScript(() => window.scrollTo(0, 100)); - await body.sendKeys(Key.Shift, '0'); + await webdriver.executeScript(() => window.scrollTo(0, 100)); + await body.sendKeys(Key.SHIFT, '0'); - let pageXOffset = await session.executeScript(() => window.pageXOffset); + let pageXOffset = await webdriver.executeScript(() => window.pageXOffset); assert(pageXOffset === 0); }); it('scrolls bottom by $', async () => { - await session.executeScript(() => window.scrollTo(0, 100)); - await body.sendKeys(Key.Shift, '$'); + await webdriver.executeScript(() => window.scrollTo(0, 100)); + await body.sendKeys(Key.SHIFT, '$'); - let pageXOffset = await session.executeScript(() => window.pageXOffset); + let pageXOffset = await webdriver.executeScript(() => window.pageXOffset); assert(pageXOffset > 5000); }); it('scrolls bottom by ', async () => { - await session.executeScript(() => window.scrollTo(0, 1000)); - await body.sendKeys(Key.Control, 'u'); + await webdriver.executeScript(() => window.scrollTo(0, 1000)); + await body.sendKeys(Key.CONTROL, 'u'); let pageHeight = - await session.executeScript(() => window.document.documentElement.clientHeight); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + await webdriver.executeScript(() => window.document.documentElement.clientHeight); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert(Math.abs(pageYOffset - (1000 - Math.floor(pageHeight / 2))) < 5); }); it('scrolls bottom by ', async () => { - await session.executeScript(() => window.scrollTo(0, 1000)); - await body.sendKeys(Key.Control, 'd'); + await webdriver.executeScript(() => window.scrollTo(0, 1000)); + await body.sendKeys(Key.CONTROL, 'd'); let pageHeight = - await session.executeScript(() => window.document.documentElement.clientHeight); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + await webdriver.executeScript(() => window.document.documentElement.clientHeight); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert(Math.abs(pageYOffset - (1000 + Math.floor(pageHeight / 2))) < 5); }); it('scrolls bottom by ', async () => { - await session.executeScript(() => window.scrollTo(0, 1000)); - await body.sendKeys(Key.Control, 'b'); + await webdriver.executeScript(() => window.scrollTo(0, 1000)); + await body.sendKeys(Key.CONTROL, 'b'); let pageHeight = - await session.executeScript(() => window.document.documentElement.clientHeight); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + await webdriver.executeScript(() => window.document.documentElement.clientHeight); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert(Math.abs(pageYOffset - (1000 - pageHeight)) < 5); }); it('scrolls bottom by ', async () => { - await session.executeScript(() => window.scrollTo(0, 1000)); - await body.sendKeys(Key.Control, 'f'); + await webdriver.executeScript(() => window.scrollTo(0, 1000)); + await body.sendKeys(Key.CONTROL, 'f'); let pageHeight = - await session.executeScript(() => window.document.documentElement.clientHeight); - let pageYOffset = await session.executeScript(() => window.pageYOffset); + await webdriver.executeScript(() => window.document.documentElement.clientHeight); + let pageYOffset = await webdriver.executeScript(() => window.pageYOffset); assert(Math.abs(pageYOffset - (1000 + pageHeight)) < 5); }); }); diff --git a/e2e/tab.test.js b/e2e/tab.test.js index 99f0374..4e3a681 100644 --- a/e2e/tab.test.js +++ b/e2e/tab.test.js @@ -3,8 +3,8 @@ const lanthan = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Builder } = require('lanthan'); +const { Key, By } = require('selenium-webdriver'); const newApp = () => { let app = express(); @@ -20,24 +20,28 @@ describe("tab test", () => { const url = `http://127.0.0.1:${port}/`; let http; - let firefox; - let session; + let lanthan; + let webdriver let browser; let win; let tabs; before(async() => { - firefox = await lanthan.firefox(); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); http = newApp().listen(port); }); after(async() => { - http.close(); - if (firefox) { - await firefox.close(); + if (http) { + http.close(); + } + if (lanthan) { + await lanthan.quit(); } }); @@ -45,7 +49,7 @@ describe("tab test", () => { win = await browser.windows.create({ url: `${url}#0` }); for (let i = 1; i < 5; ++i) { await browser.tabs.create({ url: `${url}#${i}`, windowId: win.id }); - await session.navigateTo(`${url}#${i}`); + await webdriver.navigate().to(`${url}#${i}`); } tabs = await browser.tabs.query({ windowId: win.id }); tabs.sort((t1, t2) => t1.index - t2.index); @@ -57,7 +61,7 @@ describe("tab test", () => { it('deletes tab and selects right by d', async () => { await browser.tabs.update(tabs[3].id, { active: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('d'); let current = await browser.tabs.query({ windowId: win.id }); @@ -68,8 +72,8 @@ describe("tab test", () => { it('deletes tab and selects left by D', async () => { await browser.tabs.update(tabs[3].id, { active: true }); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'D'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'D'); await eventually(async() => { let current = await browser.tabs.query({ windowId: win.id }); @@ -81,7 +85,7 @@ describe("tab test", () => { it('deletes all tabs to the right by x$', async () => { await browser.tabs.update(tabs[1].id, { active: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('x', '$'); let current = await browser.tabs.query({ windowId: win.id }); @@ -90,7 +94,7 @@ describe("tab test", () => { it('duplicates tab by zd', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('z', 'd'); await eventually(async() => { @@ -103,7 +107,7 @@ describe("tab test", () => { it('makes pinned by zp', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('z', 'p'); let current = await browser.tabs.query({ windowId: win.id }); @@ -112,8 +116,8 @@ describe("tab test", () => { it('selects previous tab by K', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'K'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'K'); let current = await browser.tabs.query({ windowId: win.id }); assert(current[1].active); @@ -121,8 +125,8 @@ describe("tab test", () => { it('selects previous tab by K rotatory', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'K'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'K'); let current = await browser.tabs.query({ windowId: win.id }); assert(current[current.length - 1].active) @@ -130,8 +134,8 @@ describe("tab test", () => { it('selects next tab by J', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'J'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'J'); let current = await browser.tabs.query({ windowId: win.id }); assert(current[3].active); @@ -139,8 +143,8 @@ describe("tab test", () => { it('selects previous tab by J rotatory', async () => { await browser.tabs.update(tabs[tabs.length - 1].id, { active: true }); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Shift, 'J'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.SHIFT, 'J'); let current = await browser.tabs.query({ windowId: win.id }); assert(current[0].active) @@ -148,7 +152,7 @@ describe("tab test", () => { it('selects first tab by g0', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('g', '0'); let current = await browser.tabs.query({ windowId: win.id }); @@ -157,7 +161,7 @@ describe("tab test", () => { it('selects last tab by g$', async () => { await browser.tabs.update(tabs[2].id, { active: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('g', '$'); let current = await browser.tabs.query({ windowId: win.id }); @@ -168,8 +172,8 @@ describe("tab test", () => { await browser.tabs.update(tabs[1].id, { active: true }); await browser.tabs.update(tabs[4].id, { active: true }); - let body = await session.findElementByCSS('body'); - await body.sendKeys(Key.Control, '6'); + let body = await webdriver.findElement(By.css('body')); + await body.sendKeys(Key.CONTROL, '6'); let current = await browser.tabs.query({ windowId: win.id }); assert(current[1].active) @@ -179,7 +183,7 @@ describe("tab test", () => { // This might be a bug in Firefox. it.skip('reopen tab by u', async () => { await browser.tabs.remove(tabs[1].id); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('u'); let current = await browser.tabs.query({ windowId: win.id }); @@ -188,7 +192,7 @@ describe("tab test", () => { it('does not delete pinned tab by d', async () => { await browser.tabs.update(tabs[0].id, { active: true, pinned: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('d'); let current = await browser.tabs.query({ windowId: win.id }); @@ -197,7 +201,7 @@ describe("tab test", () => { it('deletes pinned tab by !d', async () => { await browser.tabs.update(tabs[0].id, { active: true, pinned: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('!', 'd'); let current = await browser.tabs.query({ windowId: win.id }); @@ -206,7 +210,7 @@ describe("tab test", () => { it('opens view-source by gf', async () => { await browser.tabs.update(tabs[0].id, { active: true }); - let body = await session.findElementByCSS('body'); + let body = await webdriver.findElement(By.css('body')); await body.sendKeys('g', 'f'); await eventually(async() => { diff --git a/e2e/zoom.test.js b/e2e/zoom.test.js index 186f67f..c11ed1e 100644 --- a/e2e/zoom.test.js +++ b/e2e/zoom.test.js @@ -1,36 +1,34 @@ const express = require('express'); -const lanthan = require('lanthan'); +const { Builder } = require('lanthan'); const path = require('path'); const assert = require('assert'); const eventually = require('./eventually'); - -const Key = lanthan.Key; +const { Key, By } = require('selenium-webdriver'); describe("zoom test", () => { - - let firefox; - let session; + let lanthan; + let webdriver; let browser; let tab; let body; before(async() => { - firefox = await lanthan.firefox(); - await firefox.session.installAddonFromPath(path.join(__dirname, '..')); - session = firefox.session; - browser = firefox.browser; + lanthan = await Builder + .forBrowser('firefox') + .spyAddon(path.join(__dirname, '..')) + .build(); + webdriver = lanthan.getWebDriver(); + browser = lanthan.getWebExtBrowser(); tab = (await browser.tabs.query({}))[0] }); after(async() => { - if (firefox) { - await firefox.close(); - } + await lanthan.quit(); }); beforeEach(async() => { - await session.navigateTo('about:blank'); - body = await session.findElementByCSS('body'); + await webdriver.navigate().to('about:blank'); + body = await webdriver.findElement(By.css('body')); }); it('should zoom in by zi', async () => { From 28a54cdbe6fed55b0d1c75410ff28c8314d2ee7e Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Sep 2019 11:47:50 +0900 Subject: [PATCH 02/18] Install lanthan@0.0.1 --- package-lock.json | 465 ++++++++++++++++++++++++++++------------------ package.json | 2 +- 2 files changed, 283 insertions(+), 184 deletions(-) diff --git a/package-lock.json b/package-lock.json index 07869a7..4459a28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1606,10 +1606,13 @@ "dev": true }, "content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=", - "dev": true + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + } }, "content-type": { "version": "1.0.4", @@ -2677,69 +2680,171 @@ } }, "express": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", - "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", "dev": true, "requires": { - "accepts": "~1.3.5", + "accepts": "~1.3.7", "array-flatten": "1.1.1", - "body-parser": "1.18.3", - "content-disposition": "0.5.2", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", "content-type": "~1.0.4", - "cookie": "0.3.1", + "cookie": "0.4.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "~1.1.2", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.1.1", + "finalhandler": "~1.1.2", "fresh": "0.5.2", "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "~2.3.0", - "parseurl": "~1.3.2", + "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.4", - "qs": "6.5.2", - "range-parser": "~1.2.0", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", "safe-buffer": "5.1.2", - "send": "0.16.2", - "serve-static": "1.13.2", - "setprototypeof": "1.1.0", - "statuses": "~1.4.0", - "type-is": "~1.6.16", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" }, "dependencies": { - "finalhandler": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", - "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", "dev": true, "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "dev": true, + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "statuses": "~1.4.0", - "unpipe": "~1.0.0" + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", + "dev": true + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", + "dev": true + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" } }, + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", + "dev": true + }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", "dev": true }, - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", "dev": true + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "dev": true, + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", + "dev": true + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } } } }, @@ -4496,9 +4601,9 @@ "dev": true }, "ipaddr.js": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", - "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==", "dev": true }, "is-accessor-descriptor": { @@ -5169,128 +5274,16 @@ } }, "lanthan": { - "version": "git+https://github.com/ueokande/lanthan.git#d7f92eb4c1c6eee3f747b4a76bdf39062b4cb58f", - "from": "git+https://github.com/ueokande/lanthan.git#master", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/lanthan/-/lanthan-0.0.1.tgz", + "integrity": "sha512-Q/YMZMzWeAh71valcgYi0zMNvnXDcThGJQV2F32SbGkob1fhQIjJh8ZyUyNjWef0pj0KobUiBg7mv2JzR27O9Q==", "dev": true, "requires": { - "commander": "^2.20.0", - "express": "^4.16.4", - "jszip": "^3.2.1", + "express": "^4.17.1", + "jszip": "^3.2.2", "request": "^2.88.0", - "request-promise-native": "^1.0.7" - }, - "dependencies": { - "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", - "dev": true, - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "dev": true - }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true - }, - "har-validator": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", - "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", - "dev": true, - "requires": { - "ajv": "^6.5.5", - "har-schema": "^2.0.0" - } - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==", - "dev": true - }, - "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", - "dev": true, - "requires": { - "mime-db": "~1.38.0" - } - }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true - }, - "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", - "dev": true, - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.0", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - } - }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", - "dev": true, - "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - } - }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true - } + "request-promise-native": "^1.0.7", + "selenium-webdriver": "^4.0.0-alpha.5" } }, "lcid": { @@ -6948,9 +6941,9 @@ } }, "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, "pascalcase": { @@ -7278,13 +7271,13 @@ } }, "proxy-addr": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", - "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", "dev": true, "requires": { "forwarded": "~0.1.2", - "ipaddr.js": "1.8.0" + "ipaddr.js": "1.9.0" } }, "prr": { @@ -7991,6 +7984,12 @@ } } }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, "scheduler": { "version": "0.15.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.15.0.tgz", @@ -8033,6 +8032,52 @@ } } }, + "selenium-webdriver": { + "version": "4.0.0-alpha.5", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.5.tgz", + "integrity": "sha512-hktl3DSrhzM59yLhWzDGHIX9o56DvA+cVK7Dw6FcJR6qQ4CGzkaHeXQPcdrslkWMTeq0Ci9AmCxq0EMOvm2Rkg==", + "dev": true, + "requires": { + "jszip": "^3.1.5", + "rimraf": "^2.6.3", + "tmp": "0.0.30", + "xml2js": "^0.4.19" + }, + "dependencies": { + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "tmp": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.30.tgz", + "integrity": "sha1-ckGdSovn1s51FI/YsyTlk6cRwu0=", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.1" + } + } + } + }, "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", @@ -8040,9 +8085,9 @@ "dev": true }, "send": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", - "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", "dev": true, "requires": { "debug": "2.6.9", @@ -8052,24 +8097,55 @@ "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.6.2", - "mime": "1.4.1", - "ms": "2.0.0", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", "on-finished": "~2.3.0", - "range-parser": "~1.2.0", - "statuses": "~1.4.0" + "range-parser": "~1.2.1", + "statuses": "~1.5.0" }, "dependencies": { + "http-errors": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", + "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", "dev": true }, - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", "dev": true } } @@ -8081,15 +8157,15 @@ "dev": true }, "serve-static": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", - "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", "dev": true, "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", - "parseurl": "~1.3.2", - "send": "0.16.2" + "parseurl": "~1.3.3", + "send": "0.17.1" } }, "set-blocking": { @@ -9096,6 +9172,12 @@ } } }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "dev": true + }, "toposort": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/toposort/-/toposort-1.0.7.tgz", @@ -10102,6 +10184,23 @@ "ultron": "~1.1.0" } }, + "xml2js": { + "version": "0.4.22", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.22.tgz", + "integrity": "sha512-MWTbxAQqclRSTnehWWe5nMKzI3VmJ8ltiJEco8akcC6j3miOhjjfzKum5sId+CWhfxdOs/1xauYr8/ZDBtQiRw==", + "dev": true, + "requires": { + "sax": ">=0.6.0", + "util.promisify": "~1.0.0", + "xmlbuilder": "~11.0.0" + } + }, + "xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "dev": true + }, "xmlhttprequest-ssl": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", diff --git a/package.json b/package.json index 2306396..f97a32f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "karma-sinon": "^1.0.5", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^4.0.2", - "lanthan": "git+https://github.com/ueokande/lanthan.git#master", + "lanthan": "0.0.1", "mocha": "^6.2.0", "node-sass": "^4.12.0", "react": "^16.9.0", From 6301af82494413a662aa58816eabfc715405f29c Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Sep 2019 11:55:07 +0900 Subject: [PATCH 03/18] Install lanthan@0.0.2 --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4459a28..5975f3e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5274,9 +5274,9 @@ } }, "lanthan": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/lanthan/-/lanthan-0.0.1.tgz", - "integrity": "sha512-Q/YMZMzWeAh71valcgYi0zMNvnXDcThGJQV2F32SbGkob1fhQIjJh8ZyUyNjWef0pj0KobUiBg7mv2JzR27O9Q==", + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/lanthan/-/lanthan-0.0.2.tgz", + "integrity": "sha512-+nWapmVfFCprRE39Z6pKyf5KCclJJvSyAU0o3G2Tl+yZc77xDtqL2JfBADVHk7UNQBrqyg62FPtLq4NeQsFdVA==", "dev": true, "requires": { "express": "^4.17.1", diff --git a/package.json b/package.json index f97a32f..798af0b 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "karma-sinon": "^1.0.5", "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "^4.0.2", - "lanthan": "0.0.1", + "lanthan": "0.0.2", "mocha": "^6.2.0", "node-sass": "^4.12.0", "react": "^16.9.0", From 91f8383ecc2f7ef3f95173ad973a74f79e277a6c Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Sep 2019 12:15:44 +0900 Subject: [PATCH 04/18] Install ts-node@8.4.1 --- package-lock.json | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 40 insertions(+) diff --git a/package-lock.json b/package-lock.json index 5975f3e..5a86613 100644 --- a/package-lock.json +++ b/package-lock.json @@ -591,6 +591,12 @@ "readable-stream": "^2.0.6" } }, + "arg": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", + "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -5551,6 +5557,12 @@ } } }, + "make-error": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", + "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", + "dev": true + }, "mamacro": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/mamacro/-/mamacro-0.0.3.tgz", @@ -9310,6 +9322,27 @@ } } }, + "ts-node": { + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.4.1.tgz", + "integrity": "sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.6", + "yn": "^3.0.0" + }, + "dependencies": { + "diff": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true + } + } + }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", @@ -10403,6 +10436,12 @@ "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", "dev": true + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true } } } diff --git a/package.json b/package.json index 798af0b..cdebac7 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "sinon-chrome": "^3.0.1", "style-loader": "^1.0.0", "ts-loader": "^6.0.4", + "ts-node": "^8.4.1", "tsyringe": "^3.3.0", "typescript": "^3.6.2", "web-ext-types": "^3.2.1", From 7e77e31ad64c3649888eae337e0c984fd9c2ea2a Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 22 Sep 2019 16:13:12 +0900 Subject: [PATCH 05/18] Migrate e2e tests to TypeScript --- e2e/{blacklist.test.js => blacklist.test.ts} | 24 +++--- e2e/{clipboard.test.js => clipboard.test.ts} | 32 +++---- ...rk.test.js => command_addbookmark.test.ts} | 24 +++--- ...delete.test.js => command_bdelete.test.ts} | 30 ++++--- ..._buffer.test.js => command_buffer.test.ts} | 24 +++--- ...mand_open.test.js => command_open.test.ts} | 30 ++++--- ...mand_quit.test.js => command_quit.test.ts} | 23 ++--- ...abopen.test.js => command_tabopen.test.ts} | 31 ++++--- ...inopen.test.js => command_winopen.test.ts} | 30 ++++--- ...{completion.test.js => completion.test.ts} | 48 ++++++----- ...ers.test.js => completion_buffers.test.ts} | 86 ++++++++++--------- ...n_open.test.js => completion_open.test.ts} | 57 ++++++------ ...ion_set.test.js => completion_set.test.ts} | 36 ++++---- e2e/{console.test.js => console.test.ts} | 42 +++++---- e2e/eventually.js | 23 ----- e2e/eventually.ts | 30 +++++++ e2e/{follow.test.js => follow.test.ts} | 46 +++++----- ...ties.test.js => follow_properties.test.ts} | 38 ++++---- e2e/lib/{Console.js => Console.ts} | 30 ++++--- e2e/lib/{clipboard.js => clipboard.ts} | 53 ++++++------ e2e/{mark.test.js => mark.test.ts} | 30 ++++--- e2e/{navigate.test.js => navigate.test.ts} | 44 +++++----- e2e/{options.test.js => options.test.ts} | 27 +++--- ...ions_form.test.js => options_form.test.ts} | 20 +++-- e2e/{repeat.test.js => repeat.test.ts} | 29 +++---- e2e/{scroll.test.js => scroll.test.ts} | 69 +++++++-------- e2e/{settings.js => settings.ts} | 4 +- e2e/{tab.test.js => tab.test.ts} | 78 ++++++++--------- e2e/{zoom.test.js => zoom.test.ts} | 29 ++++--- 29 files changed, 552 insertions(+), 515 deletions(-) rename e2e/{blacklist.test.js => blacklist.test.ts} (81%) rename e2e/{clipboard.test.js => clipboard.test.ts} (84%) rename e2e/{command_addbookmark.test.js => command_addbookmark.test.ts} (76%) rename e2e/{command_bdelete.test.js => command_bdelete.test.ts} (91%) rename e2e/{command_buffer.test.js => command_buffer.test.ts} (93%) rename e2e/{command_open.test.js => command_open.test.ts} (88%) rename e2e/{command_quit.test.js => command_quit.test.ts} (89%) rename e2e/{command_tabopen.test.js => command_tabopen.test.ts} (89%) rename e2e/{command_winopen.test.js => command_winopen.test.ts} (90%) rename e2e/{completion.test.js => completion.test.ts} (74%) rename e2e/{completion_buffers.test.js => completion_buffers.test.ts} (71%) rename e2e/{completion_open.test.js => completion_open.test.ts} (82%) rename e2e/{completion_set.test.js => completion_set.test.ts} (65%) rename e2e/{console.test.js => console.test.ts} (83%) delete mode 100644 e2e/eventually.js create mode 100644 e2e/eventually.ts rename e2e/{follow.test.js => follow.test.ts} (88%) rename e2e/{follow_properties.test.js => follow_properties.test.ts} (88%) rename e2e/lib/{Console.js => Console.ts} (56%) rename e2e/lib/{clipboard.js => clipboard.ts} (53%) rename e2e/{mark.test.js => mark.test.ts} (87%) rename e2e/{navigate.test.js => navigate.test.ts} (91%) rename e2e/{options.test.js => options.test.ts} (85%) rename e2e/{options_form.test.js => options_form.test.ts} (91%) rename e2e/{repeat.test.js => repeat.test.ts} (83%) rename e2e/{scroll.test.js => scroll.test.ts} (76%) rename e2e/{settings.js => settings.ts} (99%) rename e2e/{tab.test.js => tab.test.ts} (79%) rename e2e/{zoom.test.js => zoom.test.ts} (73%) diff --git a/e2e/blacklist.test.js b/e2e/blacklist.test.ts similarity index 81% rename from e2e/blacklist.test.js rename to e2e/blacklist.test.ts index 8a8996e..c88f655 100644 --- a/e2e/blacklist.test.js +++ b/e2e/blacklist.test.ts @@ -1,13 +1,13 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const settings = require('./settings'); -const { Builder } = require('lanthan'); -const { By } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, By } from 'selenium-webdriver'; +import * as http from 'http'; const newApp = () => { let app = express(); - app.get('/*', (req, res) => { + app.get('/*', (_req, res) => { res.status(200).send(` @@ -17,12 +17,11 @@ const newApp = () => { }; describe("navigate test", () => { - const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; before(async() => { http = newApp().listen(port); @@ -73,4 +72,3 @@ describe("navigate test", () => { assert.equal(pageYOffset, 64); }); }); - diff --git a/e2e/clipboard.test.js b/e2e/clipboard.test.ts similarity index 84% rename from e2e/clipboard.test.js rename to e2e/clipboard.test.ts index df31770..dbc00de 100644 --- a/e2e/clipboard.test.js +++ b/e2e/clipboard.test.ts @@ -1,15 +1,17 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const clipboard = require('./lib/clipboard'); -const settings = require('./settings'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import eventually from './eventually'; +import * as clipboard from './lib/clipboard'; +import settings from './settings'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.status(200).send(``); }); return app; @@ -18,10 +20,10 @@ const newApp = () => { describe("navigate test", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; before(async() => { http = newApp().listen(port); @@ -85,7 +87,7 @@ describe("navigate test", () => { await eventually(async() => { let tabs = await browser.tabs.query({}); - assert.deepEqual(tabs.map(t => t.url), [ + assert.deepEqual(tabs.map((t: any) => t.url), [ `http://127.0.0.1:${port}/`, `http://127.0.0.1:${port}/#open_to_new_tab`, ]); @@ -114,7 +116,7 @@ describe("navigate test", () => { await eventually(async() => { let tabs = await browser.tabs.query({}); - assert.deepEqual(tabs.map(t => t.url), [ + assert.deepEqual(tabs.map((t: any) => t.url), [ `http://127.0.0.1:${port}/`, `http://127.0.0.1:${port}/google?q=an%20apple`, ]); diff --git a/e2e/command_addbookmark.test.js b/e2e/command_addbookmark.test.ts similarity index 76% rename from e2e/command_addbookmark.test.js rename to e2e/command_addbookmark.test.ts index 68d1c6d..ad94494 100644 --- a/e2e/command_addbookmark.test.js +++ b/e2e/command_addbookmark.test.ts @@ -1,13 +1,15 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); - app.get('/happy', (req, res) => { + app.get('/happy', (_req, res) => { res.send(` @@ -20,10 +22,10 @@ const newApp = () => { describe('addbookmark command test', () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; before(async() => { http = newApp().listen(port); diff --git a/e2e/command_bdelete.test.js b/e2e/command_bdelete.test.ts similarity index 91% rename from e2e/command_bdelete.test.js rename to e2e/command_bdelete.test.ts index aae5b67..ce54b23 100644 --- a/e2e/command_bdelete.test.js +++ b/e2e/command_bdelete.test.ts @@ -1,9 +1,11 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); @@ -21,10 +23,10 @@ const newApp = () => { describe('bdelete/bdeletes command test', () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; before(async() => { http = newApp().listen(port); @@ -74,7 +76,7 @@ describe('bdelete/bdeletes command test', () => { await eventually(async() => { let tabs = await browser.tabs.query({}); - assert.deepEqual(tabs.map(t => t.url), [ + assert.deepEqual(tabs.map((t: any) => t.url), [ `http://127.0.0.1:${port}/site1`, `http://127.0.0.1:${port}/site2`, `http://127.0.0.1:${port}/site3`, @@ -137,7 +139,7 @@ describe('bdelete/bdeletes command test', () => { await eventually(async() => { let tabs = await browser.tabs.query({}); - assert.deepEqual(tabs.map(t => t.url), [ + assert.deepEqual(tabs.map((t: any) => t.url), [ `http://127.0.0.1:${port}/site1`, `http://127.0.0.1:${port}/site2`, `http://127.0.0.1:${port}/site3`, @@ -156,7 +158,7 @@ describe('bdelete/bdeletes command test', () => { await eventually(async() => { let tabs = await browser.tabs.query({}); - assert.deepEqual(tabs.map(t => t.url), [ + assert.deepEqual(tabs.map((t: any) => t.url), [ `http://127.0.0.1:${port}/site2`, `http://127.0.0.1:${port}/site3`, `http://127.0.0.1:${port}/site4`, @@ -175,7 +177,7 @@ describe('bdelete/bdeletes command test', () => { await eventually(async() => { let tabs = await browser.tabs.query({}); - assert.deepEqual(tabs.map(t => t.url), [ + assert.deepEqual(tabs.map((t: any) => t.url), [ `http://127.0.0.1:${port}/site1`, `http://127.0.0.1:${port}/site2`, `http://127.0.0.1:${port}/site3`, diff --git a/e2e/command_buffer.test.js b/e2e/command_buffer.test.ts similarity index 93% rename from e2e/command_buffer.test.js rename to e2e/command_buffer.test.ts index b3336dc..e642673 100644 --- a/e2e/command_buffer.test.js +++ b/e2e/command_buffer.test.ts @@ -1,9 +1,11 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); @@ -21,10 +23,10 @@ const newApp = () => { describe('buffer command test', () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; before(async() => { http = newApp().listen(port); @@ -105,7 +107,7 @@ describe('buffer command test', () => { assert.equal(text, 'tab 0 does not exist'); }); - await webdriver.switchTo().parentFrame(); + await (webdriver.switchTo() as any).parentFrame(); body = await webdriver.findElement(By.css('body')); await body.sendKeys(':'); diff --git a/e2e/command_open.test.js b/e2e/command_open.test.ts similarity index 88% rename from e2e/command_open.test.js rename to e2e/command_open.test.ts index ccf7393..cfaee15 100644 --- a/e2e/command_open.test.js +++ b/e2e/command_open.test.ts @@ -1,23 +1,25 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const settings = require('./settings'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import settings from './settings'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) { - app.get('/' + name, (req, res) => { + app.get('/' + name, (_req, res) => { res.send(`

${name.charAt(0).toUpperCase() + name.slice(1)}

`); }); } - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.send(`

home

@@ -28,11 +30,11 @@ const newApp = () => { describe("open command test", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; - let body; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + let body: WebElement; before(async() => { lanthan = await Builder diff --git a/e2e/command_quit.test.js b/e2e/command_quit.test.ts similarity index 89% rename from e2e/command_quit.test.js rename to e2e/command_quit.test.ts index 07e770a..29b947a 100644 --- a/e2e/command_quit.test.js +++ b/e2e/command_quit.test.ts @@ -1,9 +1,12 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, By, Key } from 'selenium-webdriver'; + const newApp = () => { let app = express(); @@ -21,10 +24,10 @@ const newApp = () => { describe('quit/quitall command test', () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; before(async() => { http = newApp().listen(port); diff --git a/e2e/command_tabopen.test.js b/e2e/command_tabopen.test.ts similarity index 89% rename from e2e/command_tabopen.test.js rename to e2e/command_tabopen.test.ts index 78f5d7f..ca4ad92 100644 --- a/e2e/command_tabopen.test.js +++ b/e2e/command_tabopen.test.ts @@ -1,23 +1,26 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const settings = require('./settings'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import settings from './settings'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By, Key } from 'selenium-webdriver'; + const newApp = () => { let app = express(); for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) { - app.get('/' + name, (req, res) => { + app.get('/' + name, (_req, res) => { res.send(`

${name.charAt(0).toUpperCase() + name.slice(1)}

`); }); } - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.send(`

home

@@ -28,11 +31,11 @@ const newApp = () => { describe("tabopen command test", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; - let body; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + let body: WebElement; before(async() => { http = newApp().listen(port); diff --git a/e2e/command_winopen.test.js b/e2e/command_winopen.test.ts similarity index 90% rename from e2e/command_winopen.test.js rename to e2e/command_winopen.test.ts index 149d775..cdd4c1c 100644 --- a/e2e/command_winopen.test.js +++ b/e2e/command_winopen.test.ts @@ -1,23 +1,25 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const settings = require('./settings'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import settings from './settings'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); for (let name of ['google', 'yahoo', 'bing', 'duckduckgo', 'twitter', 'wikipedia']) { - app.get('/' + name, (req, res) => { + app.get('/' + name, (_req, res) => { res.send(`

${name.charAt(0).toUpperCase() + name.slice(1)}

`); }); } - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.send(`

home

@@ -28,11 +30,11 @@ const newApp = () => { describe("winopen command test", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; - let body; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + let body: WebElement; before(async() => { http = newApp().listen(port); diff --git a/e2e/completion.test.js b/e2e/completion.test.ts similarity index 74% rename from e2e/completion.test.js rename to e2e/completion.test.ts index fc87df0..fd58f74 100644 --- a/e2e/completion.test.js +++ b/e2e/completion.test.ts @@ -1,15 +1,17 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const settings = require('./settings'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); -const Console = require('./lib/Console'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import settings from './settings'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By, Key } from 'selenium-webdriver'; +import { Console } from './lib/Console'; const newApp = () => { let app = express(); - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.send(` ok @@ -20,11 +22,11 @@ const newApp = () => { describe("general completion test", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; - let body; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + let body: WebElement; before(async() => { lanthan = await Builder @@ -62,9 +64,9 @@ describe("general completion test", () => { let items = await c.getCompletions(); assert.equal(items.length, 10); assert.deepEqual(items[0], { type: 'title', text: 'Console Command' }); - assert(items[1].text.startsWith('set')) - assert(items[2].text.startsWith('open')) - assert(items[3].text.startsWith('tabopen')) + assert.ok(items[1].text.startsWith('set')) + assert.ok(items[2].text.startsWith('open')) + assert.ok(items[3].text.startsWith('tabopen')) }); }); @@ -79,9 +81,9 @@ describe("general completion test", () => { let items = await c.getCompletions(); assert.equal(items.length, 4); assert.deepEqual(items[0], { type: 'title', text: 'Console Command' }); - assert(items[1].text.startsWith('buffer')) - assert(items[2].text.startsWith('bdelete')) - assert(items[3].text.startsWith('bdeletes')) + assert.ok(items[1].text.startsWith('buffer')) + assert.ok(items[2].text.startsWith('bdelete')) + assert.ok(items[3].text.startsWith('bdeletes')) }); }); @@ -100,7 +102,7 @@ describe("general completion test", () => { await c.sendKeys(Key.TAB); await eventually(async() => { let items = await c.getCompletions(); - assert(items[1].highlight) + assert.ok(items[1].highlight) let v = await c.currentValue(); assert.equal(v, 'buffer'); @@ -109,7 +111,7 @@ describe("general completion test", () => { await c.sendKeys(Key.TAB, Key.TAB); await eventually(async() => { let items = await c.getCompletions(); - assert(items[3].highlight) + assert.ok(items[3].highlight) let v = await c.currentValue(); assert.equal(v, 'bdeletes'); @@ -124,7 +126,7 @@ describe("general completion test", () => { await c.sendKeys(Key.SHIFT, Key.TAB); await eventually(async() => { let items = await c.getCompletions(); - assert(items[3].highlight) + assert.ok(items[3].highlight) let v = await c.currentValue(); assert.equal(v, 'bdeletes'); diff --git a/e2e/completion_buffers.test.js b/e2e/completion_buffers.test.ts similarity index 71% rename from e2e/completion_buffers.test.js rename to e2e/completion_buffers.test.ts index 87d2397..9c212cc 100644 --- a/e2e/completion_buffers.test.js +++ b/e2e/completion_buffers.test.ts @@ -1,11 +1,13 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const settings = require('./settings'); -const Console = require('./lib/Console'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import settings from './settings'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By } from 'selenium-webdriver'; +import { Console } from './lib/Console'; const newApp = () => { @@ -24,11 +26,11 @@ const newApp = () => { describe("completion on buffer/bdelete/bdeletes", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; - let body; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + let body: WebElement; before(async() => { lanthan = await Builder @@ -85,14 +87,14 @@ describe("completion on buffer/bdelete/bdeletes", () => { let items = await c.getCompletions(); assert.equal(items.length, 6); assert.deepEqual(items[0], { type: 'title', text: 'Buffers' }); - assert(items[1].text.startsWith('1:')); - assert(items[2].text.startsWith('2:')); - assert(items[3].text.startsWith('3:')); - assert(items[4].text.startsWith('4:')); - assert(items[5].text.startsWith('5:')); - - assert(items[3].text.includes('%')); - assert(items[5].text.includes('#')); + assert.ok(items[1].text.startsWith('1:')); + assert.ok(items[2].text.startsWith('2:')); + assert.ok(items[3].text.startsWith('3:')); + assert.ok(items[4].text.startsWith('4:')); + assert.ok(items[5].text.startsWith('5:')); + + assert.ok(items[3].text.includes('%')); + assert.ok(items[5].text.includes('#')); }); }) @@ -106,9 +108,9 @@ describe("completion on buffer/bdelete/bdeletes", () => { await eventually(async() => { let items = await c.getCompletions(); assert.deepEqual(items[0], { type: 'title', text: 'Buffers' }); - assert(items[1].text.startsWith('2:')); - assert(items[1].text.includes('title_site2')); - assert(items[1].text.includes(`http://127.0.0.1:${port}/site2`)); + assert.ok(items[1].text.startsWith('2:')); + assert.ok(items[1].text.includes('title_site2')); + assert.ok(items[1].text.includes(`http://127.0.0.1:${port}/site2`)); }); }) @@ -122,7 +124,7 @@ describe("completion on buffer/bdelete/bdeletes", () => { await eventually(async() => { let items = await c.getCompletions(); assert.deepEqual(items[0], { type: 'title', text: 'Buffers' }); - assert(items[1].text.startsWith('2:')); + assert.ok(items[1].text.startsWith('2:')); }); }) @@ -137,7 +139,7 @@ describe("completion on buffer/bdelete/bdeletes", () => { let items = await c.getCompletions(); assert.equal(items.length, 2); assert.deepEqual(items[0], { type: 'title', text: 'Buffers' }); - assert(items[1].text.startsWith('2:')); + assert.ok(items[1].text.startsWith('2:')); }); }) @@ -151,9 +153,9 @@ describe("completion on buffer/bdelete/bdeletes", () => { await eventually(async() => { let items = await c.getCompletions(); assert.equal(items.length, 4); - assert(items[1].text.includes('site3')); - assert(items[2].text.includes('site4')); - assert(items[3].text.includes('site5')); + assert.ok(items[1].text.includes('site3')); + assert.ok(items[2].text.includes('site4')); + assert.ok(items[3].text.includes('site5')); }); }) @@ -167,9 +169,9 @@ describe("completion on buffer/bdelete/bdeletes", () => { await eventually(async() => { let items = await c.getCompletions(); assert.equal(items.length, 4); - assert(items[1].text.includes('site3')); - assert(items[2].text.includes('site4')); - assert(items[3].text.includes('site5')); + assert.ok(items[1].text.includes('site3')); + assert.ok(items[2].text.includes('site4')); + assert.ok(items[3].text.includes('site5')); }); }) @@ -183,11 +185,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { await eventually(async() => { let items = await c.getCompletions(); assert.equal(items.length, 6); - assert(items[1].text.includes('site1')); - assert(items[2].text.includes('site2')); - assert(items[3].text.includes('site3')); - assert(items[4].text.includes('site4')); - assert(items[5].text.includes('site5')); + assert.ok(items[1].text.includes('site1')); + assert.ok(items[2].text.includes('site2')); + assert.ok(items[3].text.includes('site3')); + assert.ok(items[4].text.includes('site4')); + assert.ok(items[5].text.includes('site5')); }); }) @@ -201,11 +203,11 @@ describe("completion on buffer/bdelete/bdeletes", () => { await eventually(async() => { let items = await c.getCompletions(); assert.equal(items.length, 6); - assert(items[1].text.includes('site1')); - assert(items[2].text.includes('site2')); - assert(items[3].text.includes('site3')); - assert(items[4].text.includes('site4')); - assert(items[5].text.includes('site5')); + assert.ok(items[1].text.includes('site1')); + assert.ok(items[2].text.includes('site2')); + assert.ok(items[3].text.includes('site3')); + assert.ok(items[4].text.includes('site4')); + assert.ok(items[5].text.includes('site5')); }); }) }); diff --git a/e2e/completion_open.test.js b/e2e/completion_open.test.ts similarity index 82% rename from e2e/completion_open.test.js rename to e2e/completion_open.test.ts index b2b7484..dcd1829 100644 --- a/e2e/completion_open.test.js +++ b/e2e/completion_open.test.ts @@ -1,17 +1,18 @@ -const express = require('express'); -const lanthan = require('lanthan'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const settings = require('./settings'); -const { Builder } = require('lanthan'); -const { By, Key } = require('selenium-webdriver'); -const Console = require('./lib/Console'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import settings from './settings'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By, Key } from 'selenium-webdriver'; +import { Console } from './lib/Console'; const newApp = () => { let app = express(); - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.send(` ok @@ -22,11 +23,11 @@ const newApp = () => { describe("completion on open/tabopen/winopen commands", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; - let body; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + let body: WebElement; before(async() => { lanthan = await Builder @@ -66,9 +67,9 @@ describe("completion on open/tabopen/winopen commands", () => { await eventually(async() => { let completions = await c.getCompletions(); - assert(completions.find(x => x.type === 'title' && x.text === 'Search Engines')); - assert(completions.find(x => x.type === 'title' && x.text === 'Bookmarks')); - assert(completions.find(x => x.type === 'title' && x.text === 'History')); + assert.ok(completions.find(x => x.type === 'title' && x.text === 'Search Engines')); + assert.ok(completions.find(x => x.type === 'title' && x.text === 'Bookmarks')); + assert.ok(completions.find(x => x.type === 'title' && x.text === 'History')); }); }); @@ -82,7 +83,7 @@ describe("completion on open/tabopen/winopen commands", () => { await eventually(async() => { let completions = await c.getCompletions(); let items = completions.filter(x => x.type === 'item').map(x => x.text); - assert(items.every(x => x.includes('https://'))); + assert.ok(items.every(x => x.includes('https://'))); }); }) @@ -96,7 +97,7 @@ describe("completion on open/tabopen/winopen commands", () => { await eventually(async() => { let completions = await c.getCompletions(); let items = completions.filter(x => x.type === 'item').map(x => x.text); - assert(items.every(x => x.toLowerCase().includes('getting'))); + assert.ok(items.every(x => x.toLowerCase().includes('getting'))); }); }) @@ -110,7 +111,7 @@ describe("completion on open/tabopen/winopen commands", () => { await eventually(async() => { let completions = await c.getCompletions(); let items = completions.filter(x => x.type === 'item').map(x => x.text); - assert(items.every(x => x.includes('https://'))); + assert.ok(items.every(x => x.includes('https://'))); }); }) @@ -124,22 +125,22 @@ describe("completion on open/tabopen/winopen commands", () => { await eventually(async() => { let completions = await c.getCompletions(); let items = completions.filter(x => x.type === 'item').map(x => x.text); - assert(items.every(x => x.includes('https://'))); + assert.ok(items.every(x => x.includes('https://'))); }); }) it('should display only specified items in "complete" property by set command', async() => { let c = new Console(webdriver); - const execCommand = async(line) => { + const execCommand = async(line: string) => { await body.sendKeys(':'); await webdriver.switchTo().frame(0); await c.sendKeys(line, Key.ENTER); await new Promise(resolve => setTimeout(resolve, 100)); - await webdriver.switchTo().parentFrame(); + await (webdriver.switchTo() as any).parentFrame(); } - const typeCommand = async(...keys) => { + const typeCommand = async(...keys: string[]) => { await body.sendKeys(':'); await webdriver.switchTo().frame(0); await c.sendKeys(...keys); @@ -148,7 +149,7 @@ describe("completion on open/tabopen/winopen commands", () => { const cancel = async() => { await c.sendKeys(Key.ESCAPE); await new Promise(resolve => setTimeout(resolve, 100)); - await webdriver.switchTo().parentFrame(); + await (webdriver.switchTo() as any).parentFrame(); } await execCommand('set complete=sbh'); @@ -191,7 +192,7 @@ describe("completion on open/tabopen/winopen commands", () => { let c = new Console(webdriver); - const typeCommand = async(...keys) => { + const typeCommand = async(...keys: string[]) => { await body.sendKeys(':'); await webdriver.switchTo().frame(0); await c.sendKeys(...keys); @@ -200,7 +201,7 @@ describe("completion on open/tabopen/winopen commands", () => { const cancel = async() => { await c.sendKeys(Key.ESCAPE); await new Promise(resolve => setTimeout(resolve, 100)); - await webdriver.switchTo().parentFrame(); + await (webdriver.switchTo() as any).parentFrame(); } await browser.storage.local.set({ settings: { diff --git a/e2e/completion_set.test.js b/e2e/completion_set.test.ts similarity index 65% rename from e2e/completion_set.test.js rename to e2e/completion_set.test.ts index a6ec248..018479f 100644 --- a/e2e/completion_set.test.js +++ b/e2e/completion_set.test.ts @@ -1,19 +1,17 @@ -const express = require('express'); -const lanthan = require('lanthan'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const settings = require('./settings'); -const Console = require('./lib/Console'); -const { Builder } = require('lanthan'); -const { By } = require('selenium-webdriver'); +import * as path from 'path'; +import * as assert from 'assert'; + +import settings from './settings'; +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By } from 'selenium-webdriver'; +import { Console } from './lib/Console'; describe("completion on set commands", () => { - const port = 12321; - let lanthan; - let session; - let browser; - let body; + let lanthan: Lanthan; + let webdriver: WebDriver; + let browser: any; + let body: WebElement; before(async() => { lanthan = await Builder @@ -50,10 +48,10 @@ describe("completion on set commands", () => { let items = await c.getCompletions(); assert.equal(items.length, 5); assert.deepEqual(items[0], { type: 'title', text: 'Properties' }); - assert(items[1].text.startsWith('hintchars')) - assert(items[2].text.startsWith('smoothscroll')) - assert(items[3].text.startsWith('nosmoothscroll')) - assert(items[4].text.startsWith('complete')) + assert.ok(items[1].text.startsWith('hintchars')) + assert.ok(items[2].text.startsWith('smoothscroll')) + assert.ok(items[3].text.startsWith('nosmoothscroll')) + assert.ok(items[4].text.startsWith('complete')) }); }); @@ -67,7 +65,7 @@ describe("completion on set commands", () => { await eventually(async() => { let items = await c.getCompletions(); assert.equal(items.length, 2); - assert(items[1].text.includes('nosmoothscroll')) + assert.ok(items[1].text.includes('nosmoothscroll')) }); }); }); diff --git a/e2e/console.test.js b/e2e/console.test.ts similarity index 83% rename from e2e/console.test.js rename to e2e/console.test.ts index 131a4ef..65c5d2d 100644 --- a/e2e/console.test.js +++ b/e2e/console.test.ts @@ -1,13 +1,14 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const { Builder } = require('lanthan'); -const { Key, By } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, WebElement, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.send(` @@ -21,12 +22,10 @@ const newApp = () => { describe("console test", () => { const port = 12321; - let http; - let lanthan; - let webdriver; - let browser; - let tab; - let body; + let http: http.Server; + let lanthan: Lanthan; + let webdriver: WebDriver; + let body: WebElement; before(async() => { http = newApp().listen(port); @@ -35,7 +34,6 @@ describe("console test", () => { .spyAddon(path.join(__dirname, '..')) .build(); webdriver = lanthan.getWebDriver(); - browser = lanthan.getWebExtBrowser(); }); after(async() => { @@ -65,7 +63,7 @@ describe("console test", () => { await body.sendKeys('o'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, 'open '); }); @@ -73,7 +71,7 @@ describe("console test", () => { await body.sendKeys(Key.SHIFT, 'o'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, `open http://127.0.0.1:${port}/`); }); @@ -81,7 +79,7 @@ describe("console test", () => { await body.sendKeys('t'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, 'tabopen '); }); @@ -89,7 +87,7 @@ describe("console test", () => { await body.sendKeys(Key.SHIFT, 't'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, `tabopen http://127.0.0.1:${port}/`); }); @@ -97,7 +95,7 @@ describe("console test", () => { await body.sendKeys('w'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, 'winopen '); }); @@ -105,7 +103,7 @@ describe("console test", () => { await body.sendKeys(Key.SHIFT, 'W'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, `winopen http://127.0.0.1:${port}/`); }); @@ -113,7 +111,7 @@ describe("console test", () => { await body.sendKeys('b'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, `buffer `); }); @@ -121,7 +119,7 @@ describe("console test", () => { await body.sendKeys('a'); await webdriver.switchTo().frame(0); - let value = await webdriver.executeScript(() => document.querySelector('input').value); + let value = await webdriver.executeScript(() => document.querySelector('input')!!.value); assert.equal(value, `addbookmark Hello, world!`); }); }); diff --git a/e2e/eventually.js b/e2e/eventually.js deleted file mode 100644 index ab0ae25..0000000 --- a/e2e/eventually.js +++ /dev/null @@ -1,23 +0,0 @@ -let defaultInterval = 100; -let defaultTimeout = 2000; - -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} - -const eventually = async (fn, timeout = defaultTimeout, interval = defaultInterval) => { - let start = Date.now(); - let loop = async() => { - try { - await fn(); - } catch (err) { - if (Date.now() - start > timeout) { - throw err; - } - await new Promise((resolve) => setTimeout(resolve, interval)) - await loop(); - } - }; - await loop(); -}; -module.exports = eventually; diff --git a/e2e/eventually.ts b/e2e/eventually.ts new file mode 100644 index 0000000..12c4552 --- /dev/null +++ b/e2e/eventually.ts @@ -0,0 +1,30 @@ +const defaultInterval = 100; +const defaultTimeout = 2000; + +type Handler = () => void + +const sleep = (ms: number): Promise => { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +const eventually = async ( + fn: Handler, + timeout = defaultTimeout, + interval = defaultInterval, +): Promise => { + let start = Date.now(); + let loop = async() => { + try { + await fn(); + } catch (err) { + if (Date.now() - start > timeout) { + throw err; + } + await sleep(interval); + await loop(); + } + }; + await loop(); +}; + +export default eventually; diff --git a/e2e/follow.test.js b/e2e/follow.test.ts similarity index 88% rename from e2e/follow.test.js rename to e2e/follow.test.ts index 336d673..5d38085 100644 --- a/e2e/follow.test.js +++ b/e2e/follow.test.ts @@ -1,28 +1,30 @@ -const express = require('express'); -const path = require('path'); -const assert = require('assert'); -const eventually = require('./eventually'); -const { Builder } = require('lanthan'); -const { Key, By } = require('selenium-webdriver'); +import express from 'express'; +import * as path from 'path'; +import * as assert from 'assert'; +import * as http from 'http'; + +import eventually from './eventually'; +import { Builder, Lanthan } from 'lanthan'; +import { WebDriver, By, Key } from 'selenium-webdriver'; const newApp = () => { let app = express(); - app.get('/', (req, res) => { + app.get('/', (_req, res) => { res.send(`
hello `); }); - app.get('/follow-input', (req, res) => { + app.get('/follow-input', (_req, res) => { res.send(` `); }); - app.get('/area', (req, res) => { + app.get('/area', (_req, res) => { res.send(` @@ -49,7 +51,7 @@ const newApp = () => { * | | * +-----------------+ */ - app.get('/test1', (req, res) => { + app.get('/test1', (_req, res) => { res.send(` @@ -71,13 +73,13 @@ const newApp = () => { * | | * +-----------------+ */ - app.get('/test2', (req, res) => { + app.get('/test2', (_req, res) => { res.send(`