Skip to content

Commit

Permalink
Rename "is enabled" to "options".
Browse files Browse the repository at this point in the history
The enabled bit is really just the first option.  Good place to handle all the other "save these user specified values".

Refs greasemonkey#2843
  • Loading branch information
arantius committed Jun 29, 2018
1 parent 0381ea4 commit 3ae55ca
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
16 changes: 12 additions & 4 deletions doc/Messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@ Data:
* `value` The new value to store.

# EnabledChanged
Sent by: `bg/is-enabled.js`.
Sent by: `bg/options.js`.

Sent whenever the global enabled status changes.

* `enabled` boolean, the new status (true = enabled, false = disabled).

# EnabledQuery
Received by: `bg/is-enabled.js`.
Received by: `bg/options.js`.

Send with no data, responds with a boolean: the new status
(true = enabled, false = disabled).

# EnabledSet
Received by: `bg/is-enabled.js`.
Received by: `bg/options.js`.

Send this to set the global enabled status.

* `enabled` boolean, the new status (true = enabled, false = disabled).

# EnabledToggle
Received by: `bg/is-enabled.js`.
Received by: `bg/options.js`.

Send this to toggle the global enabled status. No data.

Expand All @@ -109,6 +109,14 @@ Response data:

* An array of `.details` objects from installed `RunnableUserScript`s.

# SaveOptions
Sent by: `browser/monkey-menu.js`
Received by: `bg/options.js`

Passes the user's option values from content to background for persistence. Request data:

* `excludes` A string, one `@exclude` pattern per line.

# UserScriptGet
Sent by: `content/edit-user-script.js`

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"/src/bg/api-provider-source.js",
"/src/bg/execute.js",
"/src/bg/export-db.js",
"/src/bg/is-enabled.js",
"/src/bg/on-message.js",
"/src/bg/on-user-script-notification.js",
"/src/bg/on-user-script-open-in-tab.js",
"/src/bg/on-user-script-xhr.js",
"/src/bg/options.js",
"/src/bg/user-script-detect.js",
"/src/bg/user-script-registry.js",
"/src/bg/value-store.js",
Expand Down
File renamed without changes.
21 changes: 0 additions & 21 deletions test/bg/is-enabled.test.js

This file was deleted.

23 changes: 23 additions & 0 deletions test/bg/options.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
describe('bg/options', () => {
describe('global enable bit', () => {
// Leave GM globally enabled after these tests run.
after(() => {
setGlobalEnabled(true);
});

it('passes data between setGlobalEnabled() and getGlobalEnabled()', () => {
setGlobalEnabled(true);
assert.equal(getGlobalEnabled(), true);
setGlobalEnabled(false);
assert.equal(getGlobalEnabled(), false);
});

it('toggles enabled state', () => {
setGlobalEnabled(true);
assert.equal(getGlobalEnabled(), true);
toggleGlobalEnabled();
assert.equal(getGlobalEnabled(), false);
});
});
});

0 comments on commit 3ae55ca

Please sign in to comment.