Add e2e test cases for deleting tabs

jh-changes
Shin'ya Ueoka 7 years ago
parent 82aad419a7
commit 5617f6f765
  1. 1
      QA.md
  2. 5
      e2e/ambassador/src/background/index.js
  3. 4
      e2e/ambassador/src/background/tabs.js
  4. 13
      e2e/ambassador/src/client/tabs.js
  5. 2
      e2e/ambassador/src/shared/messages.js
  6. 32
      e2e/contents/tab.test.js

@ -21,7 +21,6 @@ The behaviors of the console are tested in [Console section](#consoles).
#### Tabs #### Tabs
- [ ] <kbd>!d</kbd>: delete current tab and pinned tab
- [ ] <kbd>u</kbd>: reopen close tab - [ ] <kbd>u</kbd>: reopen close tab
- [ ] <kbd>r</kbd>: reload current tab - [ ] <kbd>r</kbd>: reload current tab
- [ ] <kbd>R</kbd>: reload current tab without cache - [ ] <kbd>R</kbd>: reload current tab without cache

@ -1,6 +1,7 @@
import { import {
WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET, WINDOWS_CREATE, WINDOWS_REMOVE, WINDOWS_GET,
TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_GET_ZOOM, TABS_SET_ZOOM, TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE,
TABS_GET_ZOOM, TABS_SET_ZOOM,
EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP, EVENT_KEYPRESS, EVENT_KEYDOWN, EVENT_KEYUP,
SCROLL_GET, SCROLL_SET, SCROLL_GET, SCROLL_SET,
} from '../shared/messages'; } from '../shared/messages';
@ -27,6 +28,8 @@ receiveContentMessage((message) => {
}); });
case TABS_GET: case TABS_GET:
return browser.tabs.get(message.tabId); return browser.tabs.get(message.tabId);
case TABS_UPDATE:
return browser.tabs.update(message.tabId, message.properties);
case TABS_GET_ZOOM: case TABS_GET_ZOOM:
return browser.tabs.getZoom(message.tabId); return browser.tabs.getZoom(message.tabId);
case TABS_SET_ZOOM: case TABS_SET_ZOOM:

@ -5,7 +5,9 @@ const create = (props = {}) => {
if (tab.url !== 'about:blank' && tabId === createdTab.id && if (tab.url !== 'about:blank' && tabId === createdTab.id &&
changeInfo.status === 'complete') { changeInfo.status === 'complete') {
browser.tabs.onUpdated.removeListener(callback); browser.tabs.onUpdated.removeListener(callback);
setTimeout(() => resolve(tab), 50) // wait for 50 milliseconds to ensure plugin loaded;
// wait for 50 milliseconds to ensure plugin loaded;
setTimeout(() => resolve(tab), 50);
} }
}; };
browser.tabs.onUpdated.addListener(callback); browser.tabs.onUpdated.addListener(callback);

@ -1,5 +1,6 @@
import { import {
TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_GET_ZOOM, TABS_SET_ZOOM, TABS_CREATE, TABS_SELECT_AT, TABS_GET, TABS_UPDATE,
TABS_GET_ZOOM, TABS_SET_ZOOM,
} from '../shared/messages'; } from '../shared/messages';
import * as ipc from './ipc'; import * as ipc from './ipc';
@ -26,6 +27,14 @@ const get = (tabId) => {
}); });
}; };
const update = (tabId, properties) => {
return ipc.send({
type: TABS_UPDATE,
tabId,
properties,
});
};
const getZoom = (tabId) => { const getZoom = (tabId) => {
return ipc.send({ return ipc.send({
tabId, tabId,
@ -41,4 +50,4 @@ const setZoom = (tabId, factor) => {
}); });
}; };
export { create, selectAt, get, getZoom, setZoom }; export { create, selectAt, get, update, getZoom, setZoom };

@ -6,6 +6,7 @@ const WINDOWS_GET = 'windows.get';
const TABS_CREATE = 'tabs.create'; const TABS_CREATE = 'tabs.create';
const TABS_SELECT_AT = 'tabs.selectAt'; const TABS_SELECT_AT = 'tabs.selectAt';
const TABS_GET = 'tabs.get'; const TABS_GET = 'tabs.get';
const TABS_UPDATE = 'tabs.update';
const TABS_GET_ZOOM = 'tabs.get.zoom'; const TABS_GET_ZOOM = 'tabs.get.zoom';
const TABS_SET_ZOOM = 'tabs.set.zoom'; const TABS_SET_ZOOM = 'tabs.set.zoom';
const EVENT_KEYPRESS = 'event.keypress'; const EVENT_KEYPRESS = 'event.keypress';
@ -23,6 +24,7 @@ export {
WINDOWS_GET, WINDOWS_GET,
TABS_GET, TABS_GET,
TABS_UPDATE,
TABS_CREATE, TABS_CREATE,
TABS_SELECT_AT, TABS_SELECT_AT,
TABS_GET_ZOOM, TABS_GET_ZOOM,

@ -212,4 +212,36 @@ describe("tab test", () => {
expect(win.tabs).to.have.lengthOf(1); expect(win.tabs).to.have.lengthOf(1);
}); });
}); });
it('does not delete pinned tab by d', () => {
return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1');
}).then((tab) => {
return tabs.update(tab.id, { pinned: true });
}).then((tab) => {
return keys.press(tab.id, 'd');
}).then(() => {
return windows.get(targetWindow.id);
}).then((win) => {
expect(win.tabs).to.have.lengthOf(2);
});
});
it('deletes pinned tab by !d', () => {
let target;
return Promise.resolve().then(() => {
return tabs.create(targetWindow.id, SERVER_URL + '#1');
}).then((tab) => {
return tabs.update(tab.id, { pinned: true });
}).then((tab) => {
target = tab;
return keys.press(target.id, '!');
}).then(() => {
return keys.press(target.id, 'd');
}).then(() => {
return windows.get(targetWindow.id);
}).then((win) => {
expect(win.tabs).to.have.lengthOf(1);
});
});
}); });