aboutsummaryrefslogtreecommitdiff
path: root/e2e-lanthan
diff options
context:
space:
mode:
Diffstat (limited to 'e2e-lanthan')
-rw-r--r--e2e-lanthan/eventually.js25
-rw-r--r--e2e-lanthan/mark.test.js121
-rw-r--r--e2e-lanthan/navigate.test.js167
-rw-r--r--e2e-lanthan/scroll.test.js150
-rw-r--r--e2e-lanthan/server/MockServer.js58
-rw-r--r--e2e-lanthan/server/handlers.js17
-rw-r--r--e2e-lanthan/tab.test.js202
-rw-r--r--e2e-lanthan/zoom.test.js81
8 files changed, 0 insertions, 821 deletions
diff --git a/e2e-lanthan/eventually.js b/e2e-lanthan/eventually.js
deleted file mode 100644
index c04c277..0000000
--- a/e2e-lanthan/eventually.js
+++ /dev/null
@@ -1,25 +0,0 @@
-const assert = require('assert');
-
-let defaultInterval = 100;
-let defaultTimeout = 2000;
-
-function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
-}
-
-const eventually = async (fn, timeout = defaultTimeout, interval = defaultInterval) => {
- let start = Date.now();
- let loop = async() => {
- try {
- await fn();
- } catch (err) {
- if (Date.now() - start > timeout) {
- throw err;
- }
- await new Promise((resolve) => setTimeout(resolve, interval))
- await loop();
- }
- };
- await loop();
-};
-module.exports = eventually;
diff --git a/e2e-lanthan/mark.test.js b/e2e-lanthan/mark.test.js
deleted file mode 100644
index abcef03..0000000
--- a/e2e-lanthan/mark.test.js
+++ /dev/null
@@ -1,121 +0,0 @@
-const express = require('express');
-const lanthan = require('lanthan');
-const path = require('path');
-const assert = require('power-assert');
-const eventually = require('./eventually');
-
-const Key = lanthan.Key;
-
-const newApp = () => {
- let app = express();
- app.get('/', (req, res) => {
- res.send(`<!DOCTYPEhtml>
-<html lang="en">
- <body style="width:10000px; height:10000px"></body>
-</html">`);
- });
- return app;
-};
-
-describe("mark test", () => {
-
- const port = 12321;
- let http;
- let firefox;
- let session;
- let browser;
-
- before(async() => {
- http = newApp().listen(port);
-
- firefox = await lanthan.firefox();
- await firefox.session.installAddon(path.join(__dirname, '..'));
- session = firefox.session;
- browser = firefox.browser;
- });
-
- after(async() => {
- if (firefox) {
- await firefox.close();
- }
- http.close();
- });
-
- it('should set a local mark and jump to it', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}`);
- let body = await session.findElementByCSS('body');
-
- await session.executeScript(() => window.scrollTo(200, 200));
- await body.sendKeys('m', 'a');
- await session.executeScript(() => window.scrollTo(500, 500));
- await body.sendKeys('\'', 'a');
-
- await eventually(async() => {
- let pageXOffset = await session.executeScript(() => window.pageXOffset);
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert.equal(pageXOffset, 200);
- assert.equal(pageYOffset, 200);
- });
- });
-
- it('should set a global mark and jump to it', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}#first`);
- let body = await session.findElementByCSS('body');
-
- await session.executeScript(() => window.scrollTo(200, 200));
- await body.sendKeys('m', 'A');
- await session.executeScript(() => window.scrollTo(500, 500));
- await body.sendKeys('\'', 'A');
-
- await eventually(async() => {
- let pageXOffset = await session.executeScript(() => window.pageXOffset);
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert.equal(pageXOffset, 200);
- assert.equal(pageYOffset, 200);
- });
-
- await browser.tabs.create({ url: `http://127.0.0.1:${port}#second` });
- body = await session.findElementByCSS('body');
- await body.sendKeys('\'', 'A');
-
- await eventually(async() => {
- let tab = (await browser.tabs.query({ active: true }))[0];
- let url = new URL(tab.url);
- assert.equal(url.hash, '#first');
-
- let pageXOffset = await session.executeScript(() => window.pageXOffset);
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert.equal(pageXOffset, 200);
- assert.equal(pageYOffset, 200);
- });
- });
-
- it('set a global mark and creates new tab from gone', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}#first`);
- await session.executeScript(() => window.scrollTo(500, 500));
- let body = await session.findElementByCSS('body');
- await body.sendKeys('m', 'A');
-
- let tab = (await browser.tabs.query({ active: true }))[0];
- await browser.tabs.create({ url: `http://127.0.0.1:${port}#second` });
- await browser.tabs.remove(tab.id);
-
- let handles;
- await eventually(async() => {
- handles = await session.getWindowHandles();
- assert.equal(handles.length, 2);
- });
- await session.switchToWindow(handles[0]);
- await session.navigateTo(`http://127.0.0.1:${port}#second`);
- body = await session.findElementByCSS('body');
- await body.sendKeys('\'', 'A');
-
- await eventually(async() => {
- let tab = (await browser.tabs.query({ active: true }))[0];
- let url = new URL(tab.url);
- assert.equal(url.hash, '#first');
- });
- });
-});
-
-
diff --git a/e2e-lanthan/navigate.test.js b/e2e-lanthan/navigate.test.js
deleted file mode 100644
index 5b3a794..0000000
--- a/e2e-lanthan/navigate.test.js
+++ /dev/null
@@ -1,167 +0,0 @@
-const express = require('express');
-const lanthan = require('lanthan');
-const path = require('path');
-const assert = require('power-assert');
-const eventually = require('./eventually');
-
-const Key = lanthan.Key;
-
-const newApp = () => {
- let app = express();
- app.get('/pagenation-a/:page', (req, res) => {
- res.status(200).send(`
-<html lang="en">
- <a href="/pagenation-a/${Number(req.params.page) - 1}">prev</a>
- <a href="/pagenation-a/${Number(req.params.page) + 1}">next</a>
-</html">`);
- });
- app.get('/pagenation-link/:page', (req, res) => {
- res.status(200).send(`
-<html lang="en">
- <head>
- <link rel="prev" href="/pagenation-link/${Number(req.params.page) - 1}"></link>
- <link rel="next" href="/pagenation-link/${Number(req.params.page) + 1}"></link>
- </head>
-</html">`);
- });
-
- app.get('/*', (req, res) => {
- res.send(`<!DOCTYPEhtml>
-<html lang="en">
- ${req.path}
-</html">`);
- });
- return app;
-};
-
-describe("zoom test", () => {
-
- const port = 12321;
- let http;
- let firefox;
- let session;
- let browser;
-
- before(async() => {
- http = newApp().listen(port);
-
- firefox = await lanthan.firefox();
- await firefox.session.installAddon(path.join(__dirname, '..'));
- session = firefox.session;
- browser = firefox.browser;
- });
-
- after(async() => {
- if (firefox) {
- await firefox.close();
- }
- http.close();
- });
-
- it('should go to parent path without hash by gu', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/a/b/c`);
- let body = await session.findElementByCSS('body');
-
- await body.sendKeys('g', 'u');
-
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.pathname, `/a/b/`)
- });
-
- it('should remove hash by gu', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/a/b/c#hash`);
- let body = await session.findElementByCSS('body');
-
- await body.sendKeys('g', 'u');
-
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.hash, '')
- assert.equal(url.pathname, `/a/b/c`)
- });
-
- it('should go to root path by gU', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/a/b/c#hash`);
- let body = await session.findElementByCSS('body');
-
- await body.sendKeys('g', Key.Shift, 'u');
-
- await eventually(async() => {
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.pathname, `/`)
- });
- });
-
- it('should go back and forward in history by H and L', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/first`);
- await session.navigateTo(`http://127.0.0.1:${port}/second`);
- let body = await session.findElementByCSS('body');
-
- await body.sendKeys(Key.Shift, 'h');
-
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.pathname, `/first`)
-
- body = await session.findElementByCSS('body');
- await body.sendKeys(Key.Shift, 'l');
-
- tab = (await browser.tabs.query({}))[0];
- url = new URL(tab.url);
- assert.equal(url.pathname, `/second`)
- });
-
- it('should go previous and next page in <a> by [[ and ]]', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/pagenation-a/10`);
-
- let body = await session.findElementByCSS('body');
- await body.sendKeys('[', '[');
-
- await eventually(async() => {
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.pathname, '/pagenation-a/9');
- });
- });
-
- it('should go next page in <a> by ]]', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/pagenation-a/10`);
- let body = await session.findElementByCSS('body');
- await body.sendKeys(']', ']');
-
- await eventually(async() => {
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.pathname, '/pagenation-a/11');
- });
- });
-
- it('should go previous page in <link> by ]]', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/pagenation-link/10`);
-
- let body = await session.findElementByCSS('body');
- await body.sendKeys('[', '[');
-
- await eventually(async() => {
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.pathname, '/pagenation-link/9');
- });
- });
-
- it('should go next page by in <link> by [[', async () => {
- await session.navigateTo(`http://127.0.0.1:${port}/pagenation-link/10`);
- let body = await session.findElementByCSS('body');
- await body.sendKeys(']', ']');
-
- await eventually(async() => {
- let tab = (await browser.tabs.query({}))[0];
- let url = new URL(tab.url);
- assert.equal(url.pathname, '/pagenation-link/11');
- });
- });
-});
-
-
diff --git a/e2e-lanthan/scroll.test.js b/e2e-lanthan/scroll.test.js
deleted file mode 100644
index 7b13a72..0000000
--- a/e2e-lanthan/scroll.test.js
+++ /dev/null
@@ -1,150 +0,0 @@
-const express = require('express');
-const lanthan = require('lanthan');
-const path = require('path');
-const assert = require('power-assert');
-
-const Key = lanthan.Key;
-
-const newApp = () => {
- let app = express();
- app.get('/', (req, res) => {
- res.send(`<!DOCTYPEhtml>
-<html lang="en">
- <body style="width:10000px; height:10000px"></body>
-</html">`);
- });
- return app;
-};
-
-describe("scroll test", () => {
-
- const port = 12321;
- let http;
- let firefox;
- let session;
- let body;
-
- before(async() => {
- http = newApp().listen(port);
-
- firefox = await lanthan.firefox();
- await firefox.session.installAddon(path.join(__dirname, '..'));
- session = firefox.session;
- });
-
- after(async() => {
- if (firefox) {
- await firefox.close();
- }
- http.close();
- });
-
- beforeEach(async() => {
- await session.navigateTo(`http://127.0.0.1:${port}`);
- body = await session.findElementByCSS('body');
- });
-
-
- it('scrolls up by k', async () => {
- await body.sendKeys('j');
-
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert.equal(pageYOffset, 64);
- });
-
- it('scrolls down by j', async () => {
- await session.executeScript(() => window.scrollTo(0, 200));
- await body.sendKeys('k');
-
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert.equal(pageYOffset, 136);
- });
-
- it('scrolls left by h', async () => {
- await session.executeScript(() => window.scrollTo(100, 100));
- await body.sendKeys('h');
-
- let pageXOffset = await session.executeScript(() => window.pageXOffset);
- assert.equal(pageXOffset, 36);
- });
-
- it('scrolls left by l', async () => {
- await session.executeScript(() => window.scrollTo(100, 100));
- await body.sendKeys('l');
-
- let pageXOffset = await session.executeScript(() => window.pageXOffset);
- assert.equal(pageXOffset, 164);
- });
-
- it('scrolls top by gg', async () => {
- await session.executeScript(() => window.scrollTo(0, 100));
- await body.sendKeys('g', 'g');
-
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert.equal(pageYOffset, 0);
- });
-
- it('scrolls bottom by G', async () => {
- await session.executeScript(() => window.scrollTo(0, 100));
- await body.sendKeys(Key.Shift, 'g');
-
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert(pageYOffset > 5000);
- });
-
- it('scrolls bottom by 0', async () => {
- await session.executeScript(() => window.scrollTo(0, 100));
- await body.sendKeys(Key.Shift, '0');
-
- let pageXOffset = await session.executeScript(() => window.pageXOffset);
- assert(pageXOffset === 0);
- });
-
- it('scrolls bottom by $', async () => {
- await session.executeScript(() => window.scrollTo(0, 100));
- await body.sendKeys(Key.Shift, '$');
-
- let pageXOffset = await session.executeScript(() => window.pageXOffset);
- assert(pageXOffset > 5000);
- });
-
- it('scrolls bottom by <C-U>', async () => {
- await session.executeScript(() => window.scrollTo(0, 1000));
- await body.sendKeys(Key.Control, 'u');
-
- let pageHeight =
- await session.executeScript(() => window.document.documentElement.clientHeight);
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert(Math.abs(pageYOffset - (1000 - Math.floor(pageHeight / 2))) < 5);
- });
-
- it('scrolls bottom by <C-D>', async () => {
- await session.executeScript(() => window.scrollTo(0, 1000));
- await body.sendKeys(Key.Control, 'd');
-
- let pageHeight =
- await session.executeScript(() => window.document.documentElement.clientHeight);
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert(Math.abs(pageYOffset - (1000 + Math.floor(pageHeight / 2))) < 5);
- });
-
- it('scrolls bottom by <C-B>', async () => {
- await session.executeScript(() => window.scrollTo(0, 1000));
- await body.sendKeys(Key.Control, 'b');
-
- let pageHeight =
- await session.executeScript(() => window.document.documentElement.clientHeight);
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert(Math.abs(pageYOffset - (1000 - pageHeight)) < 5);
- });
-
- it('scrolls bottom by <C-F>', async () => {
- await session.executeScript(() => window.scrollTo(0, 1000));
- await body.sendKeys(Key.Control, 'f');
-
- let pageHeight =
- await session.executeScript(() => window.document.documentElement.clientHeight);
- let pageYOffset = await session.executeScript(() => window.pageYOffset);
- assert(Math.abs(pageYOffset - (1000 + pageHeight)) < 5);
- });
-});
diff --git a/e2e-lanthan/server/MockServer.js b/e2e-lanthan/server/MockServer.js
deleted file mode 100644
index 131c177..0000000
--- a/e2e-lanthan/server/MockServer.js
+++ /dev/null
@@ -1,58 +0,0 @@
-var http = require('http');
-var url = require('url');
-var handlers = require('./handlers');
-
-class MockServer {
- constructor() {
- this.handlers = [];
- this.server = undefined;
- }
-
- start() {
- if (this.server) {
- throw new Error('Server is already started');
- }
-
- let listener = (req, res) => {
- if (req.method !== 'GET') {
- res.writeHead(404, {'Content-Type': 'text/plain'});
- res.end('not found')
- return
- }
-
- let u = url.parse(req.url);
- let handler = this.handlers.find(h => u.pathname == h.pathname);
- if (!handler) {
- res.writeHead(404, {'Content-Type': 'text/plain'});
- res.end('not found')
- return
- }
-
- handler.handler(req, res);
- }
-
- this.server = http.createServer(listener);
- this.server.listen();
- }
-
- stop() {
- if (!this.server) {
- throw new Error('Server is not started');
- }
- this.server.close();
- this.server = undefined;
- }
-
- port() {
- if (!this.server) {
- throw new Error('Server is not started');
- }
- return this.server.address().port
- }
-
- on(pathname, handler) {
- this.handlers.push({ pathname, handler });
- }
-}
-
-module.exports = MockServer
diff --git a/e2e-lanthan/server/handlers.js b/e2e-lanthan/server/handlers.js
deleted file mode 100644
index 979b4be..0000000
--- a/e2e-lanthan/server/handlers.js
+++ /dev/null
@@ -1,17 +0,0 @@
-const handleText = (body) => {
- return (req, res) => {
- res.writeHead(200, {'Content-Type': 'text/plane'});
- res.end(body);
- }
-}
-
-const handleHtml = (body) => {
- return (req, res) => {
- res.writeHead(200, {'Content-Type': 'text/html'});
- res.end(body);
- }
-}
-
-module.exports = {
- handleText, handleHtml
-}
diff --git a/e2e-lanthan/tab.test.js b/e2e-lanthan/tab.test.js
deleted file mode 100644
index 93b0fc6..0000000
--- a/e2e-lanthan/tab.test.js
+++ /dev/null
@@ -1,202 +0,0 @@
-const express = require('express');
-const lanthan = require('lanthan');
-const path = require('path');
-const assert = require('power-assert');
-const eventually = require('./eventually');
-
-const Key = lanthan.Key;
-
-const newApp = () => {
- let app = express();
- app.get('/', (req, res) => {
- res.send('ok');
- });
- return app;
-};
-
-describe("tab test", () => {
-
- const port = 12321;
- const url = `http://127.0.0.1:${port}/`;
-
- let http;
- let firefox;
- let session;
- let browser;
- let win;
- let tabs;
-
- before(async() => {
- firefox = await lanthan.firefox();
- await firefox.session.installAddon(path.join(__dirname, '..'));
- session = firefox.session;
- browser = firefox.browser;
- http = newApp().listen(port);
- });
-
- after(async() => {
- http.close();
- if (firefox) {
- await firefox.close();
- }
- });
-
- beforeEach(async() => {
- win = await browser.windows.create({ url: `${url}#0` });
- for (let i = 1; i < 5; ++i) {
- await browser.tabs.create({ url: `${url}#${i}`, windowId: win.id });
- await session.navigateTo(`${url}#${i}`);
- }
- tabs = await browser.tabs.query({ windowId: win.id });
- tabs.sort((t1, t2) => t1.index - t2.index);
- });
-
- afterEach(async() => {
- await browser.windows.remove(win.id);
- });
-
- it('deletes tab by d', async () => {
- let body = await session.findElementByCSS('body');
- await body.sendKeys('d');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current.length === tabs.length - 1);
- });
-
- it('deletes tabs to the right by D', async () => {
- await browser.tabs.update(tabs[1].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys(Key.Shift, 'd');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current.length === 2);
- });
-
- it('duplicates tab by zd', async () => {
- await browser.tabs.update(tabs[0].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys('z', 'd');
-
- await eventually(async() => {
- let current = await browser.tabs.query({ windowId: win.id });
- current.sort((t1, t2) => t1.index - t2.index);
- assert(current.length === tabs.length + 1);
- assert(current[0].url === current[1].url);
- });
- });
-
- it('makes pinned by zp', async () => {
- await browser.tabs.update(tabs[0].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys('z', 'p');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[0].pinned);
- });
-
- it('selects previous tab by K', async () => {
- await browser.tabs.update(tabs[2].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys(Key.Shift, 'K');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[1].active);
- });
-
- it('selects previous tab by K rotatory', async () => {
- await browser.tabs.update(tabs[0].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys(Key.Shift, 'K');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[current.length - 1].active)
- });
-
- it('selects next tab by J', async () => {
- await browser.tabs.update(tabs[2].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys(Key.Shift, 'J');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[3].active);
- });
-
- it('selects previous tab by J rotatory', async () => {
- await browser.tabs.update(tabs[tabs.length - 1].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys(Key.Shift, 'J');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[0].active)
- });
-
- it('selects first tab by g0', async () => {
- await browser.tabs.update(tabs[2].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys('g', '0');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[0].active)
- });
-
- it('selects last tab by g$', async () => {
- await browser.tabs.update(tabs[2].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys('g', '$');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[current.length - 1].active)
- });
-
- it('selects last selected tab by <C-6>', async () => {
- await browser.tabs.update(tabs[1].id, { active: true });
- await browser.tabs.update(tabs[4].id, { active: true });
-
- let body = await session.findElementByCSS('body');
- await body.sendKeys(Key.Control, '6');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current[1].active)
- });
-
- // browser.sessions.getRecentlyClosed() sometime throws "An unexpected error occurred"
- // This might be a bug in Firefox.
- it.skip('reopen tab by u', async () => {
- await browser.tabs.remove(tabs[1].id);
- let body = await session.findElementByCSS('body');
- await body.sendKeys('u');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current.length === tabs.length);
- });
-
- it('does not delete pinned tab by d', async () => {
- await browser.tabs.update(tabs[0].id, { active: true, pinned: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys('d');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current.length === tabs.length);
- });
-
- it('deletes pinned tab by !d', async () => {
- await browser.tabs.update(tabs[0].id, { active: true, pinned: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys('!', 'd');
-
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current.length === tabs.length - 1);
- });
-
- it('opens view-source by gf', async () => {
- await browser.tabs.update(tabs[0].id, { active: true });
- let body = await session.findElementByCSS('body');
- await body.sendKeys('g', 'f');
-
- await eventually(async() => {
- let current = await browser.tabs.query({ windowId: win.id });
- assert(current.length === tabs.length + 1);
- assert(current[current.length - 1].url === `view-source:${url}#0`);
- });
- });
-});
diff --git a/e2e-lanthan/zoom.test.js b/e2e-lanthan/zoom.test.js
deleted file mode 100644
index 1f59e3d..0000000
--- a/e2e-lanthan/zoom.test.js
+++ /dev/null
@@ -1,81 +0,0 @@
-const express = require('express');
-const lanthan = require('lanthan');
-const path = require('path');
-const assert = require('power-assert');
-const eventually = require('./eventually');
-
-const Key = lanthan.Key;
-
-const newApp = () => {
- let app = express();
- app.get('/', (req, res) => {
- res.send(`<!DOCTYPEhtml>
-<html lang="en">
-</html">`);
- });
- return app;
-};
-
-describe("zoom test", () => {
-
- const port = 12321;
- let http;
- let firefox;
- let session;
- let browser;
- let tab;
- let body;
-
- before(async() => {
- http = newApp().listen(port);
-
- firefox = await lanthan.firefox();
- await firefox.session.installAddon(path.join(__dirname, '..'));
- session = firefox.session;
- browser = firefox.browser;
- tab = (await browser.tabs.query({}))[0]
- });
-
- after(async() => {
- if (firefox) {
- await firefox.close();
- }
- http.close();
- });
-
- beforeEach(async() => {
- await session.navigateTo(`http://127.0.0.1:${port}`);
- body = await session.findElementByCSS('body');
- });
-
- it('should zoom in by zi', async () => {
- let before = await browser.tabs.getZoom(tab.id);
- await body.sendKeys('z', 'i');
-
- await eventually(async() => {
- let actual = await browser.tabs.getZoom(tab.id);
- assert(before < actual);
- });
- });
-
- it('should zoom out by zo', async () => {
- let before = await browser.tabs.getZoom(tab.id);
- await body.sendKeys('z', 'o');
-
- await eventually(async() => {
- let actual = await browser.tabs.getZoom(tab.id);
- assert(before > actual);
- });
- });
-
- it('scrolls left by h', async () => {
- await browser.tabs.setZoom(tab.id, 2);
- await body.sendKeys('z', 'z');
-
- await eventually(async() => {
- let actual = await browser.tabs.getZoom(tab.id);
- assert(actual === 1);
- });
- });
-});
-