Skip to content
Snippets Groups Projects
Commit fb135b95 authored by Lina Butler's avatar Lina Butler
Browse files

Bug 1825157 - Unify the fake pref implementations used in tests. r=nanj

Before this commit, the New Tab tests had two fake pref
implementations:

* The `Services.prefs` mock in `TEST_GLOBAL`, which stubbed out a
  handful of `nsIPrefBranch` methods.
* `FakensIPrefBranch`, which mocked a different handful of
  `nsIPrefBranch` methods.

This commit:

* Consolidates the two fake implementations into the mock
  `FakensIPrefBranch` class.
* Adds a `FakensIPrefService` subclass of `FakensIPrefBranch`, with
  additional methods specific to `nsIPrefService`.
* Replaces `FakensIPrefBranch.prototype.prefs` with a new
  `FAKE_GLOBAL_PREFS` map. The new approach still lets tests change and
  clear prefs on existing instances of `FakensIPrefBranch` and its
  subclasses, but makes the shared state explicit. The old approach of
  mutating `FakensIPrefBranch.prototype.prefs` relied on a subtle quirk
  of `prefs` being shared by all instances of `FakensIPrefBranch` and
  its subclasses, and broke when setting `prefs` to a new, empty
  object.
* Moves `{observe, ignore}Branch` into `FakePrefs`, since these are
  not part of the `nsIPrefBranch` interface.

Differential Revision: https://phabricator.services.mozilla.com/D173897
parent e418d8bb
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment