summaryrefslogtreecommitdiffstats
path: root/browser/components/tests/unit/test_browserGlue_migration_places_xulstore.js
blob: 7e2ae93bfe273e577180a0f5e90f43c616a36573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
const TOPICDATA_BROWSERGLUE_TEST = "force-ui-migration";
const UI_VERSION = 120;

const { AppConstants } = ChromeUtils.importESModule(
  "resource://gre/modules/AppConstants.sys.mjs"
);
const { PlacesUIUtils } = ChromeUtils.importESModule(
  "resource:///modules/PlacesUIUtils.sys.mjs"
);

add_task(async function has_not_used_ctrl_tab_and_its_off() {
  const gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"].getService(
    Ci.nsIObserver
  );
  registerCleanupFunction(() => {
    Services.prefs.clearUserPref("browser.migration.version");
  });
  Services.prefs.setIntPref("browser.migration.version", UI_VERSION);

  Services.xulStore.setValue(
    AppConstants.BROWSER_CHROME_URL,
    "place:test",
    "open",
    "true"
  );

  // Simulate a migration.
  gBrowserGlue.observe(
    null,
    TOPIC_BROWSERGLUE_TEST,
    TOPICDATA_BROWSERGLUE_TEST
  );

  Assert.equal(
    Services.xulStore.getValue(
      AppConstants.BROWSER_CHROME_URL,
      PlacesUIUtils.obfuscateUrlForXulStore("place:test"),
      "open"
    ),
    "true"
  );

  Assert.greater(
    Services.prefs.getIntPref("browser.migration.version"),
    UI_VERSION,
    "Check migration version has been bumped up"
  );
});