Opened 23 months ago

Closed 22 months ago

Last modified 21 months ago

#6893 closed change (fixed)

Split out the INIParser class into its own file

Reported by: mjethani Assignee: mjethani
Priority: P3 Milestone:
Module: Core Keywords:
Cc: Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

Description (last modified by mjethani)


The INIParser class is currently internal to lib/filterStorage.js. It is not well documented. It is tested only as part of lib/filterStorage.js.

This is an important class for multiple reasons, most importantly performance. If we are to make changes to the INI file format (see discussion in #6861), this class should firstly be well written and well documented. We are also migrating to ES2015 classes on a file-by-file basis (see #6741), and it would be easier to manage the changes if large files like lib/filterStorage.js are gradually split up into smaller files.

What to change

  1. Move the definition of INIParser into lib/iniParser.js
  2. Convert to ES2015 class
  3. Make properties not needed by other modules "private" (use an underscore prefix)
  4. Add JSDoc comments

Additional notes

The unit testing for this class is currently covered by test/filterStorage_readwrite.js. This is OK, there's no need to write separate tests, but it may make sense to do so in the future, especially if there are changes to the file format.

Hints for testers

This is a development/refactoring task and there are no specific things to test, as there is no expected change in behavior. Just make sure that there are no regressions, i.e. filters are saved and loaded correctly to and from the patterns.ini file.

Try this:

  1. Add a filter foo in the "My filters" box and click Save
  2. Add another filter and click Save
  3. Add a comment ! foo and click Save
  4. Restart the extension (disable and enabled on chrome://extensions)
  5. Open the options page and see that the two filters and comment are still there

Change History (9)

comment:1 Changed 23 months ago by mjethani

  • Description modified (diff)

comment:2 Changed 22 months ago by abpbot

A commit referencing this issue has landed:
Issue 6893, 6741 - Split out INIParser into its own file

comment:3 Changed 22 months ago by mjethani

  • Description modified (diff)
  • Resolution set to fixed
  • Status changed from new to closed

comment:4 Changed 22 months ago by mjethani

  • Description modified (diff)

comment:5 Changed 21 months ago by Ross

I have a dumb question: Where should we be looking for patterns.ini now?

comment:6 Changed 21 months ago by mjethani

Not a dumb question at all. In the current extension for Chrome, you could get the contents of patterns.ini by pasting the following line into the background page console:"file:patterns.ini").then(console.log);

This should give you an object with two properties, content and lastModified, and the content property is the serialized data.

comment:7 Changed 21 months ago by mjethani

  • Description modified (diff)

comment:8 Changed 21 months ago by mjethani

Having said the above, I don't think anybody should have to manually examine the patterns.ini. I've added a simple test idea in the description now.

comment:9 Changed 21 months ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Thanks, that makes sense! This looks to be working as expected then.

Firefox 62 / 51 / Windows 10
Chrome 69 / 49 / Windows 10
Opera 56 / 36 / Windows 10

Note: See TracTickets for help on using tickets.