Use latest lanthan
This commit is contained in:
parent
0fc2eea743
commit
4d36a203c0
25 changed files with 814 additions and 832 deletions
|
@ -1,8 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
|
const { By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -19,26 +20,24 @@ describe("navigate test", () => {
|
||||||
|
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
http.close();
|
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');
|
await body.sendKeys('j');
|
||||||
|
|
||||||
// not works
|
// not works
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageYOffset, 0);
|
assert.equal(pageYOffset, 0);
|
||||||
|
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/ab`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/ab`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('j');
|
await body.sendKeys('j');
|
||||||
|
|
||||||
// works
|
// works
|
||||||
pageYOffset = await session.executeScript(() => window.pageYOffset);
|
pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageYOffset, 64);
|
assert.equal(pageYOffset, 64);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const clipboard = require('./lib/clipboard');
|
const clipboard = require('./lib/clipboard');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -20,18 +19,19 @@ describe("navigate test", () => {
|
||||||
|
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
});
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
session = firefox.session;
|
.build();
|
||||||
browser = firefox.browser;
|
webdriver = lanthan.getWebDriver();
|
||||||
|
browser = lanthan.getWebExtBrowser();
|
||||||
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
settings,
|
settings,
|
||||||
|
@ -39,8 +39,8 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
http.close();
|
http.close();
|
||||||
});
|
});
|
||||||
|
@ -53,8 +53,8 @@ describe("navigate test", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should copy current URL by y', async () => {
|
it('should copy current URL by y', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/#should_copy_url`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/#should_copy_url`);
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await body.sendKeys('y');
|
await body.sendKeys('y');
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -64,8 +64,8 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open an URL from clipboard by p', async () => {
|
it('should open an URL from clipboard by p', 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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await clipboard.write(`http://127.0.0.1:${port}/#open_from_clipboard`);
|
await clipboard.write(`http://127.0.0.1:${port}/#open_from_clipboard`);
|
||||||
await body.sendKeys('p');
|
await body.sendKeys('p');
|
||||||
|
@ -77,11 +77,11 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open an URL from clipboard to new tab by P', async () => {
|
it('should open an URL from clipboard to new tab by P', 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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await clipboard.write(`http://127.0.0.1:${port}/#open_to_new_tab`);
|
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() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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 () => {
|
it('should open search result with keywords in clipboard by p', 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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await clipboard.write(`an apple`);
|
await clipboard.write(`an apple`);
|
||||||
await body.sendKeys('p');
|
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 () => {
|
it('should open search result with keywords in clipboard to new tabby P', 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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await clipboard.write(`an apple`);
|
await clipboard.write(`an apple`);
|
||||||
await body.sendKeys(Key.Shift, 'p');
|
await body.sendKeys(Key.SHIFT, 'p');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -22,41 +21,39 @@ const newApp = () => {
|
||||||
describe('addbookmark command test', () => {
|
describe('addbookmark command test', () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('addbookmark how to be happy', Key.Enter);
|
await input.sendKeys('addbookmark how to be happy', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
var bookmarks = await browser.bookmarks.search({ title: 'how to be happy' });
|
var bookmarks = await browser.bookmarks.search({ title: 'how to be happy' });
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -23,27 +22,24 @@ const newApp = () => {
|
||||||
describe('bdelete/bdeletes command test', () => {
|
describe('bdelete/bdeletes command test', () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
lanthan = await Builder
|
||||||
firefox = await lanthan.firefox({
|
.forBrowser('firefox')
|
||||||
spy: path.join(__dirname, '..'),
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builderf: (builder) => {
|
.build();
|
||||||
builder.addFile('build/settings.js');
|
webdriver = lanthan.getWebDriver();
|
||||||
},
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
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 browser.tabs.create({ url: `http://127.0.0.1:${port}/site5` })
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let handles = await session.getWindowHandles();
|
let handles = await webdriver.getAllWindowHandles();
|
||||||
assert.equal(handles.length, 5);
|
assert.equal(handles.length, 5);
|
||||||
await session.switchToWindow(handles[2]);
|
await webdriver.switchTo().window(handles[2]);
|
||||||
await session.findElementByCSS('iframe');
|
await webdriver.findElement(By.css('iframe'));
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete an unpinned tab by bdelete command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('bdelete site5', Key.Enter);
|
await input.sendKeys('bdelete site5', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('bdelete site1', Key.Enter);
|
await input.sendKeys('bdelete site1', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('bdelete xyz', Key.Enter);
|
await input.sendKeys('bdelete xyz', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
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();
|
let text = await p.getText();
|
||||||
assert.equal(text, 'No matching buffer for xyz');
|
assert.equal(text, 'No matching buffer for xyz');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show an error when more than one tabs are matched by bdelete command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('bdelete site', Key.Enter);
|
await input.sendKeys('bdelete site', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
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();
|
let text = await p.getText();
|
||||||
assert.equal(text, 'More than one match for site');
|
assert.equal(text, 'More than one match for site');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete an unpinned tab by bdelete! command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('bdelete! site5', Key.Enter);
|
await input.sendKeys('bdelete! site5', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('bdelete! site1', Key.Enter);
|
await input.sendKeys('bdelete! site1', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
@ -170,12 +166,12 @@ describe('bdelete/bdeletes command test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete unpinned tabs by bdeletes command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('bdeletes site', Key.Enter);
|
await input.sendKeys('bdeletes site', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('bdeletes! site', Key.Enter);
|
await input.sendKeys('bdeletes! site', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -23,27 +22,24 @@ const newApp = () => {
|
||||||
describe('buffer command test', () => {
|
describe('buffer command test', () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
lanthan = await Builder
|
||||||
firefox = await lanthan.firefox({
|
.forBrowser('firefox')
|
||||||
spy: path.join(__dirname, '..'),
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builderf: (builder) => {
|
.build();
|
||||||
builder.addFile('build/settings.js');
|
webdriver = lanthan.getWebDriver();
|
||||||
},
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,22 +54,22 @@ describe('buffer command test', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let handles = await session.getWindowHandles();
|
let handles = await webdriver.getAllWindowHandles();
|
||||||
assert.equal(handles.length, 5);
|
assert.equal(handles.length, 5);
|
||||||
await session.switchToWindow(handles[2]);
|
await webdriver.switchTo().window(handles[2]);
|
||||||
await session.findElementByCSS('iframe');
|
await webdriver.findElement(By.css('iframe'));
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do nothing by buffer command with no parameters', async() => {
|
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 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'));
|
||||||
await input.sendKeys('buffer', Key.Enter);
|
await input.sendKeys('buffer', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('buffer', Key.Enter);
|
await input.sendKeys('buffer', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('buffer 0', Key.Enter);
|
await input.sendKeys('buffer 0', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
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();
|
let text = await p.getText();
|
||||||
assert.equal(text, 'tab 0 does not exist');
|
assert.equal(text, 'tab 0 does not exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
await session.switchToParentFrame();
|
await webdriver.switchTo().parentFrame();
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
input = await session.findElementByCSS('input');
|
input = await webdriver.findElement(By.css('input'));
|
||||||
await input.sendKeys('buffer 9', Key.Enter);
|
await input.sendKeys('buffer 9', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
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();
|
let text = await p.getText();
|
||||||
assert.equal(text, 'tab 9 does not exist');
|
assert.equal(text, 'tab 9 does not exist');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should select a tab by buffer command with a title', async() => {
|
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 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'));
|
||||||
await input.sendKeys('buffer my_site1', Key.Enter);
|
await input.sendKeys('buffer my_site1', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
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() => {
|
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 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'));
|
||||||
await input.sendKeys('buffer /site1', Key.Enter);
|
await input.sendKeys('buffer /site1', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
let tabs = await browser.tabs.query({ active: true });
|
||||||
|
@ -153,15 +149,15 @@ describe('buffer command test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should select tabs rotately', async() => {
|
it('should select tabs rotately', async() => {
|
||||||
let handles = await session.getWindowHandles();
|
let handles = await webdriver.getAllWindowHandles();
|
||||||
await session.switchToWindow(handles[4]);
|
await webdriver.switchTo().window(handles[4]);
|
||||||
|
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
await input.sendKeys('buffer site', Key.Enter);
|
await input.sendKeys('buffer site', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
let tabs = await browser.tabs.query({ active: true });
|
||||||
|
@ -170,12 +166,12 @@ describe('buffer command test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do nothing by ":buffer %"', async() => {
|
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 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'));
|
||||||
await input.sendKeys('buffer %', Key.Enter);
|
await input.sendKeys('buffer %', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
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() => {
|
it('should selects last selected tab by ":buffer #"', async() => {
|
||||||
let handles = await session.getWindowHandles();
|
let handles = await webdriver.getAllWindowHandles();
|
||||||
await session.switchToWindow(handles[1]);
|
await webdriver.switchTo().window(handles[1]);
|
||||||
|
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
await input.sendKeys('buffer #', Key.Enter);
|
await input.sendKeys('buffer #', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
let tabs = await browser.tabs.query({ active: true });
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
|
|
||||||
|
@ -30,20 +29,18 @@ const newApp = () => {
|
||||||
describe("open command test", () => {
|
describe("open command test", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
|
@ -53,22 +50,22 @@ describe("open command test", () => {
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should open default search for keywords by open command ', async() => {
|
it('should open default search for keywords by open command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('open an apple', Key.Enter);
|
input.sendKeys('open an apple', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true });
|
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() => {
|
it('should open certain search page for keywords by open command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('open yahoo an apple', Key.Enter);
|
input.sendKeys('open yahoo an apple', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true })
|
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() => {
|
it('should open default engine with empty keywords by open command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('open', Key.Enter);
|
input.sendKeys('open', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true })
|
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() => {
|
it('should open certain search page for empty keywords by open command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('open yahoo', Key.Enter);
|
input.sendKeys('open yahoo', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true })
|
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() => {
|
it('should open a site with domain by open command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('open i-beam.org', Key.Enter);
|
input.sendKeys('open i-beam.org', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true })
|
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() => {
|
it('should open a site with URL by open command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('open https://i-beam.org', Key.Enter);
|
input.sendKeys('open https://i-beam.org', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({ active: true })
|
let tabs = await browser.tabs.query({ active: true })
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -23,27 +22,24 @@ const newApp = () => {
|
||||||
describe('quit/quitall command test', () => {
|
describe('quit/quitall command test', () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
lanthan = await Builder
|
||||||
firefox = await lanthan.firefox({
|
.forBrowser('firefox')
|
||||||
spy: path.join(__dirname, '..'),
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builderf: (builder) => {
|
.build();
|
||||||
builder.addFile('build/settings.js');
|
webdriver = lanthan.getWebDriver();
|
||||||
},
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,22 +54,22 @@ describe('quit/quitall command test', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let handles = await session.getWindowHandles();
|
let handles = await webdriver.getAllWindowHandles();
|
||||||
assert.equal(handles.length, 5);
|
assert.equal(handles.length, 5);
|
||||||
await session.switchToWindow(handles[2]);
|
await webdriver.switchTo().window(handles[2]);
|
||||||
await session.findElementByCSS('iframe');
|
await webdriver.findElement(By.css('iframe'));
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should current tab by q command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('q', Key.Enter);
|
await input.sendKeys('q', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
@ -82,12 +78,12 @@ describe('quit/quitall command test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should current tab by quit command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('quit', Key.Enter);
|
await input.sendKeys('quit', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
@ -96,12 +92,12 @@ describe('quit/quitall command test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should current tab by qa command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('qa', Key.Enter);
|
await input.sendKeys('qa', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
@ -110,12 +106,12 @@ describe('quit/quitall command test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should current tab by quitall command', async() => {
|
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 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'));
|
||||||
await input.sendKeys('quitall', Key.Enter);
|
await input.sendKeys('quitall', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
|
|
||||||
|
@ -30,22 +29,20 @@ const newApp = () => {
|
||||||
describe("tabopen command test", () => {
|
describe("tabopen command test", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
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({
|
await browser.storage.local.set({
|
||||||
settings,
|
settings,
|
||||||
});
|
});
|
||||||
|
@ -53,8 +50,8 @@ describe("tabopen command test", () => {
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -64,16 +61,16 @@ describe("tabopen command test", () => {
|
||||||
await browser.tabs.remove(tab.id);
|
await browser.tabs.remove(tab.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should open default search for keywords by tabopen command ', async() => {
|
it('should open default search for keywords by tabopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('tabopen an apple', Key.Enter);
|
input.sendKeys('tabopen an apple', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
it('should open certain search page for keywords by tabopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('tabopen yahoo an apple', Key.Enter);
|
input.sendKeys('tabopen yahoo an apple', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
it('should open default engine with empty keywords by tabopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('tabopen', Key.Enter);
|
input.sendKeys('tabopen', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
it('should open certain search page for empty keywords by tabopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('tabopen yahoo', Key.Enter);
|
input.sendKeys('tabopen yahoo', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
it('should open a site with domain by tabopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('tabopen i-beam.org', Key.Enter);
|
input.sendKeys('tabopen i-beam.org', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
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() => {
|
it('should open a site with URL by tabopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('tabopen https://i-beam.org', Key.Enter);
|
input.sendKeys('tabopen https://i-beam.org', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
|
|
||||||
|
@ -30,22 +29,19 @@ const newApp = () => {
|
||||||
describe("winopen command test", () => {
|
describe("winopen command test", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
lanthan = await Builder
|
||||||
firefox = await lanthan.firefox({
|
.forBrowser('firefox')
|
||||||
spy: path.join(__dirname, '..'),
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builderf: (builder) => {
|
.build();
|
||||||
builder.addFile('build/settings.js');
|
webdriver = lanthan.getWebDriver();
|
||||||
},
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
settings,
|
settings,
|
||||||
});
|
});
|
||||||
|
@ -53,8 +49,8 @@ describe("winopen command test", () => {
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -64,16 +60,16 @@ describe("winopen command test", () => {
|
||||||
await browser.windows.remove(win.id);
|
await browser.windows.remove(win.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should open default search for keywords by winopen command ', async() => {
|
it('should open default search for keywords by winopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('winopen an apple', Key.Enter);
|
input.sendKeys('winopen an apple', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let wins = await browser.windows.getAll();
|
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() => {
|
it('should open certain search page for keywords by winopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('winopen yahoo an apple', Key.Enter);
|
input.sendKeys('winopen yahoo an apple', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let wins = await browser.windows.getAll();
|
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() => {
|
it('should open default engine with empty keywords by winopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('winopen', Key.Enter);
|
input.sendKeys('winopen', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let wins = await browser.windows.getAll();
|
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() => {
|
it('should open certain search page for empty keywords by winopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('winopen yahoo', Key.Enter);
|
input.sendKeys('winopen yahoo', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let wins = await browser.windows.getAll();
|
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() => {
|
it('should open a site with domain by winopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('winopen i-beam.org', Key.Enter);
|
input.sendKeys('winopen i-beam.org', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let wins = await browser.windows.getAll();
|
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() => {
|
it('should open a site with URL by winopen command ', async() => {
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys('winopen https://i-beam.org', Key.Enter);
|
input.sendKeys('winopen https://i-beam.org', Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let wins = await browser.windows.getAll();
|
let wins = await browser.windows.getAll();
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
|
const { By, Key } = require('selenium-webdriver');
|
||||||
const Console = require('./lib/Console');
|
const Console = require('./lib/Console');
|
||||||
|
|
||||||
const Key = lanthan.Key;
|
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
|
@ -22,20 +21,18 @@ const newApp = () => {
|
||||||
describe("general completion test", () => {
|
describe("general completion test", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
|
@ -45,21 +42,21 @@ describe("general completion test", () => {
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should all commands on empty line', async() => {
|
it('should all commands on empty line', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let items = await c.getCompletions();
|
let items = await c.getCompletions();
|
||||||
|
@ -74,8 +71,8 @@ describe("general completion test", () => {
|
||||||
it('should only commands filtered by prefix', async() => {
|
it('should only commands filtered by prefix', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('b');
|
await c.sendKeys('b');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -91,8 +88,8 @@ describe("general completion test", () => {
|
||||||
it('selects completion items by <Tab>/<S-Tab> keys', async() => {
|
it('selects completion items by <Tab>/<S-Tab> keys', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('b');
|
await c.sendKeys('b');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -100,7 +97,7 @@ describe("general completion test", () => {
|
||||||
assert.equal(items.length, 4);
|
assert.equal(items.length, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
await c.sendKeys(Key.Tab);
|
await c.sendKeys(Key.TAB);
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let items = await c.getCompletions();
|
let items = await c.getCompletions();
|
||||||
assert(items[1].highlight)
|
assert(items[1].highlight)
|
||||||
|
@ -109,7 +106,7 @@ describe("general completion test", () => {
|
||||||
assert.equal(v, 'buffer');
|
assert.equal(v, 'buffer');
|
||||||
});
|
});
|
||||||
|
|
||||||
await c.sendKeys(Key.Tab, Key.Tab);
|
await c.sendKeys(Key.TAB, Key.TAB);
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let items = await c.getCompletions();
|
let items = await c.getCompletions();
|
||||||
assert(items[3].highlight)
|
assert(items[3].highlight)
|
||||||
|
@ -118,13 +115,13 @@ describe("general completion test", () => {
|
||||||
assert.equal(v, 'bdeletes');
|
assert.equal(v, 'bdeletes');
|
||||||
});
|
});
|
||||||
|
|
||||||
await c.sendKeys(Key.Tab);
|
await c.sendKeys(Key.TAB);
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let v = await c.currentValue();
|
let v = await c.currentValue();
|
||||||
assert.equal(v, 'b');
|
assert.equal(v, 'b');
|
||||||
});
|
});
|
||||||
|
|
||||||
await c.sendKeys(Key.Shift, Key.Tab);
|
await c.sendKeys(Key.SHIFT, Key.TAB);
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let items = await c.getCompletions();
|
let items = await c.getCompletions();
|
||||||
assert(items[3].highlight)
|
assert(items[3].highlight)
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
const Console = require('./lib/Console');
|
const Console = require('./lib/Console');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By, Key } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
|
|
||||||
|
@ -26,20 +25,18 @@ const newApp = () => {
|
||||||
describe("completion on buffer/bdelete/bdeletes", () => {
|
describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
|
@ -49,8 +46,8 @@ describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -67,12 +64,12 @@ describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let handles = await session.getWindowHandles();
|
let handles = await webdriver.getAllWindowHandles();
|
||||||
assert.equal(handles.length, 5);
|
assert.equal(handles.length, 5);
|
||||||
await session.switchToWindow(handles[2]);
|
await webdriver.switchTo().window(handles[2]);
|
||||||
await session.findElementByCSS('iframe');
|
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));
|
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() => {
|
it('should all tabs by "buffer" command with empty params', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('buffer ');
|
await c.sendKeys('buffer ');
|
||||||
|
|
||||||
await eventually(async() => {
|
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() => {
|
it('should filter items with URLs by keywords on "buffer" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('buffer title_site2');
|
await c.sendKeys('buffer title_site2');
|
||||||
|
|
||||||
await eventually(async() => {
|
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() => {
|
it('should filter items with titles by keywords on "buffer" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('buffer /site2');
|
await c.sendKeys('buffer /site2');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -132,8 +129,8 @@ describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
it('should show one item by number on "buffer" command', async() => {
|
it('should show one item by number on "buffer" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('buffer 2');
|
await c.sendKeys('buffer 2');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -147,8 +144,8 @@ describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
it('should show unpinned tabs "bdelete" command', async() => {
|
it('should show unpinned tabs "bdelete" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('bdelete site');
|
await c.sendKeys('bdelete site');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -163,8 +160,8 @@ describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
it('should show unpinned tabs "bdeletes" command', async() => {
|
it('should show unpinned tabs "bdeletes" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('bdelete site');
|
await c.sendKeys('bdelete site');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -179,8 +176,8 @@ describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
it('should show both pinned and unpinned tabs "bdelete!" command', async() => {
|
it('should show both pinned and unpinned tabs "bdelete!" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('bdelete! site');
|
await c.sendKeys('bdelete! site');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -197,8 +194,8 @@ describe("completion on buffer/bdelete/bdeletes", () => {
|
||||||
it('should show both pinned and unpinned tabs "bdeletes!" command', async() => {
|
it('should show both pinned and unpinned tabs "bdeletes!" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('bdeletes! site');
|
await c.sendKeys('bdeletes! site');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
|
|
@ -4,10 +4,10 @@ const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
|
const { By, Key } = require('selenium-webdriver');
|
||||||
const Console = require('./lib/Console');
|
const Console = require('./lib/Console');
|
||||||
|
|
||||||
const Key = lanthan.Key;
|
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
|
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -23,20 +23,18 @@ const newApp = () => {
|
||||||
describe("completion on open/tabopen/winopen commands", () => {
|
describe("completion on open/tabopen/winopen commands", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
|
@ -44,26 +42,26 @@ describe("completion on open/tabopen/winopen commands", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add item into hitories
|
// Add item into hitories
|
||||||
await session.navigateTo(`https://i-beam.org/404`);
|
await webdriver.navigate().to(`https://i-beam.org/404`);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
http.close();
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show completions from search engines, bookmarks, and histories by "open" command', async() => {
|
it('should show completions from search engines, bookmarks, and histories by "open" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('open ');
|
await c.sendKeys('open ');
|
||||||
|
|
||||||
await eventually(async() => {
|
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() => {
|
it('should filter items with URLs by keywords on "open" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('open https://');
|
await c.sendKeys('open https://');
|
||||||
|
|
||||||
await eventually(async() => {
|
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() => {
|
it('should filter items with titles by keywords on "open" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('open getting');
|
await c.sendKeys('open getting');
|
||||||
|
|
||||||
await eventually(async() => {
|
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() => {
|
it('should filter items with titles by keywords on "tabopen" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('tabopen https://');
|
await c.sendKeys('tabopen https://');
|
||||||
|
|
||||||
await eventually(async() => {
|
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() => {
|
it('should filter items with titles by keywords on "winopen" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('winopen https://');
|
await c.sendKeys('winopen https://');
|
||||||
|
|
||||||
await eventually(async() => {
|
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() => {
|
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) => {
|
const execCommand = async(line) => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
await c.sendKeys(line, Key.Enter);
|
await c.sendKeys(line, Key.ENTER);
|
||||||
await session.switchToParentFrame();
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
await webdriver.switchTo().parentFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeCommand = async(...keys) => {
|
const typeCommand = async(...keys) => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
await c.sendKeys(...keys);
|
await c.sendKeys(...keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancel = async() => {
|
const cancel = async() => {
|
||||||
await c.sendKeys(Key.Escape);
|
await c.sendKeys(Key.ESCAPE);
|
||||||
await session.switchToParentFrame();
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
await webdriver.switchTo().parentFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
await execCommand('set complete=sbh');
|
await execCommand('set complete=sbh');
|
||||||
|
@ -189,17 +189,18 @@ describe("completion on open/tabopen/winopen commands", () => {
|
||||||
};
|
};
|
||||||
await browser.storage.local.set({ settings, });
|
await browser.storage.local.set({ settings, });
|
||||||
|
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
|
|
||||||
const typeCommand = async(...keys) => {
|
const typeCommand = async(...keys) => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
await c.sendKeys(...keys);
|
await c.sendKeys(...keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancel = async() => {
|
const cancel = async() => {
|
||||||
await c.sendKeys(Key.Escape);
|
await c.sendKeys(Key.ESCAPE);
|
||||||
await session.switchToParentFrame();
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
await webdriver.switchTo().parentFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
await browser.storage.local.set({ settings: {
|
await browser.storage.local.set({ settings: {
|
||||||
|
|
|
@ -5,25 +5,23 @@ const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const settings = require('./settings');
|
const settings = require('./settings');
|
||||||
const Console = require('./lib/Console');
|
const Console = require('./lib/Console');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By } = require('selenium-webdriver');
|
||||||
|
|
||||||
describe("completion on set commands", () => {
|
describe("completion on set commands", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let session;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
|
|
||||||
await browser.storage.local.set({
|
await browser.storage.local.set({
|
||||||
settings,
|
settings,
|
||||||
|
@ -31,21 +29,21 @@ describe("completion on set commands", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo(`about:blank`);
|
await webdriver.navigate().to(`about:blank`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show all property names by "set" command with empty params', async() => {
|
it('should show all property names by "set" command with empty params', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('set ');
|
await c.sendKeys('set ');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -62,8 +60,8 @@ describe("completion on set commands", () => {
|
||||||
it('should show filtered property names by "set" command', async() => {
|
it('should show filtered property names by "set" command', async() => {
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
await c.sendKeys('set no');
|
await c.sendKeys('set no');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { Key, By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -23,102 +22,106 @@ const newApp = () => {
|
||||||
describe("console test", () => {
|
describe("console test", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let tab;
|
let tab;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox();
|
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
lanthan = await Builder
|
||||||
|
.forBrowser('firefox')
|
||||||
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
|
.build();
|
||||||
|
webdriver = lanthan.getWebDriver();
|
||||||
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
if (lanthan) {
|
||||||
if (firefox) {
|
await lanthan.quit();
|
||||||
await firefox.close();
|
}
|
||||||
|
if (http) {
|
||||||
|
http.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with :', async() => {
|
it('open console with :', async() => {
|
||||||
await body.sendKeys(':');
|
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);
|
assert.equal(await input.isDisplayed(), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with open command by o', async() => {
|
it('open console with open command by o', async() => {
|
||||||
await body.sendKeys('o');
|
await body.sendKeys('o');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, 'open ');
|
assert.equal(value, 'open ');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with open command and current URL by O', async() => {
|
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);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, `open http://127.0.0.1:${port}/`);
|
assert.equal(value, `open http://127.0.0.1:${port}/`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with tabopen command by t', async() => {
|
it('open console with tabopen command by t', async() => {
|
||||||
await body.sendKeys('t');
|
await body.sendKeys('t');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, 'tabopen ');
|
assert.equal(value, 'tabopen ');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with tabopen command and current URL by T', async() => {
|
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);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, `tabopen http://127.0.0.1:${port}/`);
|
assert.equal(value, `tabopen http://127.0.0.1:${port}/`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with winopen command by w', async() => {
|
it('open console with winopen command by w', async() => {
|
||||||
await body.sendKeys('w');
|
await body.sendKeys('w');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, 'winopen ');
|
assert.equal(value, 'winopen ');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with winopen command and current URL by W', async() => {
|
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);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, `winopen http://127.0.0.1:${port}/`);
|
assert.equal(value, `winopen http://127.0.0.1:${port}/`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with buffer command by b', async() => {
|
it('open console with buffer command by b', async() => {
|
||||||
await body.sendKeys('b');
|
await body.sendKeys('b');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, `buffer `);
|
assert.equal(value, `buffer `);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('open console with addbookmark command with title by a', async() => {
|
it('open console with addbookmark command with title by a', async() => {
|
||||||
await body.sendKeys('a');
|
await body.sendKeys('a');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
let value = await session.executeScript(() => document.querySelector('input').value);
|
let value = await webdriver.executeScript(() => document.querySelector('input').value);
|
||||||
assert.equal(value, `addbookmark Hello, world!`);
|
assert.equal(value, `addbookmark Hello, world!`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { Key, By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -119,9 +118,9 @@ const newApp = () => {
|
||||||
return app;
|
return app;
|
||||||
};
|
};
|
||||||
|
|
||||||
const waitForHints = async(session) => {
|
const waitForHints = async(webdriver) => {
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let hints = await session.findElementsByCSS('.vimvixen-hint');
|
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
|
||||||
assert(hints.length > 0);
|
assert(hints.length > 0);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -130,24 +129,27 @@ describe('follow test', () => {
|
||||||
|
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
lanthan = await Builder
|
||||||
firefox = await lanthan.firefox();
|
.forBrowser('firefox')
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
session = firefox.session;
|
.build();
|
||||||
browser = firefox.browser;
|
webdriver = lanthan.getWebDriver();
|
||||||
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
|
}
|
||||||
|
if (http) {
|
||||||
|
http.close();
|
||||||
}
|
}
|
||||||
http.close();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async() => {
|
afterEach(async() => {
|
||||||
|
@ -158,45 +160,49 @@ describe('follow test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should focus an input by f', async () => {
|
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 body.sendKeys('f');
|
||||||
await waitForHints(session);
|
await waitForHints(webdriver);
|
||||||
await body.sendKeys('a');
|
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');
|
assert.equal(tagName.toLowerCase(), 'input');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open a link by f', async () => {
|
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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('f', 'a');
|
await body.sendKeys('f');
|
||||||
|
await waitForHints(webdriver);
|
||||||
|
await body.sendKeys('a');
|
||||||
|
|
||||||
let hash = await session.executeScript('location.pathname');
|
await eventually(async() => {
|
||||||
await body.sendKeys(hash, '/hello');
|
let hash = await webdriver.executeScript('return location.pathname');
|
||||||
|
assert.equal(hash, '/hello');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should focus an input by F', async () => {
|
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(Key.Shift, 'f');
|
await body.sendKeys(Key.SHIFT, 'f');
|
||||||
await waitForHints(session);
|
await waitForHints(webdriver);
|
||||||
await body.sendKeys('a');
|
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');
|
assert.equal(tagName.toLowerCase(), 'input');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open a link to new tab by F', async () => {
|
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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'f');
|
await body.sendKeys(Key.SHIFT, 'f');
|
||||||
await waitForHints(session);
|
await waitForHints(webdriver);
|
||||||
await body.sendKeys('a');
|
await body.sendKeys('a');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -208,49 +214,49 @@ describe('follow test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show hints of links in area', async () => {
|
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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'f');
|
await body.sendKeys(Key.SHIFT, 'f');
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let hints = await session.findElementsByCSS('.vimvixen-hint');
|
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
|
||||||
assert.equal(hints.length, 3);
|
assert.equal(hints.length, 3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should shows hints only in viewport', async () => {
|
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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'f');
|
await body.sendKeys(Key.SHIFT, 'f');
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let hints = await session.findElementsByCSS('.vimvixen-hint');
|
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
|
||||||
assert.equal(hints.length, 1);
|
assert.equal(hints.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should shows hints only in window of the frame', async () => {
|
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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'f');
|
await body.sendKeys(Key.SHIFT, 'f');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let hints = await session.findElementsByCSS('.vimvixen-hint');
|
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
|
||||||
assert.equal(hints.length, 1);
|
assert.equal(hints.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should shows hints only in the frame', async () => {
|
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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'f');
|
await body.sendKeys(Key.SHIFT, 'f');
|
||||||
|
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let hints = await session.findElementsByCSS('.vimvixen-hint');
|
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
|
||||||
assert.equal(hints.length, 1);
|
assert.equal(hints.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
const Console = require('./lib/Console');
|
const Console = require('./lib/Console');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { Key, By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -25,9 +24,9 @@ const newApp = () => {
|
||||||
return app;
|
return app;
|
||||||
};
|
};
|
||||||
|
|
||||||
const waitForHints = async(session) => {
|
const waitForHints = async(webdriver) => {
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let hints = await session.findElementsByCSS('.vimvixen-hint');
|
let hints = await webdriver.findElements(By.css(`.vimvixen-hint`));
|
||||||
assert(hints.length > 0);
|
assert(hints.length > 0);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -36,22 +35,20 @@ describe('follow properties test', () => {
|
||||||
|
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
},
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
|
|
||||||
await browser.storage.local.set({ settings: {
|
await browser.storage.local.set({ settings: {
|
||||||
source: 'json',
|
source: 'json',
|
||||||
|
@ -74,15 +71,15 @@ describe('follow properties test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
http.close();
|
http.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async() => {
|
afterEach(async() => {
|
||||||
|
@ -95,7 +92,7 @@ describe('follow properties test', () => {
|
||||||
it('should show hints with hintchars by settings', async () => {
|
it('should show hints with hintchars by settings', async () => {
|
||||||
await body.sendKeys('f');
|
await body.sendKeys('f');
|
||||||
await eventually(async() => {
|
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(hints.length, 5);
|
||||||
|
|
||||||
assert.equal(await hints[0].getText(), 'J');
|
assert.equal(await hints[0].getText(), 'J');
|
||||||
|
@ -108,20 +105,20 @@ describe('follow properties test', () => {
|
||||||
await body.sendKeys('j');
|
await body.sendKeys('j');
|
||||||
|
|
||||||
await eventually(async() => {
|
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[0].getCssValue('display'), 'block');
|
||||||
assert.equal(await hints[1].getStyle('display'), 'none');
|
assert.equal(await hints[1].getCssValue('display'), 'none');
|
||||||
assert.equal(await hints[2].getStyle('display'), 'block');
|
assert.equal(await hints[2].getCssValue('display'), 'block');
|
||||||
assert.equal(await hints[3].getStyle('display'), 'block');
|
assert.equal(await hints[3].getCssValue('display'), 'block');
|
||||||
assert.equal(await hints[4].getStyle('display'), 'none');
|
assert.equal(await hints[4].getCssValue('display'), 'none');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open tab in background by background:false', async () => {
|
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() => {
|
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(hints.length, 5);
|
||||||
});
|
});
|
||||||
await body.sendKeys('jj');
|
await body.sendKeys('jj');
|
||||||
|
@ -134,9 +131,9 @@ describe('follow properties test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open tab in background by background:true', async () => {
|
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() => {
|
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(hints.length, 5);
|
||||||
});
|
});
|
||||||
await body.sendKeys('jj');
|
await body.sendKeys('jj');
|
||||||
|
@ -149,16 +146,17 @@ describe('follow properties test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show hints with hintchars by settings', async () => {
|
it('should show hints with hintchars by settings', async () => {
|
||||||
let c = new Console(session);
|
let c = new Console(webdriver);
|
||||||
|
|
||||||
await body.sendKeys(':');
|
await body.sendKeys(':');
|
||||||
await session.switchToFrame(0);
|
await webdriver.switchTo().frame(0);
|
||||||
await c.sendKeys('set hintchars=abc', Key.Enter);
|
await c.sendKeys('set hintchars=abc', Key.ENTER);
|
||||||
await session.switchToParentFrame();
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
await webdriver.switchTo().parentFrame();
|
||||||
|
|
||||||
await body.sendKeys('f');
|
await body.sendKeys('f');
|
||||||
await eventually(async() => {
|
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(hints.length, 5);
|
||||||
|
|
||||||
assert.equal(await hints[0].getText(), 'A');
|
assert.equal(await hints[0].getText(), 'A');
|
||||||
|
@ -170,13 +168,13 @@ describe('follow properties test', () => {
|
||||||
|
|
||||||
await body.sendKeys('a');
|
await body.sendKeys('a');
|
||||||
await eventually(async() => {
|
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[0].getCssValue('display'), 'block');
|
||||||
assert.equal(await hints[1].getStyle('display'), 'none');
|
assert.equal(await hints[1].getCssValue('display'), 'none');
|
||||||
assert.equal(await hints[2].getStyle('display'), 'none');
|
assert.equal(await hints[2].getCssValue('display'), 'none');
|
||||||
assert.equal(await hints[3].getStyle('display'), 'block');
|
assert.equal(await hints[3].getCssValue('display'), 'block');
|
||||||
assert.equal(await hints[4].getStyle('display'), 'block');
|
assert.equal(await hints[4].getCssValue('display'), 'block');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
|
const { By } = require('selenium-webdriver');
|
||||||
|
|
||||||
class Console {
|
class Console {
|
||||||
constructor(session) {
|
constructor(webdriver) {
|
||||||
this.session = session;
|
this.webdriver = webdriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendKeys(...keys) {
|
async sendKeys(...keys) {
|
||||||
let input = await this.session.findElementByCSS('input');
|
let input = await this.webdriver.findElement(By.css('input'));
|
||||||
input.sendKeys(...keys);
|
input.sendKeys(...keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
async currentValue() {
|
async currentValue() {
|
||||||
return await this.session.executeScript(() => {
|
return await this.webdriver.executeScript(() => {
|
||||||
let input = document.querySelector('input');
|
let input = document.querySelector('input');
|
||||||
return input.value;
|
return input.value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCompletions() {
|
async getCompletions() {
|
||||||
return await this.session.executeScript(() => {
|
return await this.webdriver.executeScript(() => {
|
||||||
let items = document.querySelectorAll('.vimvixen-console-completion > li');
|
let items = document.querySelectorAll('.vimvixen-console-completion > li');
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
throw new Error('completion items not found');
|
throw new Error('completion items not found');
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -21,61 +20,65 @@ describe("mark test", () => {
|
||||||
|
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox();
|
lanthan = await Builder
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
.forBrowser('firefox')
|
||||||
session = firefox.session;
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
browser = firefox.browser;
|
.build();
|
||||||
|
webdriver = lanthan.getWebDriver();
|
||||||
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
|
}
|
||||||
|
if (http) {
|
||||||
|
http.close();
|
||||||
}
|
}
|
||||||
http.close();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set a local mark and jump to it', async () => {
|
it('should set a local mark and jump to it', 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');
|
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 body.sendKeys('m', 'a');
|
||||||
await session.executeScript(() => window.scrollTo(500, 500));
|
await webdriver.executeScript(() => window.scrollTo(500, 500));
|
||||||
await body.sendKeys('\'', 'a');
|
await body.sendKeys('\'', 'a');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let pageXOffset = await session.executeScript(() => window.pageXOffset);
|
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageXOffset, 200);
|
assert.equal(pageXOffset, 200);
|
||||||
assert.equal(pageYOffset, 200);
|
assert.equal(pageYOffset, 200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set a global mark and jump to it', async () => {
|
it('should set a global mark and jump to it', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}#first`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}#first`);
|
||||||
let body = await session.findElementByCSS('body');
|
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 body.sendKeys('m', 'A');
|
||||||
await session.executeScript(() => window.scrollTo(500, 500));
|
await webdriver.executeScript(() => window.scrollTo(500, 500));
|
||||||
await body.sendKeys('\'', 'A');
|
await body.sendKeys('\'', 'A');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let pageXOffset = await session.executeScript(() => window.pageXOffset);
|
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageXOffset, 200);
|
assert.equal(pageXOffset, 200);
|
||||||
assert.equal(pageYOffset, 200);
|
assert.equal(pageYOffset, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
await browser.tabs.create({ url: `http://127.0.0.1:${port}#second` });
|
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 body.sendKeys('\'', 'A');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -83,17 +86,17 @@ describe("mark test", () => {
|
||||||
let url = new URL(tab.url);
|
let url = new URL(tab.url);
|
||||||
assert.equal(url.hash, '#first');
|
assert.equal(url.hash, '#first');
|
||||||
|
|
||||||
let pageXOffset = await session.executeScript(() => window.pageXOffset);
|
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageXOffset, 200);
|
assert.equal(pageXOffset, 200);
|
||||||
assert.equal(pageYOffset, 200);
|
assert.equal(pageYOffset, 200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('set a global mark and creates new tab from gone', async () => {
|
it('set a global mark and creates new tab from gone', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}#first`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}#first`);
|
||||||
await session.executeScript(() => window.scrollTo(500, 500));
|
await webdriver.executeScript(() => window.scrollTo(500, 500));
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('m', 'A');
|
await body.sendKeys('m', 'A');
|
||||||
|
|
||||||
let tab = (await browser.tabs.query({ active: true }))[0];
|
let tab = (await browser.tabs.query({ active: true }))[0];
|
||||||
|
@ -102,12 +105,12 @@ describe("mark test", () => {
|
||||||
|
|
||||||
let handles;
|
let handles;
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
handles = await session.getWindowHandles();
|
handles = await webdriver.getAllWindowHandles();
|
||||||
assert.equal(handles.length, 2);
|
assert.equal(handles.length, 2);
|
||||||
});
|
});
|
||||||
await session.switchToWindow(handles[0]);
|
await webdriver.switchTo().window(handles[0]);
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}#second`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}#second`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('\'', 'A');
|
await body.sendKeys('\'', 'A');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { Options: FirefoxOptions } = require('selenium-webdriver/firefox');
|
||||||
|
const { Key, By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -47,26 +47,26 @@ describe("navigate test", () => {
|
||||||
|
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
|
let opts = new FirefoxOptions()
|
||||||
|
.setPreference('browser.startup.homepage', `http://127.0.0.1:${port}#home`);
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
lanthan = await Builder
|
||||||
firefox = await lanthan.firefox({
|
.forBrowser('firefox')
|
||||||
prefs: {
|
.setOptions(opts)
|
||||||
'browser.startup.homepage': `http://127.0.0.1:${port}#home`,
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
}
|
.build();
|
||||||
});
|
webdriver = lanthan.getWebDriver();
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
browser = lanthan.getWebExtBrowser();
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
http.close();
|
http.close();
|
||||||
});
|
});
|
||||||
|
@ -79,8 +79,8 @@ describe("navigate test", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should go to parent path without hash by gu', async () => {
|
it('should go to parent path without hash by gu', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/a/b/c`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/a/b/c`);
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await body.sendKeys('g', 'u');
|
await body.sendKeys('g', 'u');
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove hash by gu', async () => {
|
it('should remove hash by gu', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/a/b/c#hash`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/a/b/c#hash`);
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await body.sendKeys('g', 'u');
|
await body.sendKeys('g', 'u');
|
||||||
|
|
||||||
|
@ -106,10 +106,10 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go to root path by gU', async () => {
|
it('should go to root path by gU', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/a/b/c#hash`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/a/b/c#hash`);
|
||||||
let body = await session.findElementByCSS('body');
|
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() => {
|
await eventually(async() => {
|
||||||
let tab = (await browser.tabs.query({}))[0];
|
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 () => {
|
it('should go back and forward in history by H and L', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/first`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/first`);
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/second`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/second`);
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
|
|
||||||
await body.sendKeys(Key.Shift, 'h');
|
await body.sendKeys(Key.SHIFT, 'h');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tab = (await browser.tabs.query({}))[0];
|
let tab = (await browser.tabs.query({}))[0];
|
||||||
|
@ -131,8 +131,8 @@ describe("navigate test", () => {
|
||||||
assert.equal(url.pathname, `/first`)
|
assert.equal(url.pathname, `/first`)
|
||||||
});
|
});
|
||||||
|
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'l');
|
await body.sendKeys(Key.SHIFT, 'l');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
tab = (await browser.tabs.query({}))[0];
|
tab = (await browser.tabs.query({}))[0];
|
||||||
|
@ -142,9 +142,9 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go previous and next page in <a> by [[ and ]]', async () => {
|
it('should go previous and next page in <a> 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 body.sendKeys('[', '[');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -155,8 +155,8 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go next page in <a> by ]]', async () => {
|
it('should go next page in <a> by ]]', 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 body.sendKeys(']', ']');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -167,9 +167,9 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go previous page in <link> by ]]', async () => {
|
it('should go previous page in <link> 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 body.sendKeys('[', '[');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -180,8 +180,8 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go next page by in <link> by [[', async () => {
|
it('should go next page by in <link> 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 body.sendKeys(']', ']');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -192,8 +192,8 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go to home page into current tab by gh', async () => {
|
it('should go to home page into current tab by gh', 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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('g', 'h');
|
await body.sendKeys('g', 'h');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -204,9 +204,9 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should go to home page into current tab by gH', async () => {
|
it('should go to home page into current tab by gH', 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');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('g', Key.Shift, 'H');
|
await body.sendKeys('g', Key.SHIFT, 'H');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
|
@ -218,8 +218,8 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reload current tab by r', async () => {
|
it('should reload current tab by r', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/reload`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/reload`);
|
||||||
await session.executeScript(() => window.scrollTo(500, 500));
|
await webdriver.executeScript(() => window.scrollTo(500, 500));
|
||||||
let before
|
let before
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tab = (await browser.tabs.query({}))[0];
|
let tab = (await browser.tabs.query({}))[0];
|
||||||
|
@ -227,7 +227,7 @@ describe("navigate test", () => {
|
||||||
assert(before > 0);
|
assert(before > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('r');
|
await body.sendKeys('r');
|
||||||
|
|
||||||
let after
|
let after
|
||||||
|
@ -238,14 +238,14 @@ describe("navigate test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageYOffset, 500);
|
assert.equal(pageYOffset, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reload current tab without cache by R', async () => {
|
it('should reload current tab without cache by R', async () => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}/reload`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}/reload`);
|
||||||
await session.executeScript(() => window.scrollTo(500, 500));
|
await webdriver.executeScript(() => window.scrollTo(500, 500));
|
||||||
let before
|
let before
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let tab = (await browser.tabs.query({}))[0];
|
let tab = (await browser.tabs.query({}))[0];
|
||||||
|
@ -253,8 +253,8 @@ describe("navigate test", () => {
|
||||||
assert(before > 0);
|
assert(before > 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'R');
|
await body.sendKeys(Key.SHIFT, 'R');
|
||||||
|
|
||||||
let after
|
let after
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -266,7 +266,7 @@ describe("navigate test", () => {
|
||||||
// assert that the page offset is reset to 0, and 'eventually' is timed-out.
|
// assert that the page offset is reset to 0, and 'eventually' is timed-out.
|
||||||
await assert.rejects(async () => {
|
await assert.rejects(async () => {
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageYOffset, 500);
|
assert.equal(pageYOffset, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
|
const { By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -18,31 +19,28 @@ const newApp = () => {
|
||||||
describe("options page", () => {
|
describe("options page", () => {
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let session;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
builder.addFile('build/settings.html');
|
webdriver = lanthan.getWebDriver();
|
||||||
},
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
|
}
|
||||||
|
if (http) {
|
||||||
|
http.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
http.close();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
|
@ -53,15 +51,15 @@ describe("options page", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateTextarea = async(value) => {
|
const updateTextarea = async(value) => {
|
||||||
let textarea = await session.findElementByCSS('textarea');
|
let textarea = await webdriver.findElement(By.css('textarea'));
|
||||||
await session.executeScript(`document.querySelector('textarea').value = '${value}'`)
|
await webdriver.executeScript(`document.querySelector('textarea').value = '${value}'`)
|
||||||
await textarea.sendKeys(' ');
|
await textarea.sendKeys(' ');
|
||||||
await session.executeScript(() => document.querySelector('textarea').blur());
|
await webdriver.executeScript(() => document.querySelector('textarea').blur());
|
||||||
}
|
}
|
||||||
|
|
||||||
it('saves current config on blur', async () => {
|
it('saves current config on blur', async () => {
|
||||||
let url = await browser.runtime.getURL("build/settings.html")
|
let url = await browser.runtime.getURL("build/settings.html")
|
||||||
await session.navigateTo(url);
|
await webdriver.navigate().to(url);
|
||||||
|
|
||||||
await updateTextarea(`{ "blacklist": [ "https://example.com" ] }`);
|
await updateTextarea(`{ "blacklist": [ "https://example.com" ] }`);
|
||||||
|
|
||||||
|
@ -75,7 +73,7 @@ describe("options page", () => {
|
||||||
assert.equal(settings.source, 'json')
|
assert.equal(settings.source, 'json')
|
||||||
assert.equal(settings.json, '{ "blacklist": [ "https://example.com" ] } ')
|
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();
|
let text = await error.getText();
|
||||||
assert.ok(text.startsWith('SyntaxError:'))
|
assert.ok(text.startsWith('SyntaxError:'))
|
||||||
});
|
});
|
||||||
|
@ -83,17 +81,17 @@ describe("options page", () => {
|
||||||
it('updates keymaps without reloading', async () => {
|
it('updates keymaps without reloading', async () => {
|
||||||
await browser.tabs.create({ url: `http://127.0.0.1:${port}`, active: false });
|
await browser.tabs.create({ url: `http://127.0.0.1:${port}`, active: false });
|
||||||
let url = await browser.runtime.getURL("build/settings.html")
|
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 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')
|
await body.sendKeys('zz')
|
||||||
|
|
||||||
let y = await session.executeScript(() => window.pageYOffset);
|
let y = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(y, 640);
|
assert.equal(y, 640);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
|
const { By } = require('selenium-webdriver');
|
||||||
|
|
||||||
describe("options form page", () => {
|
describe("options form page", () => {
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
firefox = await lanthan.firefox({
|
lanthan = await Builder
|
||||||
spy: path.join(__dirname, '..'),
|
.forBrowser('firefox')
|
||||||
builderf: (builder) => {
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
builder.addFile('build/settings.js');
|
.build();
|
||||||
builder.addFile('build/settings.html');
|
webdriver = lanthan.getWebDriver();
|
||||||
},
|
browser = lanthan.getWebExtBrowser();
|
||||||
});
|
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
|
||||||
session = firefox.session;
|
|
||||||
browser = firefox.browser;
|
|
||||||
|
|
||||||
let tabs = await browser.tabs.query({});
|
let tabs = await browser.tabs.query({});
|
||||||
for (let tab of tabs.slice(1)) {
|
for (let tab of tabs.slice(1)) {
|
||||||
|
@ -26,37 +23,37 @@ describe("options form page", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async() => {
|
afterEach(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const setBlacklistValue = async(nth, value) => {
|
const setBlacklistValue = async(nth, value) => {
|
||||||
let selector = '.form-blacklist-form .column-url';
|
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 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) => {
|
const setSearchEngineValue = async(nth, name, url) => {
|
||||||
let selector = '.form-search-form input.column-name';
|
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 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';
|
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 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 () => {
|
it('switch to form settings', async () => {
|
||||||
let url = await browser.runtime.getURL("build/settings.html")
|
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 useFormInput.click();
|
||||||
await session.acceptAlert();
|
await webdriver.switchTo().alert().accept();
|
||||||
|
|
||||||
let { settings } = await browser.storage.local.get('settings');
|
let { settings } = await browser.storage.local.get('settings');
|
||||||
assert.equal(settings.source, 'form')
|
assert.equal(settings.source, 'form')
|
||||||
|
@ -64,19 +61,19 @@ describe("options form page", () => {
|
||||||
|
|
||||||
it('add blacklist', async () => {
|
it('add blacklist', async () => {
|
||||||
let url = await browser.runtime.getURL("build/settings.html")
|
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 useFormInput.click();
|
||||||
await session.acceptAlert();
|
await webdriver.switchTo().alert().accept();
|
||||||
await session.executeScript(() => window.scrollBy(0, 1000));
|
await webdriver.executeScript(() => window.scrollBy(0, 1000));
|
||||||
|
|
||||||
// assert default
|
// assert default
|
||||||
let settings = (await browser.storage.local.get('settings')).settings;
|
let settings = (await browser.storage.local.get('settings')).settings;
|
||||||
assert.deepEqual(settings.form.blacklist, [])
|
assert.deepEqual(settings.form.blacklist, [])
|
||||||
|
|
||||||
// add blacklist items
|
// 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 addButton.click();
|
||||||
await setBlacklistValue(0, 'google.com')
|
await setBlacklistValue(0, 'google.com')
|
||||||
|
|
||||||
|
@ -90,7 +87,7 @@ describe("options form page", () => {
|
||||||
assert.deepEqual(settings.form.blacklist, ['google.com', 'yahoo.com'])
|
assert.deepEqual(settings.form.blacklist, ['google.com', 'yahoo.com'])
|
||||||
|
|
||||||
// delete first item
|
// 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()
|
await deleteButton.click()
|
||||||
|
|
||||||
settings = (await browser.storage.local.get('settings')).settings;
|
settings = (await browser.storage.local.get('settings')).settings;
|
||||||
|
@ -99,23 +96,23 @@ describe("options form page", () => {
|
||||||
|
|
||||||
it('add search engines', async () => {
|
it('add search engines', async () => {
|
||||||
let url = await browser.runtime.getURL("build/settings.html")
|
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 useFormInput.click();
|
||||||
await session.acceptAlert();
|
await webdriver.switchTo().alert().accept();
|
||||||
|
|
||||||
// assert default
|
// assert default
|
||||||
let settings = (await browser.storage.local.get('settings')).settings;
|
let settings = (await browser.storage.local.get('settings')).settings;
|
||||||
assert.deepEqual(settings.form.search.default, 'google');
|
assert.deepEqual(settings.form.search.default, 'google');
|
||||||
|
|
||||||
// change default
|
// 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();
|
await radio.click();
|
||||||
settings = (await browser.storage.local.get('settings')).settings;
|
settings = (await browser.storage.local.get('settings')).settings;
|
||||||
assert.deepEqual(settings.form.search.default, 'bing');
|
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 addButton.click();
|
||||||
await setSearchEngineValue(6, 'yippy', 'https://www.yippy.com/search?query={}');
|
await setSearchEngineValue(6, 'yippy', 'https://www.yippy.com/search?query={}');
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { Key, By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -20,44 +19,48 @@ describe("tab test", () => {
|
||||||
const url = `http://127.0.0.1:${port}/`;
|
const url = `http://127.0.0.1:${port}/`;
|
||||||
|
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver
|
||||||
let browser;
|
let browser;
|
||||||
let tabs;
|
let tabs;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox();
|
lanthan = await Builder
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
.forBrowser('firefox')
|
||||||
session = firefox.session;
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
browser = firefox.browser;
|
.build();
|
||||||
|
webdriver = lanthan.getWebDriver();
|
||||||
|
browser = lanthan.getWebExtBrowser();
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
await session.navigateTo(`${url}`);
|
await webdriver.navigate().to(`${url}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
if (http) {
|
||||||
if (firefox) {
|
http.close();
|
||||||
await firefox.close();
|
}
|
||||||
|
if (lanthan) {
|
||||||
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('repeats last operation', async () => {
|
it('repeats last operation', async () => {
|
||||||
let before = await browser.tabs.query({});
|
let before = await browser.tabs.query({});
|
||||||
|
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(':');
|
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'));
|
||||||
input.sendKeys(`tabopen ${url}newtab`, Key.Enter);
|
input.sendKeys(`tabopen ${url}newtab`, Key.ENTER);
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let current = await browser.tabs.query({ url: `*://*/newtab` });
|
let current = await browser.tabs.query({ url: `*://*/newtab` });
|
||||||
assert.equal(current.length, 1);
|
assert.equal(current.length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys('.');
|
await body.sendKeys('.');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -72,7 +75,7 @@ describe("tab test", () => {
|
||||||
}
|
}
|
||||||
let before = await browser.tabs.query({});
|
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 body.sendKeys('d');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -81,7 +84,7 @@ describe("tab test", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await browser.tabs.update(before[2].id, { active: true });
|
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 body.sendKeys('.');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { Key, By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -20,131 +19,135 @@ describe("scroll test", () => {
|
||||||
|
|
||||||
const port = 12321;
|
const port = 12321;
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
|
|
||||||
firefox = await lanthan.firefox();
|
lanthan = await Builder
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
.forBrowser('firefox')
|
||||||
session = firefox.session;
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
|
.build();
|
||||||
|
webdriver = lanthan.getWebDriver();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
if (lanthan) {
|
||||||
await firefox.close();
|
await lanthan.quit();
|
||||||
|
}
|
||||||
|
if (http) {
|
||||||
|
http.close();
|
||||||
}
|
}
|
||||||
http.close();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo(`http://127.0.0.1:${port}`);
|
await webdriver.navigate().to(`http://127.0.0.1:${port}`);
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('scrolls up by k', async () => {
|
it('scrolls up by k', async () => {
|
||||||
await body.sendKeys('j');
|
await body.sendKeys('j');
|
||||||
|
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageYOffset, 64);
|
assert.equal(pageYOffset, 64);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls down by j', async () => {
|
it('scrolls down by j', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 200));
|
await webdriver.executeScript(() => window.scrollTo(0, 200));
|
||||||
await body.sendKeys('k');
|
await body.sendKeys('k');
|
||||||
|
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageYOffset, 136);
|
assert.equal(pageYOffset, 136);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls left by h', async () => {
|
it('scrolls left by h', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(100, 100));
|
await webdriver.executeScript(() => window.scrollTo(100, 100));
|
||||||
await body.sendKeys('h');
|
await body.sendKeys('h');
|
||||||
|
|
||||||
let pageXOffset = await session.executeScript(() => window.pageXOffset);
|
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
|
||||||
assert.equal(pageXOffset, 36);
|
assert.equal(pageXOffset, 36);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls left by l', async () => {
|
it('scrolls left by l', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(100, 100));
|
await webdriver.executeScript(() => window.scrollTo(100, 100));
|
||||||
await body.sendKeys('l');
|
await body.sendKeys('l');
|
||||||
|
|
||||||
let pageXOffset = await session.executeScript(() => window.pageXOffset);
|
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
|
||||||
assert.equal(pageXOffset, 164);
|
assert.equal(pageXOffset, 164);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls top by gg', async () => {
|
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');
|
await body.sendKeys('g', 'g');
|
||||||
|
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert.equal(pageYOffset, 0);
|
assert.equal(pageYOffset, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls bottom by G', async () => {
|
it('scrolls bottom by G', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 100));
|
await webdriver.executeScript(() => window.scrollTo(0, 100));
|
||||||
await body.sendKeys(Key.Shift, 'g');
|
await body.sendKeys(Key.SHIFT, 'g');
|
||||||
|
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert(pageYOffset > 5000);
|
assert(pageYOffset > 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls bottom by 0', async () => {
|
it('scrolls bottom by 0', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 100));
|
await webdriver.executeScript(() => window.scrollTo(0, 100));
|
||||||
await body.sendKeys(Key.Shift, '0');
|
await body.sendKeys(Key.SHIFT, '0');
|
||||||
|
|
||||||
let pageXOffset = await session.executeScript(() => window.pageXOffset);
|
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
|
||||||
assert(pageXOffset === 0);
|
assert(pageXOffset === 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls bottom by $', async () => {
|
it('scrolls bottom by $', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 100));
|
await webdriver.executeScript(() => window.scrollTo(0, 100));
|
||||||
await body.sendKeys(Key.Shift, '$');
|
await body.sendKeys(Key.SHIFT, '$');
|
||||||
|
|
||||||
let pageXOffset = await session.executeScript(() => window.pageXOffset);
|
let pageXOffset = await webdriver.executeScript(() => window.pageXOffset);
|
||||||
assert(pageXOffset > 5000);
|
assert(pageXOffset > 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls bottom by <C-U>', async () => {
|
it('scrolls bottom by <C-U>', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 1000));
|
await webdriver.executeScript(() => window.scrollTo(0, 1000));
|
||||||
await body.sendKeys(Key.Control, 'u');
|
await body.sendKeys(Key.CONTROL, 'u');
|
||||||
|
|
||||||
let pageHeight =
|
let pageHeight =
|
||||||
await session.executeScript(() => window.document.documentElement.clientHeight);
|
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert(Math.abs(pageYOffset - (1000 - Math.floor(pageHeight / 2))) < 5);
|
assert(Math.abs(pageYOffset - (1000 - Math.floor(pageHeight / 2))) < 5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls bottom by <C-D>', async () => {
|
it('scrolls bottom by <C-D>', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 1000));
|
await webdriver.executeScript(() => window.scrollTo(0, 1000));
|
||||||
await body.sendKeys(Key.Control, 'd');
|
await body.sendKeys(Key.CONTROL, 'd');
|
||||||
|
|
||||||
let pageHeight =
|
let pageHeight =
|
||||||
await session.executeScript(() => window.document.documentElement.clientHeight);
|
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert(Math.abs(pageYOffset - (1000 + Math.floor(pageHeight / 2))) < 5);
|
assert(Math.abs(pageYOffset - (1000 + Math.floor(pageHeight / 2))) < 5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls bottom by <C-B>', async () => {
|
it('scrolls bottom by <C-B>', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 1000));
|
await webdriver.executeScript(() => window.scrollTo(0, 1000));
|
||||||
await body.sendKeys(Key.Control, 'b');
|
await body.sendKeys(Key.CONTROL, 'b');
|
||||||
|
|
||||||
let pageHeight =
|
let pageHeight =
|
||||||
await session.executeScript(() => window.document.documentElement.clientHeight);
|
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert(Math.abs(pageYOffset - (1000 - pageHeight)) < 5);
|
assert(Math.abs(pageYOffset - (1000 - pageHeight)) < 5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scrolls bottom by <C-F>', async () => {
|
it('scrolls bottom by <C-F>', async () => {
|
||||||
await session.executeScript(() => window.scrollTo(0, 1000));
|
await webdriver.executeScript(() => window.scrollTo(0, 1000));
|
||||||
await body.sendKeys(Key.Control, 'f');
|
await body.sendKeys(Key.CONTROL, 'f');
|
||||||
|
|
||||||
let pageHeight =
|
let pageHeight =
|
||||||
await session.executeScript(() => window.document.documentElement.clientHeight);
|
await webdriver.executeScript(() => window.document.documentElement.clientHeight);
|
||||||
let pageYOffset = await session.executeScript(() => window.pageYOffset);
|
let pageYOffset = await webdriver.executeScript(() => window.pageYOffset);
|
||||||
assert(Math.abs(pageYOffset - (1000 + pageHeight)) < 5);
|
assert(Math.abs(pageYOffset - (1000 + pageHeight)) < 5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,8 +3,8 @@ const lanthan = require('lanthan');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Builder } = require('lanthan');
|
||||||
const Key = lanthan.Key;
|
const { Key, By } = require('selenium-webdriver');
|
||||||
|
|
||||||
const newApp = () => {
|
const newApp = () => {
|
||||||
let app = express();
|
let app = express();
|
||||||
|
@ -20,24 +20,28 @@ describe("tab test", () => {
|
||||||
const url = `http://127.0.0.1:${port}/`;
|
const url = `http://127.0.0.1:${port}/`;
|
||||||
|
|
||||||
let http;
|
let http;
|
||||||
let firefox;
|
let lanthan;
|
||||||
let session;
|
let webdriver
|
||||||
let browser;
|
let browser;
|
||||||
let win;
|
let win;
|
||||||
let tabs;
|
let tabs;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox();
|
lanthan = await Builder
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
.forBrowser('firefox')
|
||||||
session = firefox.session;
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
browser = firefox.browser;
|
.build();
|
||||||
|
webdriver = lanthan.getWebDriver();
|
||||||
|
browser = lanthan.getWebExtBrowser();
|
||||||
http = newApp().listen(port);
|
http = newApp().listen(port);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
http.close();
|
if (http) {
|
||||||
if (firefox) {
|
http.close();
|
||||||
await firefox.close();
|
}
|
||||||
|
if (lanthan) {
|
||||||
|
await lanthan.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -45,7 +49,7 @@ describe("tab test", () => {
|
||||||
win = await browser.windows.create({ url: `${url}#0` });
|
win = await browser.windows.create({ url: `${url}#0` });
|
||||||
for (let i = 1; i < 5; ++i) {
|
for (let i = 1; i < 5; ++i) {
|
||||||
await browser.tabs.create({ url: `${url}#${i}`, windowId: win.id });
|
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 = await browser.tabs.query({ windowId: win.id });
|
||||||
tabs.sort((t1, t2) => t1.index - t2.index);
|
tabs.sort((t1, t2) => t1.index - t2.index);
|
||||||
|
@ -57,7 +61,7 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('deletes tab and selects right by d', async () => {
|
it('deletes tab and selects right by d', async () => {
|
||||||
await browser.tabs.update(tabs[3].id, { active: true });
|
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');
|
await body.sendKeys('d');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
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 () => {
|
it('deletes tab and selects left by D', async () => {
|
||||||
await browser.tabs.update(tabs[3].id, { active: true });
|
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(Key.Shift, 'D');
|
await body.sendKeys(Key.SHIFT, 'D');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
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 () => {
|
it('deletes all tabs to the right by x$', async () => {
|
||||||
await browser.tabs.update(tabs[1].id, { active: true });
|
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', '$');
|
await body.sendKeys('x', '$');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
|
@ -90,7 +94,7 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('duplicates tab by zd', async () => {
|
it('duplicates tab by zd', async () => {
|
||||||
await browser.tabs.update(tabs[0].id, { active: true });
|
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 body.sendKeys('z', 'd');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
@ -103,7 +107,7 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('makes pinned by zp', async () => {
|
it('makes pinned by zp', async () => {
|
||||||
await browser.tabs.update(tabs[0].id, { active: true });
|
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');
|
await body.sendKeys('z', 'p');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
|
@ -112,8 +116,8 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('selects previous tab by K', async () => {
|
it('selects previous tab by K', async () => {
|
||||||
await browser.tabs.update(tabs[2].id, { active: true });
|
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(Key.Shift, 'K');
|
await body.sendKeys(Key.SHIFT, 'K');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
assert(current[1].active);
|
assert(current[1].active);
|
||||||
|
@ -121,8 +125,8 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('selects previous tab by K rotatory', async () => {
|
it('selects previous tab by K rotatory', async () => {
|
||||||
await browser.tabs.update(tabs[0].id, { active: true });
|
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(Key.Shift, 'K');
|
await body.sendKeys(Key.SHIFT, 'K');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
assert(current[current.length - 1].active)
|
assert(current[current.length - 1].active)
|
||||||
|
@ -130,8 +134,8 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('selects next tab by J', async () => {
|
it('selects next tab by J', async () => {
|
||||||
await browser.tabs.update(tabs[2].id, { active: true });
|
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(Key.Shift, 'J');
|
await body.sendKeys(Key.SHIFT, 'J');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
assert(current[3].active);
|
assert(current[3].active);
|
||||||
|
@ -139,8 +143,8 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('selects previous tab by J rotatory', async () => {
|
it('selects previous tab by J rotatory', async () => {
|
||||||
await browser.tabs.update(tabs[tabs.length - 1].id, { active: true });
|
await browser.tabs.update(tabs[tabs.length - 1].id, { active: true });
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Shift, 'J');
|
await body.sendKeys(Key.SHIFT, 'J');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
assert(current[0].active)
|
assert(current[0].active)
|
||||||
|
@ -148,7 +152,7 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('selects first tab by g0', async () => {
|
it('selects first tab by g0', async () => {
|
||||||
await browser.tabs.update(tabs[2].id, { active: true });
|
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');
|
await body.sendKeys('g', '0');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
|
@ -157,7 +161,7 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('selects last tab by g$', async () => {
|
it('selects last tab by g$', async () => {
|
||||||
await browser.tabs.update(tabs[2].id, { active: true });
|
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', '$');
|
await body.sendKeys('g', '$');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
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[1].id, { active: true });
|
||||||
await browser.tabs.update(tabs[4].id, { active: true });
|
await browser.tabs.update(tabs[4].id, { active: true });
|
||||||
|
|
||||||
let body = await session.findElementByCSS('body');
|
let body = await webdriver.findElement(By.css('body'));
|
||||||
await body.sendKeys(Key.Control, '6');
|
await body.sendKeys(Key.CONTROL, '6');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
assert(current[1].active)
|
assert(current[1].active)
|
||||||
|
@ -179,7 +183,7 @@ describe("tab test", () => {
|
||||||
// This might be a bug in Firefox.
|
// This might be a bug in Firefox.
|
||||||
it.skip('reopen tab by u', async () => {
|
it.skip('reopen tab by u', async () => {
|
||||||
await browser.tabs.remove(tabs[1].id);
|
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');
|
await body.sendKeys('u');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
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 () => {
|
it('does not delete pinned tab by d', async () => {
|
||||||
await browser.tabs.update(tabs[0].id, { active: true, pinned: true });
|
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');
|
await body.sendKeys('d');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
|
@ -197,7 +201,7 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('deletes pinned tab by !d', async () => {
|
it('deletes pinned tab by !d', async () => {
|
||||||
await browser.tabs.update(tabs[0].id, { active: true, pinned: true });
|
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');
|
await body.sendKeys('!', 'd');
|
||||||
|
|
||||||
let current = await browser.tabs.query({ windowId: win.id });
|
let current = await browser.tabs.query({ windowId: win.id });
|
||||||
|
@ -206,7 +210,7 @@ describe("tab test", () => {
|
||||||
|
|
||||||
it('opens view-source by gf', async () => {
|
it('opens view-source by gf', async () => {
|
||||||
await browser.tabs.update(tabs[0].id, { active: true });
|
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 body.sendKeys('g', 'f');
|
||||||
|
|
||||||
await eventually(async() => {
|
await eventually(async() => {
|
||||||
|
|
|
@ -1,36 +1,34 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const lanthan = require('lanthan');
|
const { Builder } = require('lanthan');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const eventually = require('./eventually');
|
const eventually = require('./eventually');
|
||||||
|
const { Key, By } = require('selenium-webdriver');
|
||||||
const Key = lanthan.Key;
|
|
||||||
|
|
||||||
describe("zoom test", () => {
|
describe("zoom test", () => {
|
||||||
|
let lanthan;
|
||||||
let firefox;
|
let webdriver;
|
||||||
let session;
|
|
||||||
let browser;
|
let browser;
|
||||||
let tab;
|
let tab;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
firefox = await lanthan.firefox();
|
lanthan = await Builder
|
||||||
await firefox.session.installAddonFromPath(path.join(__dirname, '..'));
|
.forBrowser('firefox')
|
||||||
session = firefox.session;
|
.spyAddon(path.join(__dirname, '..'))
|
||||||
browser = firefox.browser;
|
.build();
|
||||||
|
webdriver = lanthan.getWebDriver();
|
||||||
|
browser = lanthan.getWebExtBrowser();
|
||||||
tab = (await browser.tabs.query({}))[0]
|
tab = (await browser.tabs.query({}))[0]
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async() => {
|
after(async() => {
|
||||||
if (firefox) {
|
await lanthan.quit();
|
||||||
await firefox.close();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
await session.navigateTo('about:blank');
|
await webdriver.navigate().to('about:blank');
|
||||||
body = await session.findElementByCSS('body');
|
body = await webdriver.findElement(By.css('body'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should zoom in by zi', async () => {
|
it('should zoom in by zi', async () => {
|
||||||
|
|
Reference in a new issue