add tab delete test

jh-changes
Shin'ya Ueoka 7 years ago
parent 3f8bbe11d9
commit 0904f8e1eb
  1. 5
      e2e/ambassador/src/background/index.js
  2. 13
      e2e/ambassador/src/client/windows.js
  3. 4
      e2e/ambassador/src/content/index.js
  4. 2
      e2e/ambassador/src/shared/messages.js
  5. 17
      e2e/contents/tab.test.js

@ -1,5 +1,6 @@
import { import {
WINDOWS_CREATE, WINDOWS_REMOVE, TABS_CREATE, WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET,
TABS_CREATE,
EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP, EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP,
} from '../shared/messages'; } from '../shared/messages';
import * as tabs from './tabs'; import * as tabs from './tabs';
@ -11,6 +12,8 @@ receiveContentMessage((message) => {
return browser.windows.create({ url: message.url }); return browser.windows.create({ url: message.url });
case WINDOWS_REMOVE: case WINDOWS_REMOVE:
return browser.windows.remove(message.windowId); return browser.windows.remove(message.windowId);
case WINDOWS_GET:
return browser.windows.get(message.windowId, { populate: true });
case TABS_CREATE: case TABS_CREATE:
return tabs.create({ return tabs.create({
url: message.url, url: message.url,

@ -1,4 +1,6 @@
import { WINDOWS_CREATE, WINDOWS_REMOVE } from '../shared/messages'; import {
WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET
} from '../shared/messages';
import * as ipc from './ipc'; import * as ipc from './ipc';
const create = (url) => { const create = (url) => {
@ -15,4 +17,11 @@ const remove = (windowId) => {
}); });
}; };
export { create, remove }; const get = (windowId) => {
return ipc.send({
type: WINDOWS_GET,
windowId,
});
};
export { create, remove, get };

@ -1,5 +1,6 @@
import { import {
WINDOWS_CREATE, WINDOWS_REMOVE, TABS_CREATE, WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET,
TABS_CREATE,
EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP, EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP,
} from '../shared/messages'; } from '../shared/messages';
import * as ipc from './ipc'; import * as ipc from './ipc';
@ -8,6 +9,7 @@ ipc.receivePageMessage((message) => {
switch (message.type) { switch (message.type) {
case WINDOWS_CREATE: case WINDOWS_CREATE:
case WINDOWS_REMOVE: case WINDOWS_REMOVE:
case WINDOWS_GET:
case TABS_CREATE: case TABS_CREATE:
case EVENT_KEYPRESS: case EVENT_KEYPRESS:
case EVENT_KEYDOWN: case EVENT_KEYDOWN:

@ -2,6 +2,7 @@ const METHOD_REQUEST = 'request';
const METHOD_RESPONSE = 'response'; const METHOD_RESPONSE = 'response';
const WINDOWS_CREATE = 'windows.create'; const WINDOWS_CREATE = 'windows.create';
const WINDOWS_REMOVE = 'windows.remove'; const WINDOWS_REMOVE = 'windows.remove';
const WINDOWS_GET = 'windows.get';
const TABS_CREATE = 'tabs.create'; const TABS_CREATE = 'tabs.create';
const EVENT_KEYPRESS = 'event.keypress'; const EVENT_KEYPRESS = 'event.keypress';
const EVENT_KEYDOWN = 'event.keydown'; const EVENT_KEYDOWN = 'event.keydown';
@ -13,6 +14,7 @@ export {
WINDOWS_CREATE, WINDOWS_CREATE,
WINDOWS_REMOVE, WINDOWS_REMOVE,
WINDOWS_GET,
TABS_CREATE, TABS_CREATE,

@ -5,7 +5,7 @@ import * as keys from "../ambassador/src/client/keys";
const SERVER_URL = "localhost:11111"; const SERVER_URL = "localhost:11111";
describe("tab test", function() { describe("tab test", () => {
let targetWindow; let targetWindow;
let targetTab; let targetTab;
@ -22,14 +22,13 @@ describe("tab test", function() {
return windows.remove(targetWindow.id); return windows.remove(targetWindow.id);
}); });
it('delete tab', (done) => { it('delete tab', () => {
let before = window.document.documentElement.scrollTop; return Promise.resolve().then(() => {
keys.press(targetTab.id, 'j').then((r) => { return keys.press(targetTab.id, 'd');
}).then(() => {
return windows.get(targetWindow.id);
}).then((after) => {
expect(after.tabs).to.have.lengthOf(1);
}); });
keys.press(targetTab.id, 'j').then((r) => {
});
keys.press(targetTab.id, 'G').then((r) => {
});
let after = window.document.documentElement.scrollTop;
}); });
}); });