commit
5750b5a037
5 changed files with 106 additions and 11 deletions
8
QA.md
8
QA.md
|
@ -4,10 +4,6 @@
|
||||||
|
|
||||||
Test operations with default key maps.
|
Test operations with default key maps.
|
||||||
|
|
||||||
#### Console
|
|
||||||
|
|
||||||
The behaviors of the console are tested in [Console section](#consoles).
|
|
||||||
|
|
||||||
#### Misc
|
#### Misc
|
||||||
|
|
||||||
- [ ] Toggle enabled/disabled of plugin bu <kbd>Shift</kbd>+<kbd>Esc</kbd>
|
- [ ] Toggle enabled/disabled of plugin bu <kbd>Shift</kbd>+<kbd>Esc</kbd>
|
||||||
|
@ -27,10 +23,6 @@ The behaviors of the console are tested in [Console section](#consoles).
|
||||||
|
|
||||||
#### Form Settings
|
#### Form Settings
|
||||||
|
|
||||||
##### `"blacklist"` section
|
|
||||||
|
|
||||||
- [ ] `github.com/a` blocks `github.com/a`, and not blocks `github.com/aa`
|
|
||||||
|
|
||||||
##### Updating
|
##### Updating
|
||||||
|
|
||||||
- [ ] keymap settings are applied to open tabs without reload
|
- [ ] keymap settings are applied to open tabs without reload
|
||||||
|
|
|
@ -4,6 +4,8 @@ title: Blacklist
|
||||||
|
|
||||||
# Blacklist
|
# Blacklist
|
||||||
|
|
||||||
|
## Blacklist
|
||||||
|
|
||||||
The blacklist allows you to disable the plugin for certain pages by URL patterns.
|
The blacklist allows you to disable the plugin for certain pages by URL patterns.
|
||||||
For instance, you could use `"*.slack.com"` to disable the plugin on all Slack channels.
|
For instance, you could use `"*.slack.com"` to disable the plugin on all Slack channels.
|
||||||
In addition, you can also specify path patterns, such as `"example.com/mail/*"`.
|
In addition, you can also specify path patterns, such as `"example.com/mail/*"`.
|
||||||
|
@ -19,3 +21,20 @@ In addition, you can also specify path patterns, such as `"example.com/mail/*"`.
|
||||||
|
|
||||||
You can toggle Vim Vixen between disabled and enabled with
|
You can toggle Vim Vixen between disabled and enabled with
|
||||||
<kbd>shift</kbd>+<kbd>Esc</kbd>.
|
<kbd>shift</kbd>+<kbd>Esc</kbd>.
|
||||||
|
|
||||||
|
## Partial Blacklist
|
||||||
|
|
||||||
|
The partial blacklist disables certain keys for each webpage separately.
|
||||||
|
This is enabled by describing object with `"url"` and `"keys"` instead of a string in the blacklist.
|
||||||
|
To disable <kbd>j</kbd> and <kbd>k</kbd> keys (scroll down and up) on github.com as an example, describe target url and disabled keys as the following:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"blacklist" [
|
||||||
|
{ "url": "github.com", "keys": ["j", "k"] }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The partial blacklist blocks all operations starting with the keys but not exactly-matched.
|
||||||
|
That means if the g described in "keys" field, it block all operation starting with <kbd>g</kbd>, such as <kbd>g</kbd><kbd>g</kbd>, <kbd>g</kbd><kbd>t</kbd>, and <kbd>g</kbd><kbd>T</kbd>.
|
||||||
|
|
|
@ -10,6 +10,10 @@ Open the console with <kbd>:</kbd>. Or populate it with initial values using
|
||||||
<kbd>o</kbd>/<kbd>O</kbd>, <kbd>t</kbd>/<kbd>T</kbd>, or
|
<kbd>o</kbd>/<kbd>O</kbd>, <kbd>t</kbd>/<kbd>T</kbd>, or
|
||||||
<kbd>w</kbd>/<kbd>W</kbd>.
|
<kbd>w</kbd>/<kbd>W</kbd>.
|
||||||
|
|
||||||
|
## `:help`
|
||||||
|
|
||||||
|
Open a [Vim Vixen official document](https://ueokande.github.io/vim-vixen/) in a new tab.
|
||||||
|
|
||||||
## `:open`
|
## `:open`
|
||||||
|
|
||||||
The `:open` command operates two different ways, depending on the parameter.
|
The `:open` command operates two different ways, depending on the parameter.
|
||||||
|
|
|
@ -8,13 +8,31 @@ export default class FormOptionPage {
|
||||||
this.webdriver = lanthan.getWebDriver();
|
this.webdriver = lanthan.getWebDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
async setBlacklist(nth: number, value: string): Promise<void> {
|
async setBlacklist(nth: number, url: string): Promise<void> {
|
||||||
let selector = '.form-blacklist-form-row > .column-url';
|
let selector = '.form-blacklist-form-row > .column-url';
|
||||||
let inputs = await this.webdriver.findElements(By.css(selector));
|
let inputs = await this.webdriver.findElements(By.css(selector));
|
||||||
if (inputs.length <= nth) {
|
if (inputs.length <= nth) {
|
||||||
throw new RangeError('Index out of range to set a blacklist')
|
throw new RangeError('Index out of range to set a blacklist')
|
||||||
}
|
}
|
||||||
await inputs[nth].sendKeys(value);
|
await inputs[nth].sendKeys(url);
|
||||||
|
await this.webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async setPartialBlacklist(nth: number, url: string, keys: string): Promise<void> {
|
||||||
|
let selector = '.form-partial-blacklist-form-row > .column-url';
|
||||||
|
let inputs = await this.webdriver.findElements(By.css(selector));
|
||||||
|
if (inputs.length <= nth) {
|
||||||
|
throw new RangeError('Index out of range to set a partial blacklist')
|
||||||
|
}
|
||||||
|
await inputs[nth].sendKeys(url);
|
||||||
|
await this.webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
|
||||||
|
|
||||||
|
selector = '.form-partial-blacklist-form-row > .column-keys';
|
||||||
|
inputs = await this.webdriver.findElements(By.css(selector));
|
||||||
|
if (inputs.length <= nth) {
|
||||||
|
throw new RangeError('Index out of range to set a partial blacklist')
|
||||||
|
}
|
||||||
|
await inputs[nth].sendKeys(keys);
|
||||||
await this.webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
|
await this.webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +61,13 @@ export default class FormOptionPage {
|
||||||
await this.webdriver.wait(until.elementLocated(By.css(`.form-blacklist-form-row:nth-child(${rows.length + 1})`)));
|
await this.webdriver.wait(until.elementLocated(By.css(`.form-blacklist-form-row:nth-child(${rows.length + 1})`)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async addPartialBlacklist(): Promise<void> {
|
||||||
|
let rows = await this.webdriver.findElements(By.css(`.form-partial-blacklist-form-row`));
|
||||||
|
let button = await this.webdriver.findElement(By.css('.form-partial-blacklist-form .ui-add-button'))
|
||||||
|
await button.click();
|
||||||
|
await this.webdriver.wait(until.elementLocated(By.css(`.form-partial-blacklist-form-row:nth-child(${rows.length + 2})`)));
|
||||||
|
}
|
||||||
|
|
||||||
async removeBlackList(nth: number): Promise<void> {
|
async removeBlackList(nth: number): Promise<void> {
|
||||||
let buttons = await this.webdriver.findElements(By.css('.form-blacklist-form-row .ui-delete-button'));
|
let buttons = await this.webdriver.findElements(By.css('.form-blacklist-form-row .ui-delete-button'));
|
||||||
if (buttons.length <= nth) {
|
if (buttons.length <= nth) {
|
||||||
|
@ -51,6 +76,14 @@ export default class FormOptionPage {
|
||||||
await buttons[nth].click()
|
await buttons[nth].click()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removePartialBlackList(nth: number): Promise<void> {
|
||||||
|
let buttons = await this.webdriver.findElements(By.css('.form-partial-blacklist-form-row .ui-delete-button'));
|
||||||
|
if (buttons.length <= nth) {
|
||||||
|
throw new RangeError('Index out of range to remove partial blacklist')
|
||||||
|
}
|
||||||
|
await buttons[nth].click()
|
||||||
|
}
|
||||||
|
|
||||||
async addSearchEngine(): Promise<void> {
|
async addSearchEngine(): Promise<void> {
|
||||||
let rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`));
|
let rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`));
|
||||||
let button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button'))
|
let button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button'))
|
||||||
|
|
|
@ -35,7 +35,7 @@ describe("options form page", () => {
|
||||||
assert.strictEqual(settings.source, 'form')
|
assert.strictEqual(settings.source, 'form')
|
||||||
});
|
});
|
||||||
|
|
||||||
it('add blacklist', async () => {
|
it('add blacklist item', async () => {
|
||||||
let page = await OptionPage.open(lanthan);
|
let page = await OptionPage.open(lanthan);
|
||||||
let forms = await page.switchToForm();
|
let forms = await page.switchToForm();
|
||||||
// Scroll is required to click a button on Firefox 60
|
// Scroll is required to click a button on Firefox 60
|
||||||
|
@ -64,6 +64,53 @@ describe("options form page", () => {
|
||||||
assert.deepStrictEqual(settings.form.blacklist, ['yahoo.com'])
|
assert.deepStrictEqual(settings.form.blacklist, ['yahoo.com'])
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('add a partial blacklist item', async () => {
|
||||||
|
let page = await OptionPage.open(lanthan);
|
||||||
|
let forms = await page.switchToForm();
|
||||||
|
// Scroll is required to click a button on Firefox 60
|
||||||
|
await page.scrollTo(0, 1000);
|
||||||
|
|
||||||
|
// assert default
|
||||||
|
let settings = (await browser.storage.local.get('settings')).settings;
|
||||||
|
assert.deepStrictEqual(settings.form.blacklist, []);
|
||||||
|
|
||||||
|
// add blacklist items
|
||||||
|
await forms.addPartialBlacklist();
|
||||||
|
await forms.setPartialBlacklist(0, 'google.com', 'j,k,<C-U>');
|
||||||
|
|
||||||
|
settings = (await browser.storage.local.get('settings')).settings;
|
||||||
|
assert.deepStrictEqual(settings.form.blacklist, [
|
||||||
|
{ url: 'google.com', keys: ['j', 'k', '<C-U>'] },
|
||||||
|
]);
|
||||||
|
|
||||||
|
await forms.addPartialBlacklist();
|
||||||
|
await forms.setPartialBlacklist(1, 'yahoo.com', 'g,G');
|
||||||
|
|
||||||
|
settings = (await browser.storage.local.get('settings')).settings;
|
||||||
|
assert.deepStrictEqual(settings.form.blacklist, [
|
||||||
|
{ url: 'google.com', keys: ['j', 'k', '<C-U>'] },
|
||||||
|
{ url: 'yahoo.com', keys: ['g', 'G'] },
|
||||||
|
]);
|
||||||
|
|
||||||
|
await forms.addBlacklist();
|
||||||
|
await forms.setBlacklist(0, 'bing.com');
|
||||||
|
|
||||||
|
settings = (await browser.storage.local.get('settings')).settings;
|
||||||
|
assert.deepStrictEqual(settings.form.blacklist, [
|
||||||
|
{ url: 'google.com', keys: ['j', 'k', '<C-U>'] },
|
||||||
|
{ url: 'yahoo.com', keys: ['g', 'G'] },
|
||||||
|
'bing.com',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// delete first item
|
||||||
|
await forms.removePartialBlackList(0);
|
||||||
|
settings = (await browser.storage.local.get('settings')).settings;
|
||||||
|
assert.deepStrictEqual(settings.form.blacklist, [
|
||||||
|
{ url: 'yahoo.com', keys: ['g', 'G'] },
|
||||||
|
'bing.com',
|
||||||
|
])
|
||||||
|
});
|
||||||
|
|
||||||
it('add search engines', async () => {
|
it('add search engines', async () => {
|
||||||
let page = await OptionPage.open(lanthan);
|
let page = await OptionPage.open(lanthan);
|
||||||
let forms = await page.switchToForm();
|
let forms = await page.switchToForm();
|
||||||
|
|
Reference in a new issue